summaryrefslogtreecommitdiffstats
path: root/Tests/Properties/CMakeLists.txt
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-07-08 20:12:02 (GMT)
committerBrad King <brad.king@kitware.com>2020-07-09 10:33:52 (GMT)
commit1235f2d747770535a388cd763c95cde8c9244375 (patch)
tree5fe38c96951731f04e7904fa9fc5316d9e386207 /Tests/Properties/CMakeLists.txt
parent177052d6b8b4127a9d345830fb3d82384e9d5b50 (diff)
downloadCMake-1235f2d747770535a388cd763c95cde8c9244375.zip
CMake-1235f2d747770535a388cd763c95cde8c9244375.tar.gz
CMake-1235f2d747770535a388cd763c95cde8c9244375.tar.bz2
set_property: Allow both DIRECTORY and TARGET_DIRECTORY together
Allow to specify both DIRECTORY and TARGET_DIRECTORY at the same time in `set_source_files_properties()` and `set_property(SOURCE)` commands. Add test cases and update the documentation. Fixes: #20932
Diffstat (limited to 'Tests/Properties/CMakeLists.txt')
-rw-r--r--Tests/Properties/CMakeLists.txt24
1 files changed, 22 insertions, 2 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"