Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
CMake
CMake
Commits
38ffcedd
Commit
38ffcedd
authored
Jul 03, 2018
by
Marc Chevrier
Committed by
Brad King
Jul 03, 2018
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UseSWIG: reintroduce legacy target name management
Fixes:
#18140
parent
51e7d415
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
115 additions
and
53 deletions
+115
-53
Modules/UseSWIG.cmake
Modules/UseSWIG.cmake
+111
-53
Tests/UseSWIG/BasicConfiguration.cmake
Tests/UseSWIG/BasicConfiguration.cmake
+1
-0
Tests/UseSWIG/ModuleVersion2/CMakeLists.txt
Tests/UseSWIG/ModuleVersion2/CMakeLists.txt
+1
-0
Tests/UseSWIG/MultipleModules/CMakeLists.txt
Tests/UseSWIG/MultipleModules/CMakeLists.txt
+1
-0
Tests/UseSWIG/MultiplePython/CMakeLists.txt
Tests/UseSWIG/MultiplePython/CMakeLists.txt
+1
-0
No files found.
Modules/UseSWIG.cmake
View file @
38ffcedd
...
@@ -28,6 +28,12 @@ Defines the following command for use with ``SWIG``:
...
@@ -28,6 +28,12 @@ Defines the following command for use with ``SWIG``:
those targets can be used with any command expecting a target (e.g.
those targets can be used with any command expecting a target (e.g.
:command:`target_link_libraries`).
:command:`target_link_libraries`).
.. note::
The variable ``SWIG_MODULE_<name>_REAL_NAME`` will be set to the name
of the swig module target library. This variable is useless if variable
``UseSWIG_TARGET_NAME_PREFERENCE`` is set to ``STANDARD``.
.. note::
.. note::
For multi-config generators, this module does not support
For multi-config generators, this module does not support
...
@@ -70,14 +76,29 @@ Defines the following command for use with ``SWIG``:
...
@@ -70,14 +76,29 @@ Defines the following command for use with ``SWIG``:
identified as sources for the ``SWIG`` tool. Other files will be handled in
identified as sources for the ``SWIG`` tool. Other files will be handled in
the standard way.
the standard way.
.. note::
.. note::
If ``UseSWIG_MODULE_VERSION`` is set to 2, it is **strongly** recommended
to use a dedicated directory unique to the target when either the
``OUTPUT_DIR`` option or the ``CMAKE_SWIG_OUTDIR`` variable are specified.
The output directory contents are erased as part of the target build, so
to prevent interference between targets or losing other important files,
each target should have its own dedicated output directory.
.. command:: swig_link_libraries
Link libraries to swig module::
swig_link_libraries(<name> <item>...)
This command has same capabilities as :command:`target_link_libraries`
command.
.. note::
If ``UseSWIG_MODULE_VERSION`` is set to 2, it is **strongly** recommended
If variable ``UseSWIG_TARGET_NAME_PREFERENCE`` is set to ``STANDARD``, this
to use a dedicated directory unique to the target when either the
command is deprecated and :command:`target_link_libraries` command must be
``OUTPUT_DIR`` option or the ``CMAKE_SWIG_OUTDIR`` variable are specified.
used instead.
The output directory contents are erased as part of the target build, so
to prevent interference between targets or losing other important files, each
target should have its own dedicated output directory.
Source file properties on module files **must** be set before the invocation
Source file properties on module files **must** be set before the invocation
of the ``swig_add_library`` command to specify special behavior of SWIG and
of the ``swig_add_library`` command to specify special behavior of SWIG and
...
@@ -123,6 +144,7 @@ input files.
...
@@ -123,6 +144,7 @@ input files.
.. code-block:: cmake
.. code-block:: cmake
set (UseSWIG_TARGET_NAME_PREFERENCE STANDARD)
swig_add_library(mymod LANGUAGE python SOURCES mymod.i)
swig_add_library(mymod LANGUAGE python SOURCES mymod.i)
set_property(TARGET mymod PROPERTY SWIG_COMPILE_DEFINITIONS MY_DEF1 MY_DEF2)
set_property(TARGET mymod PROPERTY SWIG_COMPILE_DEFINITIONS MY_DEF1 MY_DEF2)
set_property(TARGET mymod PROPERTY SWIG_COMPILE_OPTIONS -bla -blb)
set_property(TARGET mymod PROPERTY SWIG_COMPILE_OPTIONS -bla -blb)
...
@@ -143,6 +165,7 @@ information about support files generated by ``SWIG`` interface compilation.
...
@@ -143,6 +165,7 @@ information about support files generated by ``SWIG`` interface compilation.
.. code-block:: cmake
.. code-block:: cmake
set (UseSWIG_TARGET_NAME_PREFERENCE STANDARD)
swig_add_library(mymod LANGUAGE python SOURCES mymod.i)
swig_add_library(mymod LANGUAGE python SOURCES mymod.i)
get_property(support_files TARGET mymod PROPERTY SWIG_SUPPORT_FILES)
get_property(support_files TARGET mymod PROPERTY SWIG_SUPPORT_FILES)
...
@@ -160,6 +183,13 @@ information about support files generated by ``SWIG`` interface compilation.
...
@@ -160,6 +183,13 @@ information about support files generated by ``SWIG`` interface compilation.
Some variables can be set to customize the behavior of ``swig_add_library``
Some variables can be set to customize the behavior of ``swig_add_library``
as well as ``SWIG``:
as well as ``SWIG``:
``UseSWIG_TARGET_NAME_PREFERENCE``
Specify target name strategy.
* Set to ``LEGACY`` or undefined: legacy strategy is applied. Variable
``SWIG_MODULE_<name>_REAL_NAME`` must be used to get real target name.
* Set to ``STANDARD``: target name matches specified name.
``UseSWIG_MODULE_VERSION``
``UseSWIG_MODULE_VERSION``
Specify different behaviors for ``UseSWIG`` module.
Specify different behaviors for ``UseSWIG`` module.
...
@@ -302,23 +332,29 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile)
...
@@ -302,23 +332,29 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile)
set
(
workingdir
"
${
outdir
}
"
)
set
(
workingdir
"
${
outdir
}
"
)
endif
()
endif
()
if
(
SWIG_TARGET_NAME
)
set
(
target_name
${
SWIG_TARGET_NAME
}
)
else
()
set
(
target_name
${
name
}
)
endif
()
set
(
swig_source_file_flags
${
CMAKE_SWIG_FLAGS
}
)
set
(
swig_source_file_flags
${
CMAKE_SWIG_FLAGS
}
)
# handle various swig compile flags properties
# handle various swig compile flags properties
get_source_file_property
(
include_directories
"
${
infile
}
"
INCLUDE_DIRECTORIES
)
get_source_file_property
(
include_directories
"
${
infile
}
"
INCLUDE_DIRECTORIES
)
if
(
include_directories
)
if
(
include_directories
)
list
(
APPEND swig_source_file_flags
"$<$<BOOL:
${
include_directories
}
>:-I$<JOIN:
${
include_directories
}
,$<SEMICOLON>-I>>"
)
list
(
APPEND swig_source_file_flags
"$<$<BOOL:
${
include_directories
}
>:-I$<JOIN:
${
include_directories
}
,$<SEMICOLON>-I>>"
)
endif
()
endif
()
set
(
property
"$<TARGET_PROPERTY:
${
name
}
,SWIG_INCLUDE_DIRECTORIES>"
)
set
(
property
"$<TARGET_PROPERTY:
${
target_
name
}
,SWIG_INCLUDE_DIRECTORIES>"
)
list
(
APPEND swig_source_file_flags
"$<$<BOOL:
${
property
}
>:-I$<JOIN:$<TARGET_GENEX_EVAL:
${
name
}
,
${
property
}
>,$<SEMICOLON>-I>>"
)
list
(
APPEND swig_source_file_flags
"$<$<BOOL:
${
property
}
>:-I$<JOIN:$<TARGET_GENEX_EVAL:
${
target_
name
}
,
${
property
}
>,$<SEMICOLON>-I>>"
)
set
(
property
"$<TARGET_PROPERTY:
${
name
}
,SWIG_COMPILE_DEFINITIONS>"
)
set
(
property
"$<TARGET_PROPERTY:
${
target_
name
}
,SWIG_COMPILE_DEFINITIONS>"
)
list
(
APPEND swig_source_file_flags
"$<$<BOOL:
${
property
}
>:-D$<JOIN:$<TARGET_GENEX_EVAL:
${
name
}
,
${
property
}
>,$<SEMICOLON>-D>>"
)
list
(
APPEND swig_source_file_flags
"$<$<BOOL:
${
property
}
>:-D$<JOIN:$<TARGET_GENEX_EVAL:
${
target_
name
}
,
${
property
}
>,$<SEMICOLON>-D>>"
)
get_source_file_property
(
compile_definitions
"
${
infile
}
"
COMPILE_DEFINITIONS
)
get_source_file_property
(
compile_definitions
"
${
infile
}
"
COMPILE_DEFINITIONS
)
if
(
compile_definitions
)
if
(
compile_definitions
)
list
(
APPEND swig_source_file_flags
"$<$<BOOL:
${
compile_definitions
}
>:-D$<JOIN:
${
compile_definitions
}
,$<SEMICOLON>-D>>"
)
list
(
APPEND swig_source_file_flags
"$<$<BOOL:
${
compile_definitions
}
>:-D$<JOIN:
${
compile_definitions
}
,$<SEMICOLON>-D>>"
)
endif
()
endif
()
list
(
APPEND swig_source_file_flags
"$<TARGET_GENEX_EVAL:
${
name
}
,$<TARGET_PROPERTY:
${
name
}
,SWIG_COMPILE_OPTIONS>>"
)
list
(
APPEND swig_source_file_flags
"$<TARGET_GENEX_EVAL:
${
target_
name
}
,$<TARGET_PROPERTY:
${
target_
name
}
,SWIG_COMPILE_OPTIONS>>"
)
get_source_file_property
(
compile_options
"
${
infile
}
"
COMPILE_OPTIONS
)
get_source_file_property
(
compile_options
"
${
infile
}
"
COMPILE_OPTIONS
)
if
(
compile_options
)
if
(
compile_options
)
list
(
APPEND swig_source_file_flags
${
compile_options
}
)
list
(
APPEND swig_source_file_flags
${
compile_options
}
)
...
@@ -377,7 +413,7 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile)
...
@@ -377,7 +413,7 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile)
list
(
APPEND swig_extra_flags
${
SWIG_MODULE_
${
name
}
_EXTRA_FLAGS
}
)
list
(
APPEND swig_extra_flags
${
SWIG_MODULE_
${
name
}
_EXTRA_FLAGS
}
)
# dependencies
# dependencies
set
(
swig_dependencies
${
SWIG_MODULE_
${
name
}
_EXTRA_DEPS
}
$<TARGET_PROPERTY:
${
name
}
,SWIG_DEPENDS>
)
set
(
swig_dependencies
${
SWIG_MODULE_
${
name
}
_EXTRA_DEPS
}
$<TARGET_PROPERTY:
${
target_
name
}
,SWIG_DEPENDS>
)
get_source_file_property
(
file_depends
"
${
infile
}
"
DEPENDS
)
get_source_file_property
(
file_depends
"
${
infile
}
"
DEPENDS
)
if
(
file_depends
)
if
(
file_depends
)
list
(
APPEND swig_dependencies
${
file_depends
}
)
list
(
APPEND swig_dependencies
${
file_depends
}
)
...
@@ -434,13 +470,13 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile)
...
@@ -434,13 +470,13 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile)
## add all properties for generated file to various properties
## add all properties for generated file to various properties
get_property
(
include_directories SOURCE
"
${
infile
}
"
PROPERTY GENERATED_INCLUDE_DIRECTORIES
)
get_property
(
include_directories SOURCE
"
${
infile
}
"
PROPERTY GENERATED_INCLUDE_DIRECTORIES
)
set_property
(
SOURCE
"
${
swig_generated_file_fullname
}
"
PROPERTY INCLUDE_DIRECTORIES
${
include_directories
}
$<TARGET_GENEX_EVAL:
${
name
}
,$<TARGET_PROPERTY:
${
name
}
,SWIG_GENERATED_INCLUDE_DIRECTORIES>>
)
set_property
(
SOURCE
"
${
swig_generated_file_fullname
}
"
PROPERTY INCLUDE_DIRECTORIES
${
include_directories
}
$<TARGET_GENEX_EVAL:
${
target_
name
}
,$<TARGET_PROPERTY:
${
target_
name
}
,SWIG_GENERATED_INCLUDE_DIRECTORIES>>
)
get_property
(
compile_definitions SOURCE
"
${
infile
}
"
PROPERTY GENERATED_COMPILE_DEFINITIONS
)
get_property
(
compile_definitions SOURCE
"
${
infile
}
"
PROPERTY GENERATED_COMPILE_DEFINITIONS
)
set_property
(
SOURCE
"
${
swig_generated_file_fullname
}
"
PROPERTY COMPILE_DEFINITIONS $<TARGET_GENEX_EVAL:
${
name
}
,$<TARGET_PROPERTY:
${
name
}
,SWIG_GENERATED_COMPILE_DEFINITIONS>>
${
compile_definitions
}
)
set_property
(
SOURCE
"
${
swig_generated_file_fullname
}
"
PROPERTY COMPILE_DEFINITIONS $<TARGET_GENEX_EVAL:
${
target_
name
}
,$<TARGET_PROPERTY:
${
target_
name
}
,SWIG_GENERATED_COMPILE_DEFINITIONS>>
${
compile_definitions
}
)
get_property
(
compile_options SOURCE
"
${
infile
}
"
PROPERTY GENERATED_COMPILE_OPTIONS
)
get_property
(
compile_options SOURCE
"
${
infile
}
"
PROPERTY GENERATED_COMPILE_OPTIONS
)
set_property
(
SOURCE
"
${
swig_generated_file_fullname
}
"
PROPERTY COMPILE_OPTIONS $<TARGET_GENEX_EVAL:
${
name
}
,$<TARGET_PROPERTY:
${
name
}
,SWIG_GENERATED_COMPILE_OPTIONS>>
${
compile_options
}
)
set_property
(
SOURCE
"
${
swig_generated_file_fullname
}
"
PROPERTY COMPILE_OPTIONS $<TARGET_GENEX_EVAL:
${
target_
name
}
,$<TARGET_PROPERTY:
${
target_
name
}
,SWIG_GENERATED_COMPILE_OPTIONS>>
${
compile_options
}
)
set
(
${
outfiles
}
"
${
swig_generated_file_fullname
}
"
${
swig_extra_generated_files
}
PARENT_SCOPE
)
set
(
${
outfiles
}
"
${
swig_generated_file_fullname
}
"
${
swig_extra_generated_files
}
PARENT_SCOPE
)
...
@@ -469,13 +505,6 @@ function(SWIG_ADD_LIBRARY name)
...
@@ -469,13 +505,6 @@ function(SWIG_ADD_LIBRARY name)
set
(
multiValueArgs SOURCES
)
set
(
multiValueArgs SOURCES
)
cmake_parse_arguments
(
_SAM
"
${
options
}
"
"
${
oneValueArgs
}
"
"
${
multiValueArgs
}
"
${
ARGN
}
)
cmake_parse_arguments
(
_SAM
"
${
options
}
"
"
${
oneValueArgs
}
"
"
${
multiValueArgs
}
"
${
ARGN
}
)
if
(
TARGET
${
name
}
)
# a target with same name is already defined.
# call NOW add_library command to raise the most useful error message
add_library
(
${
name
}
)
return
()
endif
()
if
(
_SAM_UNPARSED_ARGUMENTS
)
if
(
_SAM_UNPARSED_ARGUMENTS
)
message
(
FATAL_ERROR
"SWIG_ADD_LIBRARY:
${
_SAM_UNPARSED_ARGUMENTS
}
: unexpected arguments"
)
message
(
FATAL_ERROR
"SWIG_ADD_LIBRARY:
${
_SAM_UNPARSED_ARGUMENTS
}
: unexpected arguments"
)
endif
()
endif
()
...
@@ -494,16 +523,44 @@ function(SWIG_ADD_LIBRARY name)
...
@@ -494,16 +523,44 @@ function(SWIG_ADD_LIBRARY name)
unset
(
_SAM_TYPE
)
unset
(
_SAM_TYPE
)
endif
()
endif
()
if
(
NOT DEFINED UseSWIG_TARGET_NAME_PREFERENCE
)
set
(
UseSWIG_TARGET_NAME_PREFERENCE LEGACY
)
elseif
(
NOT UseSWIG_TARGET_NAME_PREFERENCE MATCHES
"^(LEGACY|STANDARD)$"
)
message
(
FATAL_ERROR
"UseSWIG_TARGET_NAME_PREFERENCE:
${
UseSWIG_TARGET_NAME_PREFERENCE
}
: invalid value. 'LEGACY' or 'STANDARD' is expected."
)
endif
()
if
(
NOT DEFINED UseSWIG_MODULE_VERSION
)
if
(
NOT DEFINED UseSWIG_MODULE_VERSION
)
set
(
UseSWIG_MODULE_VERSION 1
)
set
(
UseSWIG_MODULE_VERSION 1
)
elseif
(
NOT UseSWIG_MODULE_VERSION MATCHES
"^(1|2)$"
)
elseif
(
NOT UseSWIG_MODULE_VERSION MATCHES
"^(1|2)$"
)
message
(
FATAL_ERROR
"UseSWIG_MODULE_VERSION:
${
UseSWIG_MODULE_VERSION
}
: invalid value. 1 or 2 is expected."
)
message
(
FATAL_ERROR
"UseSWIG_MODULE_VERSION:
${
UseSWIG_MODULE_VERSION
}
: invalid value. 1 or 2 is expected."
)
endif
()
endif
()
set
(
workingdir
"
${
CMAKE_CURRENT_BINARY_DIR
}${
CMAKE_FILES_DIRECTORY
}
/
${
name
}
.dir"
)
set
(
SWIG_MODULE_
${
name
}
_NOPROXY
${
_SAM_NO_PROXY
}
)
swig_module_initialize
(
${
name
}
${
_SAM_LANGUAGE
}
)
# compute real target name.
if
(
UseSWIG_TARGET_NAME_PREFERENCE STREQUAL
"LEGACY"
AND
SWIG_MODULE_
${
name
}
_LANGUAGE STREQUAL
"PYTHON"
AND NOT SWIG_MODULE_
${
name
}
_NOPROXY
)
# swig will produce a module.py containing an 'import _modulename' statement,
# which implies having a corresponding _modulename.so (*NIX), _modulename.pyd (Win32),
# unless the -noproxy flag is used
set
(
target_name
"_
${
name
}
"
)
else
()
set
(
target_name
"
${
name
}
"
)
endif
()
if
(
TARGET
${
target_name
}
)
# a target with same name is already defined.
# call NOW add_library command to raise the most useful error message
add_library
(
${
target_name
}
)
return
()
endif
()
set
(
workingdir
"
${
CMAKE_CURRENT_BINARY_DIR
}${
CMAKE_FILES_DIRECTORY
}
/
${
target_name
}
.dir"
)
# set special variable to pass extra information to command SWIG_ADD_SOURCE_TO_MODULE
# set special variable to pass extra information to command SWIG_ADD_SOURCE_TO_MODULE
# which cannot be changed due to legacy compatibility
# which cannot be changed due to legacy compatibility
set
(
SWIG_WORKING_DIR
"
${
workingdir
}
"
)
set
(
SWIG_WORKING_DIR
"
${
workingdir
}
"
)
set
(
SWIG_TARGET_NAME
"
${
target_name
}
"
)
set
(
outputdir
"
${
_SAM_OUTPUT_DIR
}
"
)
set
(
outputdir
"
${
_SAM_OUTPUT_DIR
}
"
)
if
(
NOT _SAM_OUTPUT_DIR
)
if
(
NOT _SAM_OUTPUT_DIR
)
...
@@ -535,9 +592,6 @@ function(SWIG_ADD_LIBRARY name)
...
@@ -535,9 +592,6 @@ function(SWIG_ADD_LIBRARY name)
set
(
CMAKE_SWIG_OUTDIR
"
${
outputdir
}
"
)
set
(
CMAKE_SWIG_OUTDIR
"
${
outputdir
}
"
)
set
(
SWIG_OUTFILE_DIR
"
${
outfiledir
}
"
)
set
(
SWIG_OUTFILE_DIR
"
${
outfiledir
}
"
)
set
(
SWIG_MODULE_
${
name
}
_NOPROXY
${
_SAM_NO_PROXY
}
)
swig_module_initialize
(
${
name
}
${
_SAM_LANGUAGE
}
)
set
(
swig_dot_i_sources
${
_SAM_SOURCES
}
)
set
(
swig_dot_i_sources
${
_SAM_SOURCES
}
)
list
(
FILTER swig_dot_i_sources INCLUDE REGEX
"
\\
.i$"
)
list
(
FILTER swig_dot_i_sources INCLUDE REGEX
"
\\
.i$"
)
if
(
NOT swig_dot_i_sources
)
if
(
NOT swig_dot_i_sources
)
...
@@ -563,24 +617,24 @@ function(SWIG_ADD_LIBRARY name)
...
@@ -563,24 +617,24 @@ function(SWIG_ADD_LIBRARY name)
set_property
(
DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
"
${
outputdir
}
"
)
set_property
(
DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
"
${
outputdir
}
"
)
endif
()
endif
()
add_library
(
${
name
}
add_library
(
${
target_
name
}
${
_SAM_TYPE
}
${
_SAM_TYPE
}
${
swig_generated_sources
}
${
swig_generated_sources
}
${
swig_other_sources
}
)
${
swig_other_sources
}
)
if
(
CMAKE_GENERATOR MATCHES
"Make"
)
if
(
CMAKE_GENERATOR MATCHES
"Make"
)
# see IMPLICIT_DEPENDS above
# see IMPLICIT_DEPENDS above
add_custom_target
(
${
name
}
_swig_compilation DEPENDS
${
swig_generated_timestamps
}
)
add_custom_target
(
${
name
}
_swig_compilation DEPENDS
${
swig_generated_timestamps
}
)
add_dependencies
(
${
name
}
${
name
}
_swig_compilation
)
add_dependencies
(
${
target_
name
}
${
name
}
_swig_compilation
)
endif
()
endif
()
if
(
_SAM_TYPE STREQUAL
"MODULE"
)
if
(
_SAM_TYPE STREQUAL
"MODULE"
)
set_target_properties
(
${
name
}
PROPERTIES NO_SONAME ON
)
set_target_properties
(
${
target_
name
}
PROPERTIES NO_SONAME ON
)
endif
()
endif
()
string
(
TOLOWER
"
${
_SAM_LANGUAGE
}
"
swig_lowercase_language
)
string
(
TOLOWER
"
${
_SAM_LANGUAGE
}
"
swig_lowercase_language
)
if
(
swig_lowercase_language STREQUAL
"octave"
)
if
(
swig_lowercase_language STREQUAL
"octave"
)
set_target_properties
(
${
name
}
PROPERTIES PREFIX
""
)
set_target_properties
(
${
target_
name
}
PROPERTIES PREFIX
""
)
set_target_properties
(
${
name
}
PROPERTIES SUFFIX
".oct"
)
set_target_properties
(
${
target_
name
}
PROPERTIES SUFFIX
".oct"
)
elseif
(
swig_lowercase_language STREQUAL
"go"
)
elseif
(
swig_lowercase_language STREQUAL
"go"
)
set_target_properties
(
${
name
}
PROPERTIES PREFIX
""
)
set_target_properties
(
${
target_
name
}
PROPERTIES PREFIX
""
)
elseif
(
swig_lowercase_language STREQUAL
"java"
)
elseif
(
swig_lowercase_language STREQUAL
"java"
)
# In java you want:
# In java you want:
# System.loadLibrary("LIBRARY");
# System.loadLibrary("LIBRARY");
...
@@ -589,23 +643,23 @@ function(SWIG_ADD_LIBRARY name)
...
@@ -589,23 +643,23 @@ function(SWIG_ADD_LIBRARY name)
# Windows: LIBRARY.dll
# Windows: LIBRARY.dll
# Linux : libLIBRARY.so
# Linux : libLIBRARY.so
if
(
APPLE
)
if
(
APPLE
)
set_target_properties
(
${
name
}
PROPERTIES SUFFIX
".jnilib"
)
set_target_properties
(
${
target_
name
}
PROPERTIES SUFFIX
".jnilib"
)
endif
()
endif
()
if
((
WIN32 AND MINGW
)
OR CYGWIN OR CMAKE_SYSTEM_NAME STREQUAL MSYS
)
if
((
WIN32 AND MINGW
)
OR CYGWIN OR CMAKE_SYSTEM_NAME STREQUAL MSYS
)
set_target_properties
(
${
name
}
PROPERTIES PREFIX
""
)
set_target_properties
(
${
target_
name
}
PROPERTIES PREFIX
""
)
endif
()
endif
()
elseif
(
swig_lowercase_language STREQUAL
"lua"
)
elseif
(
swig_lowercase_language STREQUAL
"lua"
)
if
(
_SAM_TYPE STREQUAL
"MODULE"
)
if
(
_SAM_TYPE STREQUAL
"MODULE"
)
set_target_properties
(
${
name
}
PROPERTIES PREFIX
""
)
set_target_properties
(
${
target_
name
}
PROPERTIES PREFIX
""
)
endif
()
endif
()
elseif
(
swig_lowercase_language STREQUAL
"python"
)
elseif
(
swig_lowercase_language STREQUAL
"python"
)
if
(
SWIG_MODULE_
${
name
}
_NOPROXY
)
if
(
UseSWIG_TARGET_NAME_PREFERENCE STREQUAL
"STANDARD"
AND NOT SWIG_MODULE_
${
name
}
_NOPROXY
)
set_target_properties
(
${
name
}
PROPERTIES PREFIX
""
)
else
()
# swig will produce a module.py containing an 'import _modulename' statement,
# swig will produce a module.py containing an 'import _modulename' statement,
# which implies having a corresponding _modulename.so (*NIX), _modulename.pyd (Win32),
# which implies having a corresponding _modulename.so (*NIX), _modulename.pyd (Win32),
# unless the -noproxy flag is used
# unless the -noproxy flag is used
set_target_properties
(
${
name
}
PROPERTIES PREFIX
"_"
)
set_target_properties
(
${
target_name
}
PROPERTIES PREFIX
"_"
)
else
()
set_target_properties
(
${
target_name
}
PROPERTIES PREFIX
""
)
endif
()
endif
()
# Python extension modules on Windows must have the extension ".pyd"
# Python extension modules on Windows must have the extension ".pyd"
# instead of ".dll" as of Python 2.5. Older python versions do support
# instead of ".dll" as of Python 2.5. Older python versions do support
...
@@ -616,10 +670,10 @@ function(SWIG_ADD_LIBRARY name)
...
@@ -616,10 +670,10 @@ function(SWIG_ADD_LIBRARY name)
# .pyd is now the only filename extension that will be searched for.
# .pyd is now the only filename extension that will be searched for.
# </quote>
# </quote>
if
(
WIN32 AND NOT CYGWIN
)
if
(
WIN32 AND NOT CYGWIN
)
set_target_properties
(
${
name
}
PROPERTIES SUFFIX
".pyd"
)
set_target_properties
(
${
target_
name
}
PROPERTIES SUFFIX
".pyd"
)
endif
()
endif
()
elseif
(
swig_lowercase_language STREQUAL
"r"
)
elseif
(
swig_lowercase_language STREQUAL
"r"
)
set_target_properties
(
${
name
}
PROPERTIES PREFIX
""
)
set_target_properties
(
${
target_
name
}
PROPERTIES PREFIX
""
)
elseif
(
swig_lowercase_language STREQUAL
"ruby"
)
elseif
(
swig_lowercase_language STREQUAL
"ruby"
)
# In ruby you want:
# In ruby you want:
# require 'LIBRARY'
# require 'LIBRARY'
...
@@ -627,23 +681,23 @@ function(SWIG_ADD_LIBRARY name)
...
@@ -627,23 +681,23 @@ function(SWIG_ADD_LIBRARY name)
# MacOS : LIBRARY.bundle
# MacOS : LIBRARY.bundle
# Windows: LIBRARY.dll
# Windows: LIBRARY.dll
# Linux : LIBRARY.so
# Linux : LIBRARY.so
set_target_properties
(
${
name
}
PROPERTIES PREFIX
""
)
set_target_properties
(
${
target_
name
}
PROPERTIES PREFIX
""
)
if
(
APPLE
)
if
(
APPLE
)
set_target_properties
(
${
name
}
PROPERTIES SUFFIX
".bundle"
)
set_target_properties
(
${
target_
name
}
PROPERTIES SUFFIX
".bundle"
)
endif
()
endif
()
elseif
(
swig_lowercase_language STREQUAL
"perl"
)
elseif
(
swig_lowercase_language STREQUAL
"perl"
)
# assume empty prefix because we expect the module to be dynamically loaded
# assume empty prefix because we expect the module to be dynamically loaded
set_target_properties
(
${
name
}
PROPERTIES PREFIX
""
)
set_target_properties
(
${
target_
name
}
PROPERTIES PREFIX
""
)
if
(
APPLE
)
if
(
APPLE
)
set_target_properties
(
${
name
}
PROPERTIES SUFFIX
".dylib"
)
set_target_properties
(
${
target_
name
}
PROPERTIES SUFFIX
".dylib"
)
endif
()
endif
()
else
()
else
()
# assume empty prefix because we expect the module to be dynamically loaded
# assume empty prefix because we expect the module to be dynamically loaded
set_target_properties
(
${
name
}
PROPERTIES PREFIX
""
)
set_target_properties
(
${
target_
name
}
PROPERTIES PREFIX
""
)
endif
()
endif
()
# target property SWIG_SUPPORT_FILES_DIRECTORY specify output directory of support files
# target property SWIG_SUPPORT_FILES_DIRECTORY specify output directory of support files
set_property
(
TARGET
${
name
}
PROPERTY SWIG_SUPPORT_FILES_DIRECTORY
"
${
outputdir
}
"
)
set_property
(
TARGET
${
target_
name
}
PROPERTY SWIG_SUPPORT_FILES_DIRECTORY
"
${
outputdir
}
"
)
# target property SWIG_SUPPORT_FILES lists principal proxy support files
# target property SWIG_SUPPORT_FILES lists principal proxy support files
if
(
NOT SWIG_MODULE_
${
name
}
_NOPROXY
)
if
(
NOT SWIG_MODULE_
${
name
}
_NOPROXY
)
string
(
TOUPPER
"
${
_SAM_LANGUAGE
}
"
swig_uppercase_language
)
string
(
TOUPPER
"
${
_SAM_LANGUAGE
}
"
swig_uppercase_language
)
...
@@ -656,13 +710,13 @@ function(SWIG_ADD_LIBRARY name)
...
@@ -656,13 +710,13 @@ function(SWIG_ADD_LIBRARY name)
if
(
swig_all_support_files
)
if
(
swig_all_support_files
)
list
(
REMOVE_DUPLICATES swig_all_support_files
)
list
(
REMOVE_DUPLICATES swig_all_support_files
)
endif
()
endif
()
set_property
(
TARGET
${
name
}
PROPERTY SWIG_SUPPORT_FILES
${
swig_all_support_files
}
)
set_property
(
TARGET
${
target_
name
}
PROPERTY SWIG_SUPPORT_FILES
${
swig_all_support_files
}
)
endif
()
endif
()
# to ensure legacy behavior, export some variables
# to ensure legacy behavior, export some variables
set
(
SWIG_MODULE_
${
name
}
_LANGUAGE
"
${
SWIG_MODULE_
${
name
}
_LANGUAGE
}
"
PARENT_SCOPE
)
set
(
SWIG_MODULE_
${
name
}
_LANGUAGE
"
${
SWIG_MODULE_
${
name
}
_LANGUAGE
}
"
PARENT_SCOPE
)
set
(
SWIG_MODULE_
${
name
}
_SWIG_LANGUAGE_FLAG
"
${
SWIG_MODULE_
${
name
}
_SWIG_LANGUAGE_FLAG
}
"
PARENT_SCOPE
)
set
(
SWIG_MODULE_
${
name
}
_SWIG_LANGUAGE_FLAG
"
${
SWIG_MODULE_
${
name
}
_SWIG_LANGUAGE_FLAG
}
"
PARENT_SCOPE
)
set
(
SWIG_MODULE_
${
name
}
_REAL_NAME
"
${
name
}
"
PARENT_SCOPE
)
set
(
SWIG_MODULE_
${
name
}
_REAL_NAME
"
${
target_
name
}
"
PARENT_SCOPE
)
set
(
SWIG_MODULE_
${
name
}
_NOPROXY
"
${
SWIG_MODULE_
${
name
}
_NOPROXY
}
"
PARENT_SCOPE
)
set
(
SWIG_MODULE_
${
name
}
_NOPROXY
"
${
SWIG_MODULE_
${
name
}
_NOPROXY
}
"
PARENT_SCOPE
)
set
(
SWIG_MODULE_
${
name
}
_EXTRA_FLAGS
"
${
SWIG_MODULE_
${
name
}
_EXTRA_FLAGS
}
"
PARENT_SCOPE
)
set
(
SWIG_MODULE_
${
name
}
_EXTRA_FLAGS
"
${
SWIG_MODULE_
${
name
}
_EXTRA_FLAGS
}
"
PARENT_SCOPE
)
# the last one is a bit crazy but it is documented, so...
# the last one is a bit crazy but it is documented, so...
...
@@ -674,10 +728,14 @@ endfunction()
...
@@ -674,10 +728,14 @@ endfunction()
# Like TARGET_LINK_LIBRARIES but for swig modules
# Like TARGET_LINK_LIBRARIES but for swig modules
#
#
function
(
SWIG_LINK_LIBRARIES name
)
function
(
SWIG_LINK_LIBRARIES name
)
message
(
DEPRECATION
"SWIG_LINK_LIBRARIES is deprecated. Use TARGET_LINK_LIBRARIES instead.
"
)
if
(
UseSWIG_TARGET_NAME_PREFERENCE STREQUAL
"STANDARD
"
)
if
(
SWIG_MODULE_
${
name
}
_REAL_NAME
)
message
(
DEPRECATION
"SWIG_LINK_LIBRARIES is deprecated. Use TARGET_LINK_LIBRARIES instead."
)
target_link_libraries
(
${
name
}
${
ARGN
}
)
target_link_libraries
(
${
name
}
${
ARGN
}
)
else
()
else
()
message
(
SEND_ERROR
"Cannot find Swig library
\"
${
name
}
\"
."
)
if
(
SWIG_MODULE_
${
name
}
_REAL_NAME
)
target_link_libraries
(
${
SWIG_MODULE_
${
name
}
_REAL_NAME
}
${
ARGN
}
)
else
()
message
(
SEND_ERROR
"Cannot find Swig library
\"
${
name
}
\"
."
)
endif
()
endif
()
endif
()
endfunction
()
endfunction
()
Tests/UseSWIG/BasicConfiguration.cmake
View file @
38ffcedd
...
@@ -58,6 +58,7 @@ if(${language} MATCHES lua)
...
@@ -58,6 +58,7 @@ if(${language} MATCHES lua)
set
(
SWIG_LANG_LIBRARIES
${
LUA_LIBRARIES
}
)
set
(
SWIG_LANG_LIBRARIES
${
LUA_LIBRARIES
}
)
endif
()
endif
()
set
(
UseSWIG_TARGET_NAME_PREFERENCE STANDARD
)
unset
(
CMAKE_SWIG_FLAGS
)
unset
(
CMAKE_SWIG_FLAGS
)
set
(
CMAKE_INCLUDE_CURRENT_DIR ON
)
set
(
CMAKE_INCLUDE_CURRENT_DIR ON
)
...
...
Tests/UseSWIG/ModuleVersion2/CMakeLists.txt
View file @
38ffcedd
...
@@ -16,6 +16,7 @@ else()
...
@@ -16,6 +16,7 @@ else()
set
(
PS
":"
)
set
(
PS
":"
)
endif
()
endif
()
set
(
UseSWIG_TARGET_NAME_PREFERENCE STANDARD
)
set
(
UseSWIG_MODULE_VERSION 2
)
set
(
UseSWIG_MODULE_VERSION 2
)
unset
(
CMAKE_SWIG_FLAGS
)
unset
(
CMAKE_SWIG_FLAGS
)
...
...
Tests/UseSWIG/MultipleModules/CMakeLists.txt
View file @
38ffcedd
...
@@ -19,6 +19,7 @@ else()
...
@@ -19,6 +19,7 @@ else()
set
(
PS
":"
)
set
(
PS
":"
)
endif
()
endif
()
set
(
UseSWIG_TARGET_NAME_PREFERENCE STANDARD
)
unset
(
CMAKE_SWIG_FLAGS
)
unset
(
CMAKE_SWIG_FLAGS
)
set_property
(
SOURCE
"../example.i"
PROPERTY CPLUSPLUS ON
)
set_property
(
SOURCE
"../example.i"
PROPERTY CPLUSPLUS ON
)
...
...
Tests/UseSWIG/MultiplePython/CMakeLists.txt
View file @
38ffcedd
...
@@ -17,6 +17,7 @@ else()
...
@@ -17,6 +17,7 @@ else()
set
(
PS
":"
)
set
(
PS
":"
)
endif
()
endif
()
set
(
UseSWIG_TARGET_NAME_PREFERENCE STANDARD
)
unset
(
CMAKE_SWIG_FLAGS
)
unset
(
CMAKE_SWIG_FLAGS
)
set_property
(
SOURCE
"../example.i"
PROPERTY CPLUSPLUS ON
)
set_property
(
SOURCE
"../example.i"
PROPERTY CPLUSPLUS ON
)
...
...
Brad King
@brad.king
mentioned in commit
7f965277
·
Jul 05, 2018
mentioned in commit
7f965277
mentioned in commit 7f9652773a386ea6bf7eec66f2c58174ebe1b5d4
Toggle commit list
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