summaryrefslogtreecommitdiffstats
path: root/Tests/CMakeCommands
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-06-04 08:30:24 (GMT)
committerStephen Kelly <steveire@gmail.com>2013-06-04 09:36:55 (GMT)
commita984f3257e95f29a72da6566859d4c6a8a5d749b (patch)
treef174238c2d4c5b582fd5f892ea1c64e2b8418c06 /Tests/CMakeCommands
parent00c3840cc8c36adea76c6e833a9e2069645aec8a (diff)
downloadCMake-a984f3257e95f29a72da6566859d4c6a8a5d749b.zip
CMake-a984f3257e95f29a72da6566859d4c6a8a5d749b.tar.gz
CMake-a984f3257e95f29a72da6566859d4c6a8a5d749b.tar.bz2
Introduce add_compile_options command.
This command is similar to add_definitions, in that it affects the compile options of all targets which follow it. The implementation is similar to the implementation of the include_directories command, in that it is based on populating a COMPILE_OPTIONS directory property and using that to initialize the same property on targets. Unlike the include_directories command however, the add_compile_options command does not affect previously defined targets. That is, in the following code, foo will not be compiled with -Wall, but bar will be: add_library(foo ...) add_compile_options(-Wall) add_library(bar ...)
Diffstat (limited to 'Tests/CMakeCommands')
-rw-r--r--Tests/CMakeCommands/add_compile_options/CMakeLists.txt14
-rw-r--r--Tests/CMakeCommands/add_compile_options/main.cpp11
2 files changed, 25 insertions, 0 deletions
diff --git a/Tests/CMakeCommands/add_compile_options/CMakeLists.txt b/Tests/CMakeCommands/add_compile_options/CMakeLists.txt
new file mode 100644
index 0000000..1652cf6
--- /dev/null
+++ b/Tests/CMakeCommands/add_compile_options/CMakeLists.txt
@@ -0,0 +1,14 @@
+cmake_minimum_required(VERSION 2.8)
+
+project(add_compile_options)
+
+add_compile_options(-DTEST_OPTION)
+
+add_executable(add_compile_options main.cpp)
+
+if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
+ target_compile_definitions(add_compile_options
+ PRIVATE
+ "DO_GNU_TESTS"
+ )
+endif()
diff --git a/Tests/CMakeCommands/add_compile_options/main.cpp b/Tests/CMakeCommands/add_compile_options/main.cpp
new file mode 100644
index 0000000..2bb20ac
--- /dev/null
+++ b/Tests/CMakeCommands/add_compile_options/main.cpp
@@ -0,0 +1,11 @@
+
+#ifdef DO_GNU_TESTS
+# ifndef TEST_OPTION
+# error Expected TEST_OPTION
+# endif
+#endif
+
+int main(void)
+{
+ return 0;
+}