diff options
46 files changed, 221 insertions, 46 deletions
diff --git a/Help/command/try_compile.rst b/Help/command/try_compile.rst index edbf92c..323077a 100644 --- a/Help/command/try_compile.rst +++ b/Help/command/try_compile.rst @@ -135,6 +135,7 @@ If set, the following variables are passed in to the generated try_compile CMakeLists.txt to initialize compile target properties with default values: +* :variable:`CMAKE_CUDA_RUNTIME_LIBRARY` * :variable:`CMAKE_ENABLE_EXPORTS` * :variable:`CMAKE_LINK_SEARCH_START_STATIC` * :variable:`CMAKE_LINK_SEARCH_END_STATIC` diff --git a/Help/prop_sf/OBJECT_OUTPUTS.rst b/Help/prop_sf/OBJECT_OUTPUTS.rst index e7e880b..3e799ed 100644 --- a/Help/prop_sf/OBJECT_OUTPUTS.rst +++ b/Help/prop_sf/OBJECT_OUTPUTS.rst @@ -7,3 +7,6 @@ Additional outputs created by compilation of this source file. If any of these outputs is missing the object will be recompiled. This is supported only on the :generator:`Ninja` and :ref:`Makefile Generators` and will be ignored on other generators. + +This property supports +:manual:`generator expressions <cmake-generator-expressions(7)>`. diff --git a/Help/prop_tgt/CUDA_RUNTIME_LIBRARY.rst b/Help/prop_tgt/CUDA_RUNTIME_LIBRARY.rst index 0782765..11b344c 100644 --- a/Help/prop_tgt/CUDA_RUNTIME_LIBRARY.rst +++ b/Help/prop_tgt/CUDA_RUNTIME_LIBRARY.rst @@ -10,8 +10,8 @@ The allowed case insensitive values are: Contents of ``CUDA_RUNTIME_LIBRARY`` may use :manual:`generator expressions <cmake-generator-expressions(7)>`. -If this property is not set then CMake uses the default value -``Static`` to select the CUDA runtime library. +If that property is not set then CMake uses an appropriate default +value based on the compiler to select the CUDA runtime library. .. note:: diff --git a/Help/release/dev/genex-OBJECT_OUTPUTS.rst b/Help/release/dev/genex-OBJECT_OUTPUTS.rst new file mode 100644 index 0000000..738dcbb --- /dev/null +++ b/Help/release/dev/genex-OBJECT_OUTPUTS.rst @@ -0,0 +1,4 @@ +genex-OBJECT_OUTPUTS +-------------------- + +* :prop_sf:`OBJECT_OUTPUTS` now support :manual:`generator expressions <cmake-generator-expressions(7)>`. diff --git a/Help/variable/CMAKE_CUDA_RUNTIME_LIBRARY.rst b/Help/variable/CMAKE_CUDA_RUNTIME_LIBRARY.rst index ea1c1b8..e3205d3 100644 --- a/Help/variable/CMAKE_CUDA_RUNTIME_LIBRARY.rst +++ b/Help/variable/CMAKE_CUDA_RUNTIME_LIBRARY.rst @@ -1,7 +1,7 @@ CMAKE_CUDA_RUNTIME_LIBRARY -------------------------- -Select the CUDA runtime library for use by compilers targeting the MSVC ABI. +Select the CUDA runtime library for use when compiling and linking CUDA. This variable is used to initialize the :prop_tgt:`CUDA_RUNTIME_LIBRARY` property on all targets as they are created. @@ -14,7 +14,8 @@ Contents of ``CMAKE_CUDA_RUNTIME_LIBRARY`` may use If this variable is not set then the :prop_tgt:`CUDA_RUNTIME_LIBRARY` target property will not be set automatically. If that property is not set then -CMake uses the default value ``Static`` to select the CUDA runtime library. +CMake uses an appropriate default value based on the compiler to select the +CUDA runtime library. .. note:: diff --git a/Modules/CMakeCUDACompiler.cmake.in b/Modules/CMakeCUDACompiler.cmake.in index 289e96e..64fb469 100644 --- a/Modules/CMakeCUDACompiler.cmake.in +++ b/Modules/CMakeCUDACompiler.cmake.in @@ -54,6 +54,8 @@ set(CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES "@CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES@") set(CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES "@CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES@") set(CMAKE_CUDA_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_CUDA_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@") +@_SET_CMAKE_CUDA_RUNTIME_LIBRARY_DEFAULT@ + set(CMAKE_LINKER "@CMAKE_LINKER@") set(CMAKE_AR "@CMAKE_AR@") set(CMAKE_MT "@CMAKE_MT@") diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake index af36688..427e5b5 100644 --- a/Modules/CMakeDetermineCUDACompiler.cmake +++ b/Modules/CMakeDetermineCUDACompiler.cmake @@ -112,6 +112,20 @@ if(${CMAKE_GENERATOR} MATCHES "Visual Studio") set(CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES "") set(CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES "") set(CMAKE_CUDA_HOST_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "") + + # We do not currently detect CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES but we + # do need to detect CMAKE_CUDA_RUNTIME_LIBRARY_DEFAULT from the compiler by + # looking at which cudart library exists in the implicit link libraries passed + # to the host linker. + if(CMAKE_CUDA_COMPILER_PRODUCED_OUTPUT MATCHES "link\\.exe [^\n]*cudart_static\\.lib") + set(CMAKE_CUDA_RUNTIME_LIBRARY_DEFAULT "STATIC") + elseif(CMAKE_CUDA_COMPILER_PRODUCED_OUTPUT MATCHES "link\\.exe [^\n]*cudart\\.lib") + set(CMAKE_CUDA_RUNTIME_LIBRARY_DEFAULT "SHARED") + else() + set(CMAKE_CUDA_RUNTIME_LIBRARY_DEFAULT "NONE") + endif() + set(_SET_CMAKE_CUDA_RUNTIME_LIBRARY_DEFAULT + "set(CMAKE_CUDA_RUNTIME_LIBRARY_DEFAULT \"${CMAKE_CUDA_RUNTIME_LIBRARY_DEFAULT}\")") elseif(CMAKE_CUDA_COMPILER_ID STREQUAL "Clang") # Parse default CUDA architecture. if(NOT CMAKE_CUDA_ARCHITECTURES) @@ -232,6 +246,20 @@ elseif(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA") log "${CMAKE_CUDA_IMPLICIT_OBJECT_REGEX}") + # Detect CMAKE_CUDA_RUNTIME_LIBRARY_DEFAULT from the compiler by looking at which + # cudart library exists in the implicit link libraries passed to the host linker. + # This is required when a project sets the cuda runtime library as part of the + # initial flags. + if(";${CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES};" MATCHES [[;cudart_static(\.lib)?;]]) + set(CMAKE_CUDA_RUNTIME_LIBRARY_DEFAULT "STATIC") + elseif(";${CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES};" MATCHES [[;cudart(\.lib)?;]]) + set(CMAKE_CUDA_RUNTIME_LIBRARY_DEFAULT "SHARED") + else() + set(CMAKE_CUDA_RUNTIME_LIBRARY_DEFAULT "NONE") + endif() + set(_SET_CMAKE_CUDA_RUNTIME_LIBRARY_DEFAULT + "set(CMAKE_CUDA_RUNTIME_LIBRARY_DEFAULT \"${CMAKE_CUDA_RUNTIME_LIBRARY_DEFAULT}\")") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Parsed CUDA nvcc implicit link information from above output:\n${_nvcc_log}\n${log}\n\n") else() diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 9ebaa6c..df48fa5 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -381,7 +381,11 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} if(CMAKE_VS_PLATFORM_NAME STREQUAL x64) set(id_ItemDefinitionGroup_entry "<CudaCompile><TargetMachinePlatform>64</TargetMachinePlatform><AdditionalOptions>%(AdditionalOptions)-v</AdditionalOptions></CudaCompile>") endif() - set(id_Link_AdditionalDependencies "<AdditionalDependencies>cudart.lib</AdditionalDependencies>") + if(CMAKE_CUDA_FLAGS MATCHES "(^| )-cudart +shared( |$)") + set(id_Link_AdditionalDependencies "<AdditionalDependencies>cudart.lib</AdditionalDependencies>") + else() + set(id_Link_AdditionalDependencies "<AdditionalDependencies>cudart_static.lib</AdditionalDependencies>") + endif() endif() configure_file(${CMAKE_ROOT}/Modules/CompilerId/VS-${v}.${ext}.in ${id_dir}/CompilerId${lang}.${ext} @ONLY) diff --git a/Modules/Compiler/NVIDIA-CUDA.cmake b/Modules/Compiler/NVIDIA-CUDA.cmake index eb8d55c..87607e2 100644 --- a/Modules/Compiler/NVIDIA-CUDA.cmake +++ b/Modules/Compiler/NVIDIA-CUDA.cmake @@ -59,7 +59,6 @@ set(CMAKE_CUDA_DEVICE_COMPILER_WRAPPER_FLAG_SEP ",") set(CMAKE_CUDA_DEVICE_LINKER_WRAPPER_FLAG "-Xlinker=") set(CMAKE_CUDA_DEVICE_LINKER_WRAPPER_FLAG_SEP ",") -set(CMAKE_CUDA_RUNTIME_LIBRARY_DEFAULT "STATIC") set(CMAKE_CUDA_RUNTIME_LIBRARY_LINK_OPTIONS_STATIC "cudadevrt;cudart_static") set(CMAKE_CUDA_RUNTIME_LIBRARY_LINK_OPTIONS_SHARED "cudadevrt;cudart") set(CMAKE_CUDA_RUNTIME_LIBRARY_LINK_OPTIONS_NONE "") diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index cb400a5..1be0625 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -2600,6 +2600,12 @@ if (("Development.Module" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS NAMES_PER_DIR HINTS "${_${_PYTHON_PREFIX}_PATH}" ${_${_PYTHON_PREFIX}_HINTS} NO_DEFAULT_PATH) + # second try including CMAKE variables to catch-up non conventional layouts + find_library (_${_PYTHON_PREFIX}_LIBRARY_DEBUG + NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG} + NAMES_PER_DIR + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH) endif() # retrieve runtime libraries diff --git a/Modules/Platform/Windows-NVIDIA-CUDA.cmake b/Modules/Platform/Windows-NVIDIA-CUDA.cmake index f887594..a88f4bc 100644 --- a/Modules/Platform/Windows-NVIDIA-CUDA.cmake +++ b/Modules/Platform/Windows-NVIDIA-CUDA.cmake @@ -69,7 +69,6 @@ else() endif() unset(_cmp0092) -set(CMAKE_CUDA_RUNTIME_LIBRARY_DEFAULT "STATIC") set(CMAKE_CUDA_RUNTIME_LIBRARY_LINK_OPTIONS_STATIC "cudadevrt;cudart_static") set(CMAKE_CUDA_RUNTIME_LIBRARY_LINK_OPTIONS_SHARED "cudadevrt;cudart") set(CMAKE_CUDA_RUNTIME_LIBRARY_LINK_OPTIONS_NONE "") diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 34009ff..fda9848 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 17) -set(CMake_VERSION_PATCH 20200520) +set(CMake_VERSION_PATCH 20200522) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/cmCMakeCommand.cxx b/Source/cmCMakeCommand.cxx index da15b1a..23bc0ea 100644 --- a/Source/cmCMakeCommand.cxx +++ b/Source/cmCMakeCommand.cxx @@ -4,7 +4,6 @@ #include <algorithm> #include <cstddef> -#include <iosfwd> #include <memory> #include <string> @@ -14,13 +13,6 @@ #include "cmRange.h" #include "cmStringAlgorithms.h" -inline std::ostream& operator<<(std::ostream& os, - cmListFileArgument const& arg) -{ - os << arg.Value; - return os; -} - bool cmCMakeCommand(std::vector<cmListFileArgument> const& args, cmExecutionStatus& status) { @@ -34,20 +26,50 @@ bool cmCMakeCommand(std::vector<cmListFileArgument> const& args, bool result = false; - if (args[0].Value == "INVOKE") { - if (args.size() == 1) { + std::vector<std::string> dispatchExpandedArgs; + std::vector<cmListFileArgument> dispatchArgs; + dispatchArgs.emplace_back(args[0]); + makefile.ExpandArguments(dispatchArgs, dispatchExpandedArgs); + + if (dispatchExpandedArgs.empty()) { + status.SetError("called with incorrect number of arguments"); + return false; + } + + if (dispatchExpandedArgs[0] == "INVOKE") { + if ((args.size() == 1 && dispatchExpandedArgs.size() != 2) || + dispatchExpandedArgs.size() > 2) { status.SetError("called with incorrect number of arguments"); return false; } // First argument is the name of the function to call + std::string invokeCommand; + size_t startArg; + if (dispatchExpandedArgs.size() == 1) { + std::vector<std::string> functionExpandedArg; + std::vector<cmListFileArgument> functionArg; + functionArg.emplace_back(args[1]); + makefile.ExpandArguments(functionArg, functionExpandedArg); + + if (functionExpandedArg.size() != 1) { + status.SetError("called with incorrect number of arguments"); + return false; + } + + invokeCommand = functionExpandedArg[0]; + startArg = 2; + } else { + invokeCommand = dispatchExpandedArgs[1]; + startArg = 1; + } + cmListFileFunction func; - func.Name = args[1].Value; + func.Name = invokeCommand; func.Line = context.Line; // The rest of the arguments are passed to the function call above - func.Arguments.resize(args.size() - 1); - for (size_t i = 2; i < args.size(); ++i) { + for (size_t i = startArg; i < args.size(); ++i) { cmListFileArgument lfarg; lfarg.Delim = args[i].Delim; lfarg.Line = context.Line; @@ -56,21 +78,29 @@ bool cmCMakeCommand(std::vector<cmListFileArgument> const& args, } result = makefile.ExecuteCommand(func, status); - } else if (args[0].Value == "EVAL") { - if (args.size() < 2) { + } else if (dispatchExpandedArgs[0] == "EVAL") { + std::vector<std::string> expandedArgs; + makefile.ExpandArguments(args, expandedArgs); + + if (expandedArgs.size() < 2) { status.SetError("called with incorrect number of arguments"); return false; } - auto code_iter = std::find_if( - args.begin(), args.end(), - [](cmListFileArgument const& arg) { return arg.Value == "CODE"; }); - if (code_iter == args.end()) { - status.SetError("called without CODE argument"); + if (expandedArgs[1] != "CODE") { + auto code_iter = + std::find(expandedArgs.begin() + 2, expandedArgs.end(), "CODE"); + if (code_iter == expandedArgs.end()) { + status.SetError("called without CODE argument"); + } else { + status.SetError( + "called with unsupported arguments between EVAL and CODE arguments"); + } return false; } - const std::string code = cmJoin(cmMakeRange(++code_iter, args.end()), " "); + const std::string code = + cmJoin(cmMakeRange(expandedArgs.begin() + 2, expandedArgs.end()), " "); result = makefile.ReadListFileAsString( code, cmStrCat(context.FilePath, ":", context.Line, ":EVAL")); } else { diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 4e2caed..cc2cd01 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -44,6 +44,8 @@ static std::string const kCMAKE_CUDA_ARCHITECTURES = "CMAKE_CUDA_ARCHITECTURES"; static std::string const kCMAKE_CUDA_COMPILER_TARGET = "CMAKE_CUDA_COMPILER_TARGET"; +static std::string const kCMAKE_CUDA_RUNTIME_LIBRARY = + "CMAKE_CUDA_RUNTIME_LIBRARY"; static std::string const kCMAKE_ENABLE_EXPORTS = "CMAKE_ENABLE_EXPORTS"; static std::string const kCMAKE_LINK_SEARCH_END_STATIC = "CMAKE_LINK_SEARCH_END_STATIC"; @@ -717,6 +719,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, vars.insert(kCMAKE_CXX_COMPILER_TARGET); vars.insert(kCMAKE_CUDA_ARCHITECTURES); vars.insert(kCMAKE_CUDA_COMPILER_TARGET); + vars.insert(kCMAKE_CUDA_RUNTIME_LIBRARY); vars.insert(kCMAKE_ENABLE_EXPORTS); vars.insert(kCMAKE_LINK_SEARCH_END_STATIC); vars.insert(kCMAKE_LINK_SEARCH_START_STATIC); diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 2f9da1c..917985a 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3864,6 +3864,10 @@ std::string cmGeneratorTarget::GetPchFileObject(const std::string& config, pchSource, false, cmSourceFileLocationKind::Known); filename = cmStrCat(this->ObjectDirectory, this->GetObjectName(pchSf)); + if (this->GetGlobalGenerator()->IsMultiConfig()) { + cmSystemTools::ReplaceString( + filename, this->GetGlobalGenerator()->GetCMakeCFGIntDir(), config); + } } return inserted.first->second; } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index f29c682..ad1cbd8 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2633,7 +2633,9 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target) // Exclude the pch files from linking if (this->Makefile->IsOn("CMAKE_LINK_PCH")) { if (!ReuseFrom) { - pch_sf->SetProperty("OBJECT_OUTPUTS", pchFile.c_str()); + pch_sf->AppendProperty( + "OBJECT_OUTPUTS", + cmStrCat("$<$<CONFIG:", config, ">:", pchFile, ">")); } else { auto reuseTarget = this->GlobalGenerator->FindGeneratorTarget(*ReuseFrom); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 5f0cfcf..04d4db7 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -895,9 +895,14 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( // Check for extra outputs created by the compilation. std::vector<std::string> outputs(1, relativeObj); if (cmProp extra_outputs_str = source.GetProperty("OBJECT_OUTPUTS")) { - // Register these as extra files to clean. - cmExpandList(*extra_outputs_str, outputs); - this->CleanFiles.insert(outputs.begin() + 1, outputs.end()); + std::string evaluated_outputs = cmGeneratorExpression::Evaluate( + *extra_outputs_str, this->LocalGenerator, config); + + if (!evaluated_outputs.empty()) { + // Register these as extra files to clean. + cmExpandList(evaluated_outputs, outputs); + this->CleanFiles.insert(outputs.begin() + 1, outputs.end()); + } } // Write the rule. diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index efd2fd5..f4ff51b 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -1266,14 +1266,19 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( } if (cmProp objectOutputs = source->GetProperty("OBJECT_OUTPUTS")) { - cmNinjaBuild build("phony"); - build.Comment = "Additional output files."; - build.Outputs = cmExpandedList(*objectOutputs); - std::transform(build.Outputs.begin(), build.Outputs.end(), - build.Outputs.begin(), MapToNinjaPath()); - build.ExplicitDeps = objBuild.Outputs; - this->GetGlobalGenerator()->WriteBuild(this->GetImplFileStream(fileConfig), - build); + std::string evaluatedObjectOutputs = cmGeneratorExpression::Evaluate( + *objectOutputs, this->LocalGenerator, config); + + if (!evaluatedObjectOutputs.empty()) { + cmNinjaBuild build("phony"); + build.Comment = "Additional output files."; + build.Outputs = cmExpandedList(evaluatedObjectOutputs); + std::transform(build.Outputs.begin(), build.Outputs.end(), + build.Outputs.begin(), MapToNinjaPath()); + build.ExplicitDeps = objBuild.Outputs; + this->GetGlobalGenerator()->WriteBuild( + this->GetImplFileStream(fileConfig), build); + } } } diff --git a/Tests/Cuda/CMakeLists.txt b/Tests/Cuda/CMakeLists.txt index 83f2f2d..630cea2 100644 --- a/Tests/Cuda/CMakeLists.txt +++ b/Tests/Cuda/CMakeLists.txt @@ -15,7 +15,7 @@ ADD_TEST_MACRO(Cuda.SharedRuntimePlusToolkit SharedRuntimePlusToolkit) # Separable compilation is currently only supported on NVCC. Disable tests # using it for other compilers. -if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA") +if(CMake_TEST_CUDA AND NOT CMake_TEST_CUDA STREQUAL "Clang") ADD_TEST_MACRO(Cuda.Complex CudaComplex) ADD_TEST_MACRO(Cuda.ProperDeviceLibraries ProperDeviceLibraries) ADD_TEST_MACRO(Cuda.ProperLinkFlags ProperLinkFlags) diff --git a/Tests/CudaOnly/CMakeLists.txt b/Tests/CudaOnly/CMakeLists.txt index ee7374e..8244b91 100644 --- a/Tests/CudaOnly/CMakeLists.txt +++ b/Tests/CudaOnly/CMakeLists.txt @@ -8,7 +8,9 @@ ADD_TEST_MACRO(CudaOnly.Standard98 CudaOnlyStandard98) ADD_TEST_MACRO(CudaOnly.Toolkit CudaOnlyToolkit) ADD_TEST_MACRO(CudaOnly.WithDefs CudaOnlyWithDefs) -if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA") +if(CMake_TEST_CUDA AND NOT CMake_TEST_CUDA STREQUAL "Clang") + ADD_TEST_MACRO(CudaOnly.SharedRuntimeViaCUDAFlags CudaOnlySharedRuntimeViaCUDAFlags) + # Separable compilation is currently only supported on NVCC. Disable tests # using it for other compilers. ADD_TEST_MACRO(CudaOnly.CircularLinkLine CudaOnlyCircularLinkLine) diff --git a/Tests/CudaOnly/GPUDebugFlag/CMakeLists.txt b/Tests/CudaOnly/GPUDebugFlag/CMakeLists.txt index 325723a..6675655 100644 --- a/Tests/CudaOnly/GPUDebugFlag/CMakeLists.txt +++ b/Tests/CudaOnly/GPUDebugFlag/CMakeLists.txt @@ -7,7 +7,7 @@ set(CMAKE_CUDA_ARCHITECTURES 30) # Goal for this example: # Verify that enabling device debug works. -string(APPEND CMAKE_CUDA_FLAGS "-G") +string(APPEND CMAKE_CUDA_FLAGS " -G") add_executable(CudaOnlyGPUDebugFlag main.cu) diff --git a/Tests/CudaOnly/SharedRuntimeViaCUDAFlags/CMakeLists.txt b/Tests/CudaOnly/SharedRuntimeViaCUDAFlags/CMakeLists.txt new file mode 100644 index 0000000..24ff478 --- /dev/null +++ b/Tests/CudaOnly/SharedRuntimeViaCUDAFlags/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.17) +project(SharedRuntimeViaCUDAFlags NONE) + +set(CMAKE_CUDA_FLAGS "") +string(APPEND CMAKE_CUDA_FLAGS "-cudart shared") + +enable_language(CUDA) + +add_executable(CudaOnlySharedRuntimeViaCUDAFlags main.cu) + +if(UNIX) + # Help the shared cuda runtime find libcudart as it is not located + # in a default system searched location + set_property(TARGET CudaOnlySharedRuntimeViaCUDAFlags PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) +endif() diff --git a/Tests/CudaOnly/SharedRuntimeViaCUDAFlags/main.cu b/Tests/CudaOnly/SharedRuntimeViaCUDAFlags/main.cu new file mode 100644 index 0000000..766b775 --- /dev/null +++ b/Tests/CudaOnly/SharedRuntimeViaCUDAFlags/main.cu @@ -0,0 +1,5 @@ + +int main() +{ + return 0; +} diff --git a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake index 449db4a..23b89d3 100644 --- a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake +++ b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake @@ -286,7 +286,7 @@ run_cmake_command(NoUnusedVariables ${CMAKE_COMMAND} ${CMAKE_CURRENT_LIST_DIR} ) # CudaSimple uses separable compilation, which is currently only supported on NVCC. -if(CMake_TEST_CUDA AND CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA") +if(CMake_TEST_CUDA AND NOT CMake_TEST_CUDA STREQUAL "Clang") set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CudaSimple-build) run_cmake_configure(CudaSimple) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) diff --git a/Tests/RunCMake/cmake_command/RunCMakeTest.cmake b/Tests/RunCMake/cmake_command/RunCMakeTest.cmake index 0f12b80..a6b2efe 100644 --- a/Tests/RunCMake/cmake_command/RunCMakeTest.cmake +++ b/Tests/RunCMake/cmake_command/RunCMakeTest.cmake @@ -2,11 +2,20 @@ include(RunCMake) run_cmake(cmake_command_no_parameters) run_cmake(cmake_command_unknown_meta_operation) +run_cmake(cmake_command_invoke_double_evaluation) +run_cmake(cmake_command_invoke_expanded_command) +run_cmake(cmake_command_invoke_expanded_command_and_arguments) +run_cmake(cmake_command_invoke_expanded_command_with_explicit_argument) +run_cmake(cmake_command_invoke_expand_command_name) +run_cmake(cmake_command_invoke_expand_function_name) run_cmake(cmake_command_invoke_message) run_cmake(cmake_command_invoke_message_fatal_error) run_cmake(cmake_command_invoke_no_parameters) run_cmake(cmake_command_invoke_preserve_arguments) run_cmake(cmake_command_invoke_unknown_function) +run_cmake(cmake_command_eval_expand_command_name) +run_cmake(cmake_command_eval_expanded_command_and_arguments) +run_cmake(cmake_command_eval_extra_parameters_between_eval_and_code) run_cmake(cmake_command_eval_message) run_cmake(cmake_command_eval_message_fatal_error) run_cmake(cmake_command_eval_no_code) diff --git a/Tests/RunCMake/cmake_command/cmake_command_eval_expand_command_name-stderr.txt b/Tests/RunCMake/cmake_command/cmake_command_eval_expand_command_name-stderr.txt new file mode 100644 index 0000000..d640661 --- /dev/null +++ b/Tests/RunCMake/cmake_command/cmake_command_eval_expand_command_name-stderr.txt @@ -0,0 +1 @@ +OK! diff --git a/Tests/RunCMake/cmake_command/cmake_command_eval_expand_command_name.cmake b/Tests/RunCMake/cmake_command/cmake_command_eval_expand_command_name.cmake new file mode 100644 index 0000000..4cea393 --- /dev/null +++ b/Tests/RunCMake/cmake_command/cmake_command_eval_expand_command_name.cmake @@ -0,0 +1,2 @@ +set (my_eval "EVAL") +cmake_command (${my_eval} CODE message("OK!")) diff --git a/Tests/RunCMake/cmake_command/cmake_command_eval_expanded_command_and_arguments-stderr.txt b/Tests/RunCMake/cmake_command/cmake_command_eval_expanded_command_and_arguments-stderr.txt new file mode 100644 index 0000000..d640661 --- /dev/null +++ b/Tests/RunCMake/cmake_command/cmake_command_eval_expanded_command_and_arguments-stderr.txt @@ -0,0 +1 @@ +OK! diff --git a/Tests/RunCMake/cmake_command/cmake_command_eval_expanded_command_and_arguments.cmake b/Tests/RunCMake/cmake_command/cmake_command_eval_expanded_command_and_arguments.cmake new file mode 100644 index 0000000..fcc399b --- /dev/null +++ b/Tests/RunCMake/cmake_command/cmake_command_eval_expanded_command_and_arguments.cmake @@ -0,0 +1,2 @@ +set(cmd EVAL CODE [[message("OK!")]]) +cmake_command(${cmd}) diff --git a/Tests/RunCMake/cmake_command/cmake_command_eval_extra_parameters_between_eval_and_code-result.txt b/Tests/RunCMake/cmake_command/cmake_command_eval_extra_parameters_between_eval_and_code-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_command/cmake_command_eval_extra_parameters_between_eval_and_code-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_command/cmake_command_eval_extra_parameters_between_eval_and_code-stderr.txt b/Tests/RunCMake/cmake_command/cmake_command_eval_extra_parameters_between_eval_and_code-stderr.txt new file mode 100644 index 0000000..13c114e --- /dev/null +++ b/Tests/RunCMake/cmake_command/cmake_command_eval_extra_parameters_between_eval_and_code-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at cmake_command_eval_extra_parameters_between_eval_and_code.cmake:1 \(cmake_command\): + cmake_command called with unsupported arguments between EVAL and CODE + arguments +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/cmake_command/cmake_command_eval_extra_parameters_between_eval_and_code.cmake b/Tests/RunCMake/cmake_command/cmake_command_eval_extra_parameters_between_eval_and_code.cmake new file mode 100644 index 0000000..0927631 --- /dev/null +++ b/Tests/RunCMake/cmake_command/cmake_command_eval_extra_parameters_between_eval_and_code.cmake @@ -0,0 +1 @@ +cmake_command(EVAL BAD CODE "message(BAD CODE)") diff --git a/Tests/RunCMake/cmake_command/cmake_command_invoke_double_evaluation-stderr.txt b/Tests/RunCMake/cmake_command/cmake_command_invoke_double_evaluation-stderr.txt new file mode 100644 index 0000000..59a70bd --- /dev/null +++ b/Tests/RunCMake/cmake_command/cmake_command_invoke_double_evaluation-stderr.txt @@ -0,0 +1 @@ +var='\${foo}' diff --git a/Tests/RunCMake/cmake_command/cmake_command_invoke_double_evaluation.cmake b/Tests/RunCMake/cmake_command/cmake_command_invoke_double_evaluation.cmake new file mode 100644 index 0000000..10970fc --- /dev/null +++ b/Tests/RunCMake/cmake_command/cmake_command_invoke_double_evaluation.cmake @@ -0,0 +1,2 @@ +set(var [[${foo}]]) +cmake_command(INVOKE cmake_command INVOKE message "var='${var}'") diff --git a/Tests/RunCMake/cmake_command/cmake_command_invoke_expand_command_name-stderr.txt b/Tests/RunCMake/cmake_command/cmake_command_invoke_expand_command_name-stderr.txt new file mode 100644 index 0000000..d640661 --- /dev/null +++ b/Tests/RunCMake/cmake_command/cmake_command_invoke_expand_command_name-stderr.txt @@ -0,0 +1 @@ +OK! diff --git a/Tests/RunCMake/cmake_command/cmake_command_invoke_expand_command_name.cmake b/Tests/RunCMake/cmake_command/cmake_command_invoke_expand_command_name.cmake new file mode 100644 index 0000000..d59afe4 --- /dev/null +++ b/Tests/RunCMake/cmake_command/cmake_command_invoke_expand_command_name.cmake @@ -0,0 +1,2 @@ +set (my_invoke "INVOKE") +cmake_command (${my_invoke} message "OK!") diff --git a/Tests/RunCMake/cmake_command/cmake_command_invoke_expand_function_name-stderr.txt b/Tests/RunCMake/cmake_command/cmake_command_invoke_expand_function_name-stderr.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_command/cmake_command_invoke_expand_function_name-stderr.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_command/cmake_command_invoke_expand_function_name.cmake b/Tests/RunCMake/cmake_command/cmake_command_invoke_expand_function_name.cmake new file mode 100644 index 0000000..923ddaa --- /dev/null +++ b/Tests/RunCMake/cmake_command/cmake_command_invoke_expand_function_name.cmake @@ -0,0 +1,11 @@ +function(some_function_1) + message(1) +endfunction() + +function(some_function_2) + message(2) +endfunction() + +set(function_version 1) + +cmake_command(INVOKE some_function_${function_version}) diff --git a/Tests/RunCMake/cmake_command/cmake_command_invoke_expanded_command-stderr.txt b/Tests/RunCMake/cmake_command/cmake_command_invoke_expanded_command-stderr.txt new file mode 100644 index 0000000..d640661 --- /dev/null +++ b/Tests/RunCMake/cmake_command/cmake_command_invoke_expanded_command-stderr.txt @@ -0,0 +1 @@ +OK! diff --git a/Tests/RunCMake/cmake_command/cmake_command_invoke_expanded_command.cmake b/Tests/RunCMake/cmake_command/cmake_command_invoke_expanded_command.cmake new file mode 100644 index 0000000..bca7d2f --- /dev/null +++ b/Tests/RunCMake/cmake_command/cmake_command_invoke_expanded_command.cmake @@ -0,0 +1,6 @@ +function (itsok) + message(OK!) +endfunction() + +set (cmd INVOKE itsok) +cmake_command (${cmd}) diff --git a/Tests/RunCMake/cmake_command/cmake_command_invoke_expanded_command_and_arguments-result.txt b/Tests/RunCMake/cmake_command/cmake_command_invoke_expanded_command_and_arguments-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_command/cmake_command_invoke_expanded_command_and_arguments-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_command/cmake_command_invoke_expanded_command_and_arguments-stderr.txt b/Tests/RunCMake/cmake_command/cmake_command_invoke_expanded_command_and_arguments-stderr.txt new file mode 100644 index 0000000..6d0e241 --- /dev/null +++ b/Tests/RunCMake/cmake_command/cmake_command_invoke_expanded_command_and_arguments-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at cmake_command_invoke_expanded_command_and_arguments.cmake:2 \(cmake_command\): + cmake_command called with incorrect number of arguments +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/cmake_command/cmake_command_invoke_expanded_command_and_arguments.cmake b/Tests/RunCMake/cmake_command/cmake_command_invoke_expanded_command_and_arguments.cmake new file mode 100644 index 0000000..6bfa3a7 --- /dev/null +++ b/Tests/RunCMake/cmake_command/cmake_command_invoke_expanded_command_and_arguments.cmake @@ -0,0 +1,2 @@ +set(invoke_message INVOKE message a b) +cmake_command(${invoke_message}) diff --git a/Tests/RunCMake/cmake_command/cmake_command_invoke_expanded_command_with_explicit_argument-stderr.txt b/Tests/RunCMake/cmake_command/cmake_command_invoke_expanded_command_with_explicit_argument-stderr.txt new file mode 100644 index 0000000..d640661 --- /dev/null +++ b/Tests/RunCMake/cmake_command/cmake_command_invoke_expanded_command_with_explicit_argument-stderr.txt @@ -0,0 +1 @@ +OK! diff --git a/Tests/RunCMake/cmake_command/cmake_command_invoke_expanded_command_with_explicit_argument.cmake b/Tests/RunCMake/cmake_command/cmake_command_invoke_expanded_command_with_explicit_argument.cmake new file mode 100644 index 0000000..eb0411f --- /dev/null +++ b/Tests/RunCMake/cmake_command/cmake_command_invoke_expanded_command_with_explicit_argument.cmake @@ -0,0 +1,2 @@ +set (cmd INVOKE message) +cmake_command (${cmd} "OK!") diff --git a/Tests/RunCMake/target_link_options/RunCMakeTest.cmake b/Tests/RunCMake/target_link_options/RunCMakeTest.cmake index 2035eb4..8ef13f9 100644 --- a/Tests/RunCMake/target_link_options/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_link_options/RunCMakeTest.cmake @@ -51,7 +51,7 @@ if (NOT CMAKE_C_COMPILER_ID STREQUAL "Intel") run_cmake_target(genex_DEVICE_LINK private LinkOptions_private --config Release) if (CMake_TEST_CUDA) # Separable compilation is only supported on NVCC. - if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA") + if(NOT CMake_TEST_CUDA STREQUAL "Clang") run_cmake_target(genex_DEVICE_LINK CMP0105_UNSET LinkOptions_CMP0105_UNSET --config Release) run_cmake_target(genex_DEVICE_LINK CMP0105_OLD LinkOptions_CMP0105_OLD --config Release) run_cmake_target(genex_DEVICE_LINK CMP0105_NEW LinkOptions_CMP0105_NEW --config Release) |