diff options
author | Brad King <brad.king@kitware.com> | 2017-06-09 15:20:41 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-06-09 16:34:39 (GMT) |
commit | 414438b2fb5a43c447273b425b59cd982818457b (patch) | |
tree | 191e35f5092f645b9a56178c2f3fcbf37be06480 | |
parent | 591557ba450f1f24610ea0eefcb4e1d7665fae25 (diff) | |
download | CMake-414438b2fb5a43c447273b425b59cd982818457b.zip CMake-414438b2fb5a43c447273b425b59cd982818457b.tar.gz CMake-414438b2fb5a43c447273b425b59cd982818457b.tar.bz2 |
CUDA: Add option to run the compiler through launcher tools
Add a `CUDA_COMPILER_LAUNCHER` target property like those added for C
and CXX by commit v3.4.0-rc1~450^2 (Add options to launch the compiler
through tools like ccache or distcc, 2015-06-04).
Fixes: #16953
-rw-r--r-- | Help/prop_tgt/LANG_COMPILER_LAUNCHER.rst | 3 | ||||
-rw-r--r-- | Help/release/dev/cuda-compiler-launcher.rst | 8 | ||||
-rw-r--r-- | Help/variable/CMAKE_LANG_COMPILER_LAUNCHER.rst | 2 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 3 | ||||
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 3 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 1 | ||||
-rw-r--r-- | Tests/RunCMake/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/CompilerLauncher/CUDA-Build-stdout.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/CompilerLauncher/CUDA-launch-Build-stdout.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/CompilerLauncher/CUDA-launch.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/CompilerLauncher/CUDA.cmake | 4 | ||||
-rw-r--r-- | Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake | 15 | ||||
-rw-r--r-- | Tests/RunCMake/CompilerLauncher/main.cu | 4 |
13 files changed, 42 insertions, 9 deletions
diff --git a/Help/prop_tgt/LANG_COMPILER_LAUNCHER.rst b/Help/prop_tgt/LANG_COMPILER_LAUNCHER.rst index 0fe0b31..28925fc 100644 --- a/Help/prop_tgt/LANG_COMPILER_LAUNCHER.rst +++ b/Help/prop_tgt/LANG_COMPILER_LAUNCHER.rst @@ -1,7 +1,8 @@ <LANG>_COMPILER_LAUNCHER ------------------------ -This property is implemented only when ``<LANG>`` is ``C`` or ``CXX``. +This property is implemented only when ``<LANG>`` is ``C``, ``CXX``, +or ``CUDA``. Specify a :ref:`;-list <CMake Language Lists>` containing a command line for a compiler launching tool. The :ref:`Makefile Generators` and the diff --git a/Help/release/dev/cuda-compiler-launcher.rst b/Help/release/dev/cuda-compiler-launcher.rst new file mode 100644 index 0000000..f217780 --- /dev/null +++ b/Help/release/dev/cuda-compiler-launcher.rst @@ -0,0 +1,8 @@ +cuda-compiler-launcher +---------------------- + +* The :ref:`Makefile Generators` and the :generator:`Ninja` generator learned + to add compiler launcher tools like ccache along with the compiler for the + ``CUDA`` language (``C`` and ``CXX`` were supported previously). See the + :variable:`CMAKE_<LANG>_COMPILER_LAUNCHER` variable and + :prop_tgt:`<LANG>_COMPILER_LAUNCHER` target property for details. diff --git a/Help/variable/CMAKE_LANG_COMPILER_LAUNCHER.rst b/Help/variable/CMAKE_LANG_COMPILER_LAUNCHER.rst index 7961f60..f4e2ba5 100644 --- a/Help/variable/CMAKE_LANG_COMPILER_LAUNCHER.rst +++ b/Help/variable/CMAKE_LANG_COMPILER_LAUNCHER.rst @@ -3,4 +3,4 @@ CMAKE_<LANG>_COMPILER_LAUNCHER Default value for :prop_tgt:`<LANG>_COMPILER_LAUNCHER` target property. This variable is used to initialize the property on each target as it is -created. This is done only when ``<LANG>`` is ``C`` or ``CXX``. +created. This is done only when ``<LANG>`` is ``C``, ``CXX``, or ``CUDA``. diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index a4511b6..7938683 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -657,7 +657,8 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( } // Maybe insert a compiler launcher like ccache or distcc - if (!compileCommands.empty() && (lang == "C" || lang == "CXX")) { + if (!compileCommands.empty() && + (lang == "C" || lang == "CXX" || lang == "CUDA")) { std::string const clauncher_prop = lang + "_COMPILER_LAUNCHER"; const char* clauncher = this->GeneratorTarget->GetProperty(clauncher_prop); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 2f4cccb..7c57ef0 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -648,7 +648,8 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang) } // Maybe insert a compiler launcher like ccache or distcc - if (!compileCmds.empty() && (lang == "C" || lang == "CXX")) { + if (!compileCmds.empty() && + (lang == "C" || lang == "CXX" || lang == "CUDA")) { std::string const clauncher_prop = lang + "_COMPILER_LAUNCHER"; const char* clauncher = this->GeneratorTarget->GetProperty(clauncher_prop); if (clauncher && *clauncher) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c95a3ca..c1b6f97 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -276,6 +276,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, this->SetPropertyDefault("CUDA_STANDARD", CM_NULLPTR); this->SetPropertyDefault("CUDA_STANDARD_REQUIRED", CM_NULLPTR); this->SetPropertyDefault("CUDA_EXTENSIONS", CM_NULLPTR); + this->SetPropertyDefault("CUDA_COMPILER_LAUNCHER", CM_NULLPTR); this->SetPropertyDefault("LINK_SEARCH_START_STATIC", CM_NULLPTR); this->SetPropertyDefault("LINK_SEARCH_END_STATIC", CM_NULLPTR); } diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 79f487d..7a59824 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -341,6 +341,9 @@ if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") add_RunCMake_test(ClangTidy -DPSEUDO_TIDY=$<TARGET_FILE:pseudo_tidy>) add_RunCMake_test(IncludeWhatYouUse -DPSEUDO_IWYU=$<TARGET_FILE:pseudo_iwyu>) add_RunCMake_test(Cpplint -DPSEUDO_CPPLINT=$<TARGET_FILE:pseudo_cpplint>) + if(DEFINED CMake_TEST_CUDA) + list(APPEND CompilerLauncher_ARGS -DCMake_TEST_CUDA=${CMake_TEST_CUDA}) + endif() add_RunCMake_test(CompilerLauncher) endif() diff --git a/Tests/RunCMake/CompilerLauncher/CUDA-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/CUDA-Build-stdout.txt new file mode 100644 index 0000000..3313e31 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/CUDA-Build-stdout.txt @@ -0,0 +1 @@ +.*-E env USED_LAUNCHER=1.* diff --git a/Tests/RunCMake/CompilerLauncher/CUDA-launch-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/CUDA-launch-Build-stdout.txt new file mode 100644 index 0000000..3313e31 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/CUDA-launch-Build-stdout.txt @@ -0,0 +1 @@ +.*-E env USED_LAUNCHER=1.* diff --git a/Tests/RunCMake/CompilerLauncher/CUDA-launch.cmake b/Tests/RunCMake/CompilerLauncher/CUDA-launch.cmake new file mode 100644 index 0000000..6b4b816 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/CUDA-launch.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(CUDA.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/CUDA.cmake b/Tests/RunCMake/CompilerLauncher/CUDA.cmake new file mode 100644 index 0000000..fe5560b --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/CUDA.cmake @@ -0,0 +1,4 @@ +enable_language(CUDA) +set(CMAKE_CUDA_COMPILER_LAUNCHER "${CMAKE_COMMAND};-E;env;USED_LAUNCHER=1") +set(CMAKE_VERBOSE_MAKEFILE TRUE) +add_executable(main main.cu) diff --git a/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake b/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake index 5884d5c..ab26512 100644 --- a/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake @@ -15,9 +15,14 @@ function(run_compiler_launcher lang) 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) +set(langs C CXX) +if(CMake_TEST_CUDA) + list(APPEND langs CUDA) endif() + +foreach(lang ${langs}) + run_compiler_launcher(${lang}) + if (NOT RunCMake_GENERATOR STREQUAL "Watcom WMake") + run_compiler_launcher(${lang}-launch) + endif() +endforeach() diff --git a/Tests/RunCMake/CompilerLauncher/main.cu b/Tests/RunCMake/CompilerLauncher/main.cu new file mode 100644 index 0000000..f8b643a --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/main.cu @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} |