diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2022-01-13 20:59:48 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2022-01-20 14:05:35 (GMT) |
commit | fce24e4f102686c5c103db301bb698e0ea82765f (patch) | |
tree | e5effdc88ea773c899b08b084aaf89dc936885dc /Tests/RunCMake/define_property | |
parent | 1ca83ae2bbf9e474c46b6ea094c5035420bbfd45 (diff) | |
download | CMake-fce24e4f102686c5c103db301bb698e0ea82765f.zip CMake-fce24e4f102686c5c103db301bb698e0ea82765f.tar.gz CMake-fce24e4f102686c5c103db301bb698e0ea82765f.tar.bz2 |
define_property(): Add INITIALIZE_FROM_VARIABLE argument
Fixes: #20698
Diffstat (limited to 'Tests/RunCMake/define_property')
19 files changed, 93 insertions, 0 deletions
diff --git a/Tests/RunCMake/define_property/RunCMakeTest.cmake b/Tests/RunCMake/define_property/RunCMakeTest.cmake index 5cb581b..7d7c75b 100644 --- a/Tests/RunCMake/define_property/RunCMakeTest.cmake +++ b/Tests/RunCMake/define_property/RunCMakeTest.cmake @@ -1,3 +1,9 @@ include(RunCMake) run_cmake(define_property) +run_cmake(define_property-INITIALIZE_FROM_VARIABLE) +run_cmake(define_property-INITIALIZE_FROM_VARIABLE-invalid_1) +run_cmake(define_property-INITIALIZE_FROM_VARIABLE-invalid_2) +run_cmake(define_property-INITIALIZE_FROM_VARIABLE-non_target) +run_cmake(define_property-INITIALIZE_FROM_VARIABLE-wrong_suffix) +run_cmake(define_property-INITIALIZE_FROM_VARIABLE-no_prefix) diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_1-result.txt b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_1-result.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_1-result.txt @@ -0,0 +1 @@ + diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_1-stderr.txt b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_1-stderr.txt new file mode 100644 index 0000000..a7903c9 --- /dev/null +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_1-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at define_property-INITIALIZE_FROM_VARIABLE-invalid_1\.cmake:[0-9]+ \(define_property\): + define_property variable name "CMAKE_PROP1" is reserved +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_1.cmake b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_1.cmake new file mode 100644 index 0000000..873263a --- /dev/null +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_1.cmake @@ -0,0 +1,3 @@ +define_property(TARGET PROPERTY PROP1 + INITIALIZE_FROM_VARIABLE CMAKE_PROP1 + ) diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_2-result.txt b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_2-result.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_2-result.txt @@ -0,0 +1 @@ + diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_2-stderr.txt b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_2-stderr.txt new file mode 100644 index 0000000..ea6bc86 --- /dev/null +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_2-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at define_property-INITIALIZE_FROM_VARIABLE-invalid_2\.cmake:[0-9]+ \(define_property\): + define_property variable name "_CMAKE_PROP1" is reserved +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_2.cmake b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_2.cmake new file mode 100644 index 0000000..95945a3 --- /dev/null +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_2.cmake @@ -0,0 +1,3 @@ +define_property(TARGET PROPERTY PROP1 + INITIALIZE_FROM_VARIABLE _CMAKE_PROP1 + ) diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_prefix-result.txt b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_prefix-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_prefix-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_prefix-stderr.txt b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_prefix-stderr.txt new file mode 100644 index 0000000..fc9099c --- /dev/null +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_prefix-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at define_property-INITIALIZE_FROM_VARIABLE-no_prefix\.cmake:[0-9]+ \(define_property\): + define_property Variable name must have a non-empty prefix before property + name "PROP1" +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_prefix.cmake b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_prefix.cmake new file mode 100644 index 0000000..cc39b57 --- /dev/null +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_prefix.cmake @@ -0,0 +1,3 @@ +define_property(TARGET PROPERTY PROP1 + INITIALIZE_FROM_VARIABLE PROP1 + ) diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-non_target-result.txt b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-non_target-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-non_target-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-non_target-stderr.txt b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-non_target-stderr.txt new file mode 100644 index 0000000..8159696 --- /dev/null +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-non_target-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at define_property-INITIALIZE_FROM_VARIABLE-non_target\.cmake:[0-9]+ \(define_property\): + define_property Scope must be TARGET if INITIALIZE_FROM_VARIABLE is + specified +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-non_target.cmake b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-non_target.cmake new file mode 100644 index 0000000..270e3b8 --- /dev/null +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-non_target.cmake @@ -0,0 +1,3 @@ +define_property(GLOBAL PROPERTY PROP1 + INITIALIZE_FROM_VARIABLE Test_PROP1 + ) diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-subdirectory/CMakeLists.txt b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-subdirectory/CMakeLists.txt new file mode 100644 index 0000000..67c186d --- /dev/null +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-subdirectory/CMakeLists.txt @@ -0,0 +1,11 @@ +define_property(TARGET PROPERTY PROP2 + INITIALIZE_FROM_VARIABLE Test_PROP2 + ) +define_property(TARGET PROPERTY PROP3 + INITIALIZE_FROM_VARIABLE Test_PROP3 + ) + +add_executable(sub_exe ../main.c) +assert_prop_eq(sub_exe PROP1 "Hello") +assert_prop_eq(sub_exe PROP2 "world") +assert_prop_eq(sub_exe PROP3 "!") diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-wrong_suffix-result.txt b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-wrong_suffix-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-wrong_suffix-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-wrong_suffix-stderr.txt b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-wrong_suffix-stderr.txt new file mode 100644 index 0000000..48c7e90 --- /dev/null +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-wrong_suffix-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at define_property-INITIALIZE_FROM_VARIABLE-wrong_suffix\.cmake:[0-9]+ \(define_property\): + define_property Variable name "Test_PROP2" does not end with property name + "PROP1" +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-wrong_suffix.cmake b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-wrong_suffix.cmake new file mode 100644 index 0000000..7566861 --- /dev/null +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-wrong_suffix.cmake @@ -0,0 +1,3 @@ +define_property(TARGET PROPERTY PROP1 + INITIALIZE_FROM_VARIABLE Test_PROP2 + ) diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE.cmake b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE.cmake new file mode 100644 index 0000000..d866fc9 --- /dev/null +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE.cmake @@ -0,0 +1,29 @@ +enable_language(C) + +function(assert_prop_eq tgt name value) + get_property(actual_value TARGET ${tgt} PROPERTY ${name}) + if(NOT actual_value STREQUAL value) + message(SEND_ERROR "Expected value of ${name}:\n ${value}\nActual value:\n ${actual_value}") + endif() +endfunction() + +function(assert_prop_undef tgt name) + get_property(actual_value TARGET ${tgt} PROPERTY ${name}) + if(DEFINED actual_value) + message(SEND_ERROR "Expected ${name} to be undefined, actual value:\n ${actual_value}") + endif() +endfunction() + +set(Test_PROP1 "Hello") +set(Test_PROP2 "world") +set(Test_PROP3 "!") +define_property(TARGET PROPERTY PROP1 + INITIALIZE_FROM_VARIABLE Test_PROP1 + ) + +add_subdirectory(define_property-INITIALIZE_FROM_VARIABLE-subdirectory) + +add_executable(top_exe main.c) +assert_prop_eq(top_exe PROP1 "Hello") +assert_prop_eq(top_exe PROP2 "world") +assert_prop_eq(top_exe PROP3 "!") diff --git a/Tests/RunCMake/define_property/main.c b/Tests/RunCMake/define_property/main.c new file mode 100644 index 0000000..8488f4e --- /dev/null +++ b/Tests/RunCMake/define_property/main.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} |