diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2020-09-30 16:47:42 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2020-09-30 17:19:14 (GMT) |
commit | 4a81a0ce3d6cfc923f399b9933ca2ec87a31be5e (patch) | |
tree | db74fbe974420a8099db04dcc4bf12117bf57c60 /Tests/UseSWIG/SwigSrcOUTPUT_DIR/CMakeLists.txt | |
parent | d91c3e33cbf9592f90f65bd7d990a8b54ad140d1 (diff) | |
download | CMake-4a81a0ce3d6cfc923f399b9933ca2ec87a31be5e.zip CMake-4a81a0ce3d6cfc923f399b9933ca2ec87a31be5e.tar.gz CMake-4a81a0ce3d6cfc923f399b9933ca2ec87a31be5e.tar.bz2 |
UseSWIG: Add OUTPUT_DIR and OUTFILE_DIR source file properties
These properties enable to manage output directories on
per source file basis.
Fixes: #21250
Diffstat (limited to 'Tests/UseSWIG/SwigSrcOUTPUT_DIR/CMakeLists.txt')
-rw-r--r-- | Tests/UseSWIG/SwigSrcOUTPUT_DIR/CMakeLists.txt | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/Tests/UseSWIG/SwigSrcOUTPUT_DIR/CMakeLists.txt b/Tests/UseSWIG/SwigSrcOUTPUT_DIR/CMakeLists.txt new file mode 100644 index 0000000..fc0cf8d --- /dev/null +++ b/Tests/UseSWIG/SwigSrcOUTPUT_DIR/CMakeLists.txt @@ -0,0 +1,61 @@ +cmake_minimum_required(VERSION 3.12...3.19) + +project(TestSwigSrcOUTPUT_DIR CXX) + +include(CTest) + + +set(CMAKE_CXX_STANDARD 11) + + +find_package(SWIG REQUIRED) +include(${SWIG_USE_FILE}) + +set(UseSWIG_MODULE_VERSION 2) + + +file(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/Foo" + "${CMAKE_CURRENT_BINARY_DIR}/FooSupport" + "${CMAKE_CURRENT_BINARY_DIR}/FooFile" + "${CMAKE_CURRENT_BINARY_DIR}/Bar" + "${CMAKE_CURRENT_BINARY_DIR}/BarSupport" + "${CMAKE_CURRENT_BINARY_DIR}/BarFile") + + +set_property (SOURCE foo.i PROPERTY COMPILE_OPTIONS -namespace Foo) +set_property (SOURCE foo.i PROPERTY OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/Foo") +set_property (SOURCE foo.i PROPERTY CPLUSPLUS ON) + +set_property (SOURCE bar.i PROPERTY COMPILE_OPTIONS -namespace Bar) +set_property (SOURCE bar.i PROPERTY OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/Bar") +set_property (SOURCE bar.i PROPERTY CPLUSPLUS ON) + +swig_add_library(outdir_test LANGUAGE csharp SOURCES foo.i bar.i cs.cpp + OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/NotUsed1" + OUTFILE_DIR "${CMAKE_CURRENT_BINARY_DIR}/NotUsed2") +target_include_directories(outdir_test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") +set_property(TARGET outdir_test PROPERTY USE_TARGET_INCLUDE_DIRECTORIES ON) + + +get_target_property(SUPPORT_FILES_DIRS outdir_test SWIG_SUPPORT_FILES_DIRECTORY) + +add_test(NAME SwigSrcOUTPUT_DIR COMMAND "${CMAKE_COMMAND}" "-DBASE_DIRECTORY=${CMAKE_CURRENT_BINARY_DIR}" "-DSUPPORT_FILES_DIRECTORY=${SUPPORT_FILES_DIRS}" -P "${CMAKE_CURRENT_SOURCE_DIR}/ValidateSupportFiles.cmake") + + + +set_property (SOURCE foo.i PROPERTY OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/FooSupport") +set_property (SOURCE foo.i PROPERTY OUTFILE_DIR "${CMAKE_CURRENT_BINARY_DIR}/FooFile") + +set_property (SOURCE bar.i PROPERTY OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/BarSupport") +set_property (SOURCE bar.i PROPERTY OUTFILE_DIR "${CMAKE_CURRENT_BINARY_DIR}/BarFile") + +swig_add_library(outfiledir_test LANGUAGE csharp SOURCES foo.i bar.i cs.cpp + OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/NotUsed1" + OUTFILE_DIR "${CMAKE_CURRENT_BINARY_DIR}/NotUsed2") +target_include_directories(outfiledir_test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") +set_property(TARGET outfiledir_test PROPERTY USE_TARGET_INCLUDE_DIRECTORIES ON) + + +get_target_property(SUPPORT_FILES_DIRS outfiledir_test SWIG_SUPPORT_FILES_DIRECTORY) + +add_test(NAME SwigSrcOUTFILE_DIR COMMAND "${CMAKE_COMMAND}" "-DBASE_DIRECTORY=${CMAKE_CURRENT_BINARY_DIR}" "-DSUPPORT_FILES_DIRECTORY=${SUPPORT_FILES_DIRS}" -DOUTFILE_DIR=ON -P "${CMAKE_CURRENT_SOURCE_DIR}/ValidateSupportFiles.cmake") |