Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
Torchaudio
Commits
7d6e486a
Unverified
Commit
7d6e486a
authored
Oct 24, 2023
by
moto
Committed by
GitHub
Oct 24, 2023
Browse files
Refactor cmake helper functions (#3672)
parent
1caa3fcc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
7 deletions
+49
-7
cmake/TorchAudioHelper.cmake
cmake/TorchAudioHelper.cmake
+48
-6
tools/setup_helpers/extension.py
tools/setup_helpers/extension.py
+1
-1
No files found.
cmake/TorchAudioHelper.cmake
View file @
7d6e486a
...
@@ -14,7 +14,7 @@ if ("caffe2::mkl" IN_LIST dep)
...
@@ -14,7 +14,7 @@ if ("caffe2::mkl" IN_LIST dep)
set_target_properties
(
torch_cpu PROPERTIES INTERFACE_LINK_LIBRARIES
"
${
dep
}
"
)
set_target_properties
(
torch_cpu PROPERTIES INTERFACE_LINK_LIBRARIES
"
${
dep
}
"
)
endif
()
endif
()
function
(
torchaudio_library
name source include_dirs link_libraries compile_defs
)
function
(
_library destination
name source include_dirs link_libraries compile_defs
)
add_library
(
${
name
}
SHARED
${
source
}
)
add_library
(
${
name
}
SHARED
${
source
}
)
target_include_directories
(
${
name
}
PRIVATE
"
${
PROJECT_SOURCE_DIR
}
/src;
${
include_dirs
}
"
)
target_include_directories
(
${
name
}
PRIVATE
"
${
PROJECT_SOURCE_DIR
}
/src;
${
include_dirs
}
"
)
target_link_libraries
(
${
name
}
${
link_libraries
}
)
target_link_libraries
(
${
name
}
${
link_libraries
}
)
...
@@ -25,11 +25,32 @@ function (torchaudio_library name source include_dirs link_libraries compile_def
...
@@ -25,11 +25,32 @@ function (torchaudio_library name source include_dirs link_libraries compile_def
endif
(
MSVC
)
endif
(
MSVC
)
install
(
install
(
TARGETS
${
name
}
TARGETS
${
name
}
LIBRARY DESTINATION
lib
LIBRARY DESTINATION
"
${
destination
}
"
RUNTIME DESTINATION
lib
# For Windows
RUNTIME DESTINATION
"
${
destination
}
"
# For Windows
)
)
endfunction
()
endfunction
()
function
(
torchaudio_library name source include_dirs link_libraries compile_defs
)
_library
(
torchaudio/lib
"
${
name
}
"
"
${
source
}
"
"
${
include_dirs
}
"
"
${
link_libraries
}
"
"
${
compile_defs
}
"
)
endfunction
()
function
(
torio_library name source include_dirs link_libraries compile_defs
)
_library
(
torio/lib
"
${
name
}
"
"
${
source
}
"
"
${
include_dirs
}
"
"
${
link_libraries
}
"
"
${
compile_defs
}
"
)
endfunction
()
if
(
BUILD_TORCHAUDIO_PYTHON_EXTENSION
)
if
(
BUILD_TORCHAUDIO_PYTHON_EXTENSION
)
# See https://github.com/pytorch/pytorch/issues/38122
# See https://github.com/pytorch/pytorch/issues/38122
...
@@ -39,7 +60,7 @@ if (BUILD_TORCHAUDIO_PYTHON_EXTENSION)
...
@@ -39,7 +60,7 @@ if (BUILD_TORCHAUDIO_PYTHON_EXTENSION)
find_package
(
Python3
${
PYTHON_VERSION
}
EXACT COMPONENTS Development
)
find_package
(
Python3
${
PYTHON_VERSION
}
EXACT COMPONENTS Development
)
set
(
ADDITIONAL_ITEMS Python3::Python
)
set
(
ADDITIONAL_ITEMS Python3::Python
)
endif
()
endif
()
function
(
torchaudio_extens
ion name sources include_dirs libraries definitions
)
function
(
_extension destinat
ion name sources include_dirs libraries definitions
)
add_library
(
${
name
}
SHARED
${
sources
}
)
add_library
(
${
name
}
SHARED
${
sources
}
)
target_compile_definitions
(
${
name
}
PRIVATE
"
${
definitions
}
"
)
target_compile_definitions
(
${
name
}
PRIVATE
"
${
definitions
}
"
)
target_include_directories
(
target_include_directories
(
...
@@ -66,8 +87,29 @@ if (BUILD_TORCHAUDIO_PYTHON_EXTENSION)
...
@@ -66,8 +87,29 @@ if (BUILD_TORCHAUDIO_PYTHON_EXTENSION)
endif
()
endif
()
install
(
install
(
TARGETS
${
name
}
TARGETS
${
name
}
LIBRARY DESTINATION lib
LIBRARY DESTINATION
"
${
destination
}
"
RUNTIME DESTINATION lib
# For Windows
RUNTIME DESTINATION
"
${
destination
}
"
# For Windows
)
endfunction
()
function
(
torchaudio_extension name sources include_dirs libraries definitions
)
_extension
(
torchaudio/lib
"
${
name
}
"
"
${
sources
}
"
"
${
include_dirs
}
"
"
${
libraries
}
"
"
${
definitions
}
"
)
endfunction
()
function
(
torio_extension name sources include_dirs libraries definitions
)
_extension
(
torio/lib
"
${
name
}
"
"
${
sources
}
"
"
${
include_dirs
}
"
"
${
libraries
}
"
"
${
definitions
}
"
)
)
endfunction
()
endfunction
()
endif
()
endif
()
...
...
tools/setup_helpers/extension.py
View file @
7d6e486a
...
@@ -114,7 +114,7 @@ class CMakeBuild(build_ext):
...
@@ -114,7 +114,7 @@ class CMakeBuild(build_ext):
# `torchaudio.[so|dylib|pyd]`, so we need something `torchaudio.foo`, that is
# `torchaudio.[so|dylib|pyd]`, so we need something `torchaudio.foo`, that is
# interpreted as `torchaudio/foo.so` then use dirname to get the `torchaudio`
# interpreted as `torchaudio/foo.so` then use dirname to get the `torchaudio`
# directory.
# directory.
extdir
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
self
.
get_ext_fullpath
(
"
torchaudio.lib
"
)))
extdir
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
self
.
get_ext_fullpath
(
"
foo
"
)))
# required for auto-detection of auxiliary "native" libs
# required for auto-detection of auxiliary "native" libs
if
not
extdir
.
endswith
(
os
.
path
.
sep
):
if
not
extdir
.
endswith
(
os
.
path
.
sep
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment