diff options
author | Robert Langlois <ezralanglois@gmail.com> | 2017-06-12 20:18:27 (GMT) |
---|---|---|
committer | Mona Lisa <rlanglois@illumina.com> | 2017-06-14 01:07:32 (GMT) |
commit | 76a0286b1d53ba35d6fa7cee152259bc040d80fb (patch) | |
tree | d0fb2ac70ee69bc042a1f1d21f9c57db7ac73b3c /Modules/UseSWIG.cmake | |
parent | ee47d80c3b476a56d876888f74387e583c69f79d (diff) | |
download | CMake-76a0286b1d53ba35d6fa7cee152259bc040d80fb.zip CMake-76a0286b1d53ba35d6fa7cee152259bc040d80fb.tar.gz CMake-76a0286b1d53ba35d6fa7cee152259bc040d80fb.tar.bz2 |
UseSWIG: Add `-dllimport` only if not already specified
SWIG fails with a redefined macro error when `-dllimport` is specified
more than once. One case where you would want to specify your own
dllimport is when using SWIG with netstandard2.0. .NET Core does not
search for shared library like Mono or .NET, so you need a fully
qualified shared library name.
Diffstat (limited to 'Modules/UseSWIG.cmake')
-rw-r--r-- | Modules/UseSWIG.cmake | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index bfe1a6f..456a6bd 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -82,10 +82,6 @@ macro(SWIG_MODULE_INITIALIZE name language) set(SWIG_MODULE_${name}_REAL_NAME "_${name}") elseif("x${SWIG_MODULE_${name}_LANGUAGE}" STREQUAL "xPERL") set(SWIG_MODULE_${name}_EXTRA_FLAGS "-shadow") - elseif("x${SWIG_MODULE_${name}_LANGUAGE}" STREQUAL "xCSHARP") - # This makes sure that the name used in the generated DllImport - # matches the library name created by CMake - set(SWIG_MODULE_${name}_EXTRA_FLAGS "-dllimport;${name}") endif() endmacro() @@ -192,6 +188,13 @@ macro(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) if(swig_source_file_cplusplus) set(swig_special_flags ${swig_special_flags} "-c++") endif() + if("x${SWIG_MODULE_${name}_LANGUAGE}" STREQUAL "xCSHARP") + if(NOT ";${swig_source_file_flags};${CMAKE_SWIG_FLAGS};" MATCHES ";-dllimport;") + # This makes sure that the name used in the generated DllImport + # matches the library name created by CMake + set(SWIG_MODULE_${name}_EXTRA_FLAGS "-dllimport;${name}") + endif() + endif() set(swig_extra_flags) if(SWIG_MODULE_${name}_EXTRA_FLAGS) set(swig_extra_flags ${swig_extra_flags} ${SWIG_MODULE_${name}_EXTRA_FLAGS}) |