summaryrefslogtreecommitdiffstats
path: root/Modules/UseSWIG.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/UseSWIG.cmake')
-rw-r--r--Modules/UseSWIG.cmake24
1 files changed, 23 insertions, 1 deletions
diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake
index b306181..7460932 100644
--- a/Modules/UseSWIG.cmake
+++ b/Modules/UseSWIG.cmake
@@ -117,6 +117,13 @@ ensure generated files will receive the required settings.
:prop_sf:`INCLUDE_DIRECTORIES`, :prop_sf:`COMPILE_DEFINITIONS` and
:prop_sf:`COMPILE_OPTIONS`.
+``USE_TARGET_INCLUDE_DIRECTORIES``
+ If set to ``TRUE``, contents of target property
+ :prop_tgt:`INCLUDE_DIRECTORIES` will be forwarded to ``SWIG`` compiler.
+ If set to ``FALSE`` target property :prop_tgt:`INCLUDE_DIRECTORIES` will be
+ ignored. If not set, target property ``SWIG_USE_TARGT_INCLUDE_DIRECTORIES``
+ will be considered.
+
``GENERATED_INCLUDE_DIRECTORIES``, ``GENERATED_COMPILE_DEFINITIONS`` and ``GENERATED_COMPILE_OPTIONS``
Add custom flags to the C/C++ generated source. They will fill, respectively,
properties :prop_sf:`INCLUDE_DIRECTORIES`, :prop_sf:`COMPILE_DEFINITIONS` and
@@ -149,6 +156,13 @@ input files.
set_property(TARGET mymod PROPERTY SWIG_COMPILE_DEFINITIONS MY_DEF1 MY_DEF2)
set_property(TARGET mymod PROPERTY SWIG_COMPILE_OPTIONS -bla -blb)
+``SWIG_USE_TARGET_INCLUDE_DIRECTORIES``
+ If set to ``TRUE``, contents of target property
+ :prop_tgt:`INCLUDE_DIRECTORIES` will be forwarded to ``SWIG`` compiler.
+ If set to ``FALSE`` or not defined, target property
+ :prop_tgt:`INCLUDE_DIRECTORIES` will be ignored. This behavior can be
+ overridden by specifying source property ``USE_TARGET_INCLUDE_DIRECTORIES``.
+
``SWIG_GENERATED_INCLUDE_DIRECTORIES``, ``SWIG_GENERATED_COMPILE_DEFINITIONS`` and ``SWIG_GENERATED_COMPILE_OPTIONS``
These properties will populate, respectively, properties
:prop_sf:`INCLUDE_DIRECTORIES`, :prop_sf:`COMPILE_DEFINITIONS` and
@@ -294,7 +308,7 @@ function(SWIG_GET_EXTRA_OUTPUT_FILES language outfiles generatedpath infile)
endif()
foreach(it ${SWIG_${language}_EXTRA_FILE_EXTENSIONS})
set(extra_file "${generatedpath}/${module_basename}${it}")
- if (extra_file MATCHES "\\.cs$")
+ if (extra_file MATCHES "\\.cs$" AND CMAKE_CSharp_COMPILER_LOADED)
set_source_files_properties(${extra_file} PROPERTIES LANGUAGE "CSharp")
else()
# Treat extra outputs as plain files regardless of language.
@@ -346,6 +360,14 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile)
endif()
set (property "$<TARGET_PROPERTY:${target_name},SWIG_INCLUDE_DIRECTORIES>")
list (APPEND swig_source_file_flags "$<$<BOOL:${property}>:-I$<JOIN:$<TARGET_GENEX_EVAL:${target_name},${property}>,$<SEMICOLON>-I>>")
+ set (property "$<TARGET_PROPERTY:${target_name},INCLUDE_DIRECTORIES>")
+ get_source_file_property(use_target_include_dirs "${infile}" USE_TARGET_INCLUDE_DIRECTORIES)
+ if (use_target_include_dirs)
+ list (APPEND swig_source_file_flags "$<$<BOOL:${property}>:-I$<JOIN:${property},$<SEMICOLON>-I>>")
+ elseif(use_target_include_dirs STREQUAL "NOTFOUND")
+ # not defined at source level, rely on target level
+ list (APPEND swig_source_file_flags "$<$<AND:$<BOOL:$<TARGET_PROPERTY:${target_name},SWIG_USE_TARGET_INCLUDE_DIRECTORIES>>,$<BOOL:${property}>>:-I$<JOIN:${property},$<SEMICOLON>-I>>")
+ endif()
set (property "$<TARGET_PROPERTY:${target_name},SWIG_COMPILE_DEFINITIONS>")
list (APPEND swig_source_file_flags "$<$<BOOL:${property}>:-D$<JOIN:$<TARGET_GENEX_EVAL:${target_name},${property}>,$<SEMICOLON>-D>>")