summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2015-06-04 19:56:56 (GMT)
committerBrad King <brad.king@kitware.com>2015-06-15 13:36:48 (GMT)
commit698f75971bee336133d21260db069bb139bd3d76 (patch)
treebb84e66564527d57821a0268053e2ddfd2fce571 /Tests
parentd3bb5da9294ddbfcc5fddf7ba3dafd2c3e0b32b2 (diff)
downloadCMake-698f75971bee336133d21260db069bb139bd3d76.zip
CMake-698f75971bee336133d21260db069bb139bd3d76.tar.gz
CMake-698f75971bee336133d21260db069bb139bd3d76.tar.bz2
Add options to launch the compiler through tools like ccache or distcc
Create a <LANG>_COMPILER_LAUNCHER target property (initialized by a CMAKE_<LANG>_COMPILER_LAUNCHER variable) to specify a compiler launcher tool. This will supersede the CMAKE_<LANG>_COMPILER_ARG1 approach to using such tools. The old approach set CMAKE_<LANG>_COMPILER to the launcher tool while the new approach leaves this variable set to the actual compiler. Implement this property for Makefile and Ninja generators. It cannot be implemented for VS or Xcode generators as the IDE build tools offer no such hooks.
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/CompilerLauncher/C-Build-stdout.txt1
-rw-r--r--Tests/RunCMake/CompilerLauncher/C-launch-Build-stdout.txt1
-rw-r--r--Tests/RunCMake/CompilerLauncher/C-launch.cmake3
-rw-r--r--Tests/RunCMake/CompilerLauncher/C.cmake4
-rw-r--r--Tests/RunCMake/CompilerLauncher/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/CompilerLauncher/CXX-Build-stdout.txt1
-rw-r--r--Tests/RunCMake/CompilerLauncher/CXX-launch-Build-stdout.txt1
-rw-r--r--Tests/RunCMake/CompilerLauncher/CXX-launch.cmake3
-rw-r--r--Tests/RunCMake/CompilerLauncher/CXX.cmake4
-rw-r--r--Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake23
-rw-r--r--Tests/RunCMake/CompilerLauncher/main.c3
-rw-r--r--Tests/RunCMake/CompilerLauncher/main.cxx1
13 files changed, 49 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 592b5e4..2a4108f 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -232,4 +232,5 @@ endif()
if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja")
add_executable(pseudo_iwyu pseudo_iwyu.c)
add_RunCMake_test(IncludeWhatYouUse -DPSEUDO_IWYU=$<TARGET_FILE:pseudo_iwyu>)
+ add_RunCMake_test(CompilerLauncher)
endif()
diff --git a/Tests/RunCMake/CompilerLauncher/C-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/C-Build-stdout.txt
new file mode 100644
index 0000000..3313e31
--- /dev/null
+++ b/Tests/RunCMake/CompilerLauncher/C-Build-stdout.txt
@@ -0,0 +1 @@
+.*-E env USED_LAUNCHER=1.*
diff --git a/Tests/RunCMake/CompilerLauncher/C-launch-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/C-launch-Build-stdout.txt
new file mode 100644
index 0000000..3313e31
--- /dev/null
+++ b/Tests/RunCMake/CompilerLauncher/C-launch-Build-stdout.txt
@@ -0,0 +1 @@
+.*-E env USED_LAUNCHER=1.*
diff --git a/Tests/RunCMake/CompilerLauncher/C-launch.cmake b/Tests/RunCMake/CompilerLauncher/C-launch.cmake
new file mode 100644
index 0000000..e66ca20
--- /dev/null
+++ b/Tests/RunCMake/CompilerLauncher/C-launch.cmake
@@ -0,0 +1,3 @@
+set(CTEST_USE_LAUNCHERS 1)
+include(CTestUseLaunchers)
+include(C.cmake)
diff --git a/Tests/RunCMake/CompilerLauncher/C.cmake b/Tests/RunCMake/CompilerLauncher/C.cmake
new file mode 100644
index 0000000..67bf7c4
--- /dev/null
+++ b/Tests/RunCMake/CompilerLauncher/C.cmake
@@ -0,0 +1,4 @@
+enable_language(C)
+set(CMAKE_C_COMPILER_LAUNCHER "${CMAKE_COMMAND};-E;env;USED_LAUNCHER=1")
+set(CMAKE_VERBOSE_MAKEFILE TRUE)
+add_executable(main main.c)
diff --git a/Tests/RunCMake/CompilerLauncher/CMakeLists.txt b/Tests/RunCMake/CompilerLauncher/CMakeLists.txt
new file mode 100644
index 0000000..18dfd26
--- /dev/null
+++ b/Tests/RunCMake/CompilerLauncher/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.2)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/CompilerLauncher/CXX-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/CXX-Build-stdout.txt
new file mode 100644
index 0000000..3313e31
--- /dev/null
+++ b/Tests/RunCMake/CompilerLauncher/CXX-Build-stdout.txt
@@ -0,0 +1 @@
+.*-E env USED_LAUNCHER=1.*
diff --git a/Tests/RunCMake/CompilerLauncher/CXX-launch-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/CXX-launch-Build-stdout.txt
new file mode 100644
index 0000000..3313e31
--- /dev/null
+++ b/Tests/RunCMake/CompilerLauncher/CXX-launch-Build-stdout.txt
@@ -0,0 +1 @@
+.*-E env USED_LAUNCHER=1.*
diff --git a/Tests/RunCMake/CompilerLauncher/CXX-launch.cmake b/Tests/RunCMake/CompilerLauncher/CXX-launch.cmake
new file mode 100644
index 0000000..3002c9d
--- /dev/null
+++ b/Tests/RunCMake/CompilerLauncher/CXX-launch.cmake
@@ -0,0 +1,3 @@
+set(CTEST_USE_LAUNCHERS 1)
+include(CTestUseLaunchers)
+include(CXX.cmake)
diff --git a/Tests/RunCMake/CompilerLauncher/CXX.cmake b/Tests/RunCMake/CompilerLauncher/CXX.cmake
new file mode 100644
index 0000000..cdd3478
--- /dev/null
+++ b/Tests/RunCMake/CompilerLauncher/CXX.cmake
@@ -0,0 +1,4 @@
+enable_language(CXX)
+set(CMAKE_CXX_COMPILER_LAUNCHER "${CMAKE_COMMAND};-E;env;USED_LAUNCHER=1")
+set(CMAKE_VERBOSE_MAKEFILE TRUE)
+add_executable(main main.cxx)
diff --git a/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake b/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake
new file mode 100644
index 0000000..5884d5c
--- /dev/null
+++ b/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake
@@ -0,0 +1,23 @@
+include(RunCMake)
+
+function(run_compiler_launcher lang)
+ # Use a single build tree for tests without cleaning.
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${lang}-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+ run_cmake(${lang})
+
+ set(RunCMake_TEST_OUTPUT_MERGE 1)
+ if("${RunCMake_GENERATOR}" STREQUAL "Ninja")
+ set(verbose_args -- -v)
+ endif()
+ run_cmake_command(${lang}-Build ${CMAKE_COMMAND} --build . ${verbose_args})
+endfunction()
+
+run_compiler_launcher(C)
+run_compiler_launcher(CXX)
+if (NOT RunCMake_GENERATOR STREQUAL "Watcom WMake")
+ run_compiler_launcher(C-launch)
+ run_compiler_launcher(CXX-launch)
+endif()
diff --git a/Tests/RunCMake/CompilerLauncher/main.c b/Tests/RunCMake/CompilerLauncher/main.c
new file mode 100644
index 0000000..03b2213
--- /dev/null
+++ b/Tests/RunCMake/CompilerLauncher/main.c
@@ -0,0 +1,3 @@
+int main(void) {
+ return 0;
+}
diff --git a/Tests/RunCMake/CompilerLauncher/main.cxx b/Tests/RunCMake/CompilerLauncher/main.cxx
new file mode 100644
index 0000000..76e8197
--- /dev/null
+++ b/Tests/RunCMake/CompilerLauncher/main.cxx
@@ -0,0 +1 @@
+int main() { return 0; }