summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r--Tests/RunCMake/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/target_compile_options/BEFORE_keyword.cmake8
-rw-r--r--Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword-NEW-result.txt1
-rw-r--r--Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword-OLD-result.txt1
-rw-r--r--Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword-OLD-stdout.txt1
-rw-r--r--Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword.cmake15
-rw-r--r--Tests/RunCMake/target_compile_options/CMP0101.c9
-rw-r--r--Tests/RunCMake/target_compile_options/RunCMakeTest.cmake18
8 files changed, 54 insertions, 1 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index cfb6ffe..39426c2 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -450,7 +450,7 @@ add_RunCMake_test(target_link_options -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_I
add_RunCMake_test(target_compile_definitions)
add_RunCMake_test(target_compile_features)
-add_RunCMake_test(target_compile_options)
+add_RunCMake_test(target_compile_options -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID})
add_RunCMake_test(target_include_directories)
add_RunCMake_test(target_sources)
add_RunCMake_test(CheckModules)
diff --git a/Tests/RunCMake/target_compile_options/BEFORE_keyword.cmake b/Tests/RunCMake/target_compile_options/BEFORE_keyword.cmake
new file mode 100644
index 0000000..8016230
--- /dev/null
+++ b/Tests/RunCMake/target_compile_options/BEFORE_keyword.cmake
@@ -0,0 +1,8 @@
+
+add_executable (CMP0101_OLD CMP0101.c)
+target_compile_options (main PRIVATE -UBEFORE_KEYWORD)
+target_compile_options (main BEFORE PRIVATE -DBEFORE_KEYWORD)
+
+add_executable (CMP0101_NEW CMP0101.c)
+target_compile_options (main PRIVATE -UBEFORE_KEYWORD)
+target_compile_options (main BEFORE PRIVATE -DBEFORE_KEYWORD)
diff --git a/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword-NEW-result.txt b/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword-NEW-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword-NEW-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword-OLD-result.txt b/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword-OLD-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword-OLD-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword-OLD-stdout.txt b/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword-OLD-stdout.txt
new file mode 100644
index 0000000..850aa65
--- /dev/null
+++ b/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword-OLD-stdout.txt
@@ -0,0 +1 @@
+BEFORE not honored
diff --git a/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword.cmake b/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword.cmake
new file mode 100644
index 0000000..577427f
--- /dev/null
+++ b/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword.cmake
@@ -0,0 +1,15 @@
+
+enable_language(C)
+
+cmake_policy (SET CMP0101 OLD)
+
+add_executable (CMP0101_OLD CMP0101.c)
+target_compile_options (CMP0101_OLD PRIVATE -UBEFORE_KEYWORD)
+target_compile_options (CMP0101_OLD BEFORE PRIVATE -DBEFORE_KEYWORD)
+
+
+cmake_policy (SET CMP0101 NEW)
+
+add_executable (CMP0101_NEW CMP0101.c)
+target_compile_options (CMP0101_NEW PRIVATE -UBEFORE_KEYWORD)
+target_compile_options (CMP0101_NEW BEFORE PRIVATE -DBEFORE_KEYWORD)
diff --git a/Tests/RunCMake/target_compile_options/CMP0101.c b/Tests/RunCMake/target_compile_options/CMP0101.c
new file mode 100644
index 0000000..250869a
--- /dev/null
+++ b/Tests/RunCMake/target_compile_options/CMP0101.c
@@ -0,0 +1,9 @@
+
+#if defined(BEFORE_KEYWORD)
+# error "BEFORE not honored"
+#endif
+
+int main()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/target_compile_options/RunCMakeTest.cmake b/Tests/RunCMake/target_compile_options/RunCMakeTest.cmake
index b67c598..9f51a9a 100644
--- a/Tests/RunCMake/target_compile_options/RunCMakeTest.cmake
+++ b/Tests/RunCMake/target_compile_options/RunCMakeTest.cmake
@@ -1,3 +1,21 @@
include(RunCMake)
run_cmake(empty_keyword_args)
+
+if (CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
+ macro(run_cmake_target test subtest target)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build)
+ set(RunCMake_TEST_OUTPUT_MERGE 1)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ run_cmake_command(${test}-${subtest} ${CMAKE_COMMAND} --build . --target ${target} ${ARGN})
+
+ unset(RunCMake_TEST_BINARY_DIR)
+ unset(RunCMake_TEST_OUTPUT_MERGE)
+ unset(RunCMake_TEST_NO_CLEAN)
+ endmacro()
+
+ run_cmake(CMP0101-BEFORE_keyword)
+
+ run_cmake_target(CMP0101-BEFORE_keyword OLD CMP0101_OLD)
+ run_cmake_target(CMP0101-BEFORE_keyword NEW CMP0101_NEW)
+endif()