diff options
Diffstat (limited to 'Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES')
-rw-r--r-- | Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/CMakeLists.txt | 46 | ||||
-rw-r--r-- | Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/example.i | 9 |
2 files changed, 55 insertions, 0 deletions
diff --git a/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/CMakeLists.txt b/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/CMakeLists.txt new file mode 100644 index 0000000..d0855bf --- /dev/null +++ b/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/CMakeLists.txt @@ -0,0 +1,46 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestUseTargetINCLUDE_DIRECTORIES CXX) + +include(CTest) + +find_package(SWIG REQUIRED) +include(${SWIG_USE_FILE}) + +find_package(Python3 REQUIRED COMPONENTS Interpreter Development) + +set(UseSWIG_TARGET_NAME_PREFERENCE STANDARD) +unset(CMAKE_SWIG_FLAGS) + +set_property(SOURCE "example.i" PROPERTY CPLUSPLUS ON) +set_property(SOURCE "example.i" PROPERTY COMPILE_OPTIONS -includeall) + +swig_add_library(example1 + LANGUAGE python + OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/example1" + SOURCES example.i ../example.cxx) +set_target_properties (example1 PROPERTIES + INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/.." + SWIG_USE_TARGET_INCLUDE_DIRECTORIES TRUE + OUTPUT_NAME example1 + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example1" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example1" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example1") +target_link_libraries(example1 PRIVATE Python3::Python) + + +# Check that source property override target property +set_property(SOURCE "example.i" PROPERTY USE_TARGET_INCLUDE_DIRECTORIES TRUE) + +swig_add_library(example2 + LANGUAGE python + OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/example2" + SOURCES example.i ../example.cxx) +set_target_properties (example2 PROPERTIES + INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/.." + SWIG_USE_TARGET_INCLUDE_DIRECTORIES FALSE + OUTPUT_NAME example2 + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example2" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example2" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example2") +target_link_libraries(example2 PRIVATE Python3::Python) diff --git a/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/example.i b/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/example.i new file mode 100644 index 0000000..fbdf724 --- /dev/null +++ b/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/example.i @@ -0,0 +1,9 @@ +/* File : example.i */ +%module example + +%{ +#include "example.h" +%} + +/* Let's just grab the original header file here */ +%include "example.h" |