diff options
author | Brad King <brad.king@kitware.com> | 2020-07-10 10:43:58 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-07-10 10:45:09 (GMT) |
commit | a5064f6e656f3c83c5aa78af67740365f08236fb (patch) | |
tree | 4c10ffe5c3743b8576218f82c1efd2e1a312ca96 /Tests | |
parent | bf3a1e9a9b51cd6116d416148abfec2765cdef10 (diff) | |
parent | 961ee62faaf63cbd72724a4e9c039352ed44dad4 (diff) | |
download | CMake-a5064f6e656f3c83c5aa78af67740365f08236fb.zip CMake-a5064f6e656f3c83c5aa78af67740365f08236fb.tar.gz CMake-a5064f6e656f3c83c5aa78af67740365f08236fb.tar.bz2 |
Merge topic 'source_file_both_props'
961ee62faa Help: Update get_property and get_source_file_property docs
1235f2d747 set_property: Allow both DIRECTORY and TARGET_DIRECTORY together
177052d6b8 set_property: Fix name of TARGET_DIRECTORY option in error messages
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4994
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/Properties/CMakeLists.txt | 24 | ||||
-rw-r--r-- | Tests/Properties/SubDir2/CMakeLists.txt | 4 | ||||
-rw-r--r-- | Tests/RunCMake/get_property/source_properties_failures-stderr.txt | 6 | ||||
-rw-r--r-- | Tests/RunCMake/set_property/SOURCE_FILE-stderr.txt | 2 |
4 files changed, 30 insertions, 6 deletions
diff --git a/Tests/Properties/CMakeLists.txt b/Tests/Properties/CMakeLists.txt index f93f553..74d99fa 100644 --- a/Tests/Properties/CMakeLists.txt +++ b/Tests/Properties/CMakeLists.txt @@ -146,18 +146,25 @@ check_cache_props() function(generate_file_for_set_property_test i target_name) set(src_path "${CMAKE_CURRENT_BINARY_DIR}/src${i}.cpp") - file(GENERATE OUTPUT "${src_path}" CONTENT + file(CONFIGURE OUTPUT "${src_path}" CONTENT "#ifndef def${i}\n\ #error Expected def${i}\n\ #endif\n\ #ifdef _WIN32\n\ __declspec(dllexport)\n\ #endif\n\ - void dummy_symbol${i}() {}\n") + void dummy_symbol${i}() {}\n" + NEWLINE_STYLE UNIX) target_sources(${target_name} PRIVATE "${src_path}") endfunction() add_library(maindirtest SHARED) + +# Generate file to be used with both DIRECTORY and TARGET_DIRECTORY options in +# set_source_files_properties and set_property(). +generate_file_for_set_property_test(32 maindirtest) +generate_file_for_set_property_test(33 maindirtest) + add_subdirectory(SubDir2) set(src_prefix "${CMAKE_CURRENT_BINARY_DIR}/SubDir2/") @@ -233,6 +240,19 @@ set_source_files_properties("${CMAKE_CURRENT_BINARY_DIR}/src30.cpp" set_source_files_properties("${CMAKE_CURRENT_BINARY_DIR}/src30.cpp" "${CMAKE_CURRENT_BINARY_DIR}/SubDir2/src31.cpp") + +# Check that specifying both DIRECTORY and TARGET_DIRECTORY works. +set_source_files_properties("${CMAKE_CURRENT_BINARY_DIR}/src32.cpp" + DIRECTORY . + TARGET_DIRECTORY set_prop_lib_3 + PROPERTIES COMPILE_DEFINITIONS "def32") + +set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/src33.cpp" + DIRECTORY SubDir2 + TARGET_DIRECTORY maindirtest + PROPERTY COMPILE_DEFINITIONS "def33") + + function(check_get_property_value expected) if(NOT actual STREQUAL expected) message(SEND_ERROR "Error: get_property returned unexpected value\n" diff --git a/Tests/Properties/SubDir2/CMakeLists.txt b/Tests/Properties/SubDir2/CMakeLists.txt index 9b2c79e..88e5531 100644 --- a/Tests/Properties/SubDir2/CMakeLists.txt +++ b/Tests/Properties/SubDir2/CMakeLists.txt @@ -28,3 +28,7 @@ generate_file_for_set_property_test(23 set_prop_lib_3) # For set_source_files_properties + multiple files in multiple directories generate_file_for_set_property_test(31 set_prop_lib_3) + +# For specifying both DIRECTORY and TARGET_DIRECTORY +target_sources(set_prop_lib_3 PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/../src32.cpp") +target_sources(set_prop_lib_3 PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/../src33.cpp") diff --git a/Tests/RunCMake/get_property/source_properties_failures-stderr.txt b/Tests/RunCMake/get_property/source_properties_failures-stderr.txt index a500e2e..0accb8f 100644 --- a/Tests/RunCMake/get_property/source_properties_failures-stderr.txt +++ b/Tests/RunCMake/get_property/source_properties_failures-stderr.txt @@ -16,7 +16,7 @@ Call Stack \(most recent call first\): CMakeLists\.txt:[0-9]+ \(include\) + CMake Error at source_properties_failures.cmake:4 \(set_source_files_properties\): - set_source_files_properties given non-existent target for DIRECTORY_TARGET + set_source_files_properties given non-existent target for TARGET_DIRECTORY non_existing_target Call Stack \(most recent call first\): CMakeLists\.txt:[0-9]+ \(include\) @@ -39,7 +39,7 @@ Call Stack \(most recent call first\): CMakeLists\.txt:[0-9]+ \(include\) + CMake Error at source_properties_failures.cmake:9 \(get_property\): - get_property given non-existent target for DIRECTORY_TARGET + get_property given non-existent target for TARGET_DIRECTORY non_existing_dir Call Stack \(most recent call first\): CMakeLists\.txt:[0-9]+ \(include\) @@ -55,7 +55,7 @@ Call Stack \(most recent call first\): CMakeLists\.txt:[0-9]+ \(include\) + CMake Error at source_properties_failures.cmake:13 \(get_source_file_property\): - get_source_file_property given non-existent target for DIRECTORY_TARGET + get_source_file_property given non-existent target for TARGET_DIRECTORY PROPERTY Call Stack \(most recent call first\): CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/set_property/SOURCE_FILE-stderr.txt b/Tests/RunCMake/set_property/SOURCE_FILE-stderr.txt index 2e0b238..a2b6cf4 100644 --- a/Tests/RunCMake/set_property/SOURCE_FILE-stderr.txt +++ b/Tests/RunCMake/set_property/SOURCE_FILE-stderr.txt @@ -16,7 +16,7 @@ Call Stack \(most recent call first\): CMakeLists\.txt:[0-9]+ \(include\) + CMake Error at SOURCE_FILE.cmake:4 \(set_property\): - set_property given non-existent target for DIRECTORY_TARGET + set_property given non-existent target for TARGET_DIRECTORY non_existing_target Call Stack \(most recent call first\): CMakeLists\.txt:[0-9]+ \(include\)$ |