summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/policy/CMP0104.rst25
-rw-r--r--Help/prop_tgt/CUDA_ARCHITECTURES.rst10
-rw-r--r--Modules/CMakeDetermineCUDACompiler.cmake2
-rw-r--r--Modules/Compiler/Clang.cmake9
-rw-r--r--Source/cmFindProgramCommand.cxx2
-rw-r--r--Source/cmGeneratorTarget.cxx51
-rw-r--r--Tests/CudaOnly/Architecture/CMakeLists.txt14
-rw-r--r--Tests/RunCMake/CMP0104/CMP0104-OFF.cmake3
-rw-r--r--Tests/RunCMake/CMP0104/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/find_program/ExeNoRead-stdout.txt2
-rw-r--r--Tests/RunCMake/find_program/RunCMakeTest.cmake12
11 files changed, 100 insertions, 31 deletions
diff --git a/Help/policy/CMP0104.rst b/Help/policy/CMP0104.rst
index ca2c571..8516716 100644
--- a/Help/policy/CMP0104.rst
+++ b/Help/policy/CMP0104.rst
@@ -23,9 +23,34 @@ The ``NEW`` behavior of this policy is to initialize
:variable:`CMAKE_CUDA_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` is ``NVIDIA``
and raise an error if :prop_tgt:`CUDA_ARCHITECTURES` is empty during generation.
+If :prop_tgt:`CUDA_ARCHITECTURES` is set to a false value no architectures
+flags are passed to the compiler. This is intended to support packagers and
+the rare cases where full control over the passed flags is required.
+
This policy was introduced in CMake version 3.18. CMake version
|release| warns when the policy is not set and uses ``OLD`` behavior.
Use the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW``
explicitly.
.. include:: DEPRECATED.txt
+
+Examples
+^^^^^^^^
+
+.. code-block:: cmake
+
+ set_property(TARGET tgt PROPERTY CUDA_ARCHITECTURES 35 50 72)
+
+Generates code for real and virtual architectures ``30``, ``50`` and ``72``.
+
+.. code-block:: cmake
+
+ set_property(TARGET tgt PROPERTY CUDA_ARCHITECTURES 70-real 72-virtual)
+
+Generates code for real architecture ``70`` and virtual architecture ``72``.
+
+.. code-block:: cmake
+
+ set_property(TARGET tgt PROPERTY CUDA_ARCHITECTURES OFF)
+
+CMake will not pass any architecture flags to the compiler.
diff --git a/Help/prop_tgt/CUDA_ARCHITECTURES.rst b/Help/prop_tgt/CUDA_ARCHITECTURES.rst
index 328f40b..bae3c6f 100644
--- a/Help/prop_tgt/CUDA_ARCHITECTURES.rst
+++ b/Help/prop_tgt/CUDA_ARCHITECTURES.rst
@@ -8,6 +8,10 @@ the kind of architecture to generate code for.
If no suffix is given then code is generated for both real and virtual
architectures.
+A non-empty false value (e.g. ``OFF``) disables adding architectures.
+This is intended to support packagers and rare cases where full control
+over the passed flags is required.
+
This property is initialized by the value of the :variable:`CMAKE_CUDA_ARCHITECTURES`
variable if it is set when a target is created.
@@ -28,3 +32,9 @@ Generates code for real and virtual architectures ``30``, ``50`` and ``72``.
set_property(TARGET tgt PROPERTY CUDA_ARCHITECTURES 70-real 72-virtual)
Generates code for real architecture ``70`` and virtual architecture ``72``.
+
+.. code-block:: cmake
+
+ set_property(TARGET tgt PROPERTY CUDA_ARCHITECTURES OFF)
+
+CMake will not pass any architecture flags to the compiler.
diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake
index 9dcebe8..a0f7202 100644
--- a/Modules/CMakeDetermineCUDACompiler.cmake
+++ b/Modules/CMakeDetermineCUDACompiler.cmake
@@ -525,7 +525,7 @@ endif()
# If the user didn't set the architectures, then set them to a default.
# If the user did, then make sure those architectures worked.
-if(DEFINED detected_architecture)
+if(DEFINED detected_architecture AND "${CMAKE_CUDA_ARCHITECTURES}" STREQUAL "")
set(CMAKE_CUDA_ARCHITECTURES "${detected_architecture}" CACHE STRING "CUDA architectures")
if(NOT CMAKE_CUDA_ARCHITECTURES)
diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake
index cd47aa6..bb516d3 100644
--- a/Modules/Compiler/Clang.cmake
+++ b/Modules/Compiler/Clang.cmake
@@ -146,7 +146,14 @@ macro(__compiler_clang_cxx_standards lang)
set(CMAKE_${lang}17_EXTENSION_COMPILE_OPTION "-std=gnu++1z")
endif()
- if (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS "${_clang_version_std17}")
+ if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 6.0)
+ set(CMAKE_${lang}17_STANDARD__HAS_FULL_SUPPORT ON)
+ endif()
+
+ if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 11.0)
+ set(CMAKE_${lang}20_STANDARD_COMPILE_OPTION "-std=c++20")
+ set(CMAKE_${lang}20_EXTENSION_COMPILE_OPTION "-std=gnu++20")
+ elseif(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS "${_clang_version_std17}")
set(CMAKE_${lang}20_STANDARD_COMPILE_OPTION "-std=c++2a")
set(CMAKE_${lang}20_EXTENSION_COMPILE_OPTION "-std=gnu++2a")
endif()
diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx
index 599b1d2..4b88bea 100644
--- a/Source/cmFindProgramCommand.cxx
+++ b/Source/cmFindProgramCommand.cxx
@@ -85,7 +85,7 @@ struct cmFindProgramHelper
this->TestNameExt = cmStrCat(name, ext);
this->TestPath =
cmSystemTools::CollapseFullPath(this->TestNameExt, path);
- bool exists = cmSystemTools::FileIsExecutable(this->TestPath);
+ bool exists = cmSystemTools::FileExists(this->TestPath, true);
exists ? this->DebugSearches.FoundAt(this->TestPath)
: this->DebugSearches.FailedAt(this->TestPath);
if (exists) {
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 31da69b..f2011ee 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -3045,6 +3045,34 @@ void cmGeneratorTarget::GetAppleArchs(const std::string& config,
void cmGeneratorTarget::AddCUDAArchitectureFlags(std::string& flags) const
{
+ const std::string& property = this->GetSafeProperty("CUDA_ARCHITECTURES");
+
+ if (property.empty()) {
+ switch (this->GetPolicyStatusCMP0104()) {
+ case cmPolicies::WARN:
+ if (!this->LocalGenerator->GetCMakeInstance()->GetIsInTryCompile()) {
+ this->Makefile->IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ cmPolicies::GetPolicyWarning(cmPolicies::CMP0104) +
+ "\nCUDA_ARCHITECTURES is empty for target \"" + this->GetName() +
+ "\".");
+ }
+ CM_FALLTHROUGH;
+ case cmPolicies::OLD:
+ break;
+ default:
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ "CUDA_ARCHITECTURES is empty for target \"" + this->GetName() +
+ "\".");
+ }
+ }
+
+ // If CUDA_ARCHITECTURES is false we don't add any architectures.
+ if (cmIsOff(property)) {
+ return;
+ }
+
struct CudaArchitecture
{
std::string name;
@@ -3055,28 +3083,7 @@ void cmGeneratorTarget::AddCUDAArchitectureFlags(std::string& flags) const
{
std::vector<std::string> options;
- cmExpandList(this->GetSafeProperty("CUDA_ARCHITECTURES"), options);
-
- if (options.empty()) {
- switch (this->GetPolicyStatusCMP0104()) {
- case cmPolicies::WARN:
- if (!this->LocalGenerator->GetCMakeInstance()->GetIsInTryCompile()) {
- this->Makefile->IssueMessage(
- MessageType::AUTHOR_WARNING,
- cmPolicies::GetPolicyWarning(cmPolicies::CMP0104) +
- "\nCUDA_ARCHITECTURES is empty for target \"" +
- this->GetName() + "\".");
- }
- CM_FALLTHROUGH;
- case cmPolicies::OLD:
- break;
- default:
- this->Makefile->IssueMessage(
- MessageType::FATAL_ERROR,
- "CUDA_ARCHITECTURES is empty for target \"" + this->GetName() +
- "\".");
- }
- }
+ cmExpandList(property, options);
for (std::string& option : options) {
CudaArchitecture architecture;
diff --git a/Tests/CudaOnly/Architecture/CMakeLists.txt b/Tests/CudaOnly/Architecture/CMakeLists.txt
index 7270b56..03e972f 100644
--- a/Tests/CudaOnly/Architecture/CMakeLists.txt
+++ b/Tests/CudaOnly/Architecture/CMakeLists.txt
@@ -1,5 +1,15 @@
-cmake_minimum_required(VERSION 3.17)
+cmake_minimum_required(VERSION 3.18)
project(Architecture CUDA)
-set(CMAKE_CUDA_ARCHITECTURES 52)
add_executable(Architecture main.cu)
+set_property(TARGET Architecture PROPERTY CUDA_ARCHITECTURES 52)
+
+# Make sure CMake doesn't pass architectures if CUDA_ARCHITECTURES is OFF.
+if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
+ set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -arch=sm_52")
+elseif(CMAKE_CUDA_COMPILER_ID STREQUAL "Clang")
+ set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --cuda-gpu-arch=sm_52")
+endif()
+
+add_executable(ArchitectureOff main.cu)
+set_property(TARGET ArchitectureOff PROPERTY CUDA_ARCHITECTURES OFF)
diff --git a/Tests/RunCMake/CMP0104/CMP0104-OFF.cmake b/Tests/RunCMake/CMP0104/CMP0104-OFF.cmake
new file mode 100644
index 0000000..f3b6682
--- /dev/null
+++ b/Tests/RunCMake/CMP0104/CMP0104-OFF.cmake
@@ -0,0 +1,3 @@
+include(CMP0104-Common.cmake)
+
+set_property(TARGET cuda PROPERTY CUDA_ARCHITECTURES OFF)
diff --git a/Tests/RunCMake/CMP0104/RunCMakeTest.cmake b/Tests/RunCMake/CMP0104/RunCMakeTest.cmake
index bc8e1b1..b26f72a 100644
--- a/Tests/RunCMake/CMP0104/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CMP0104/RunCMakeTest.cmake
@@ -2,4 +2,5 @@ include(RunCMake)
run_cmake(CMP0104-OLD)
run_cmake(CMP0104-NEW)
+run_cmake(CMP0104-OFF)
run_cmake(CMP0104-WARN)
diff --git a/Tests/RunCMake/find_program/ExeNoRead-stdout.txt b/Tests/RunCMake/find_program/ExeNoRead-stdout.txt
index 35a83f2..f231178 100644
--- a/Tests/RunCMake/find_program/ExeNoRead-stdout.txt
+++ b/Tests/RunCMake/find_program/ExeNoRead-stdout.txt
@@ -1 +1 @@
--- ExeNoRead_EXECUTABLE='.*/Tests/RunCMake/find_program/ExeNoRead-build/ExeNoRead'
+-- ExeNoRead_EXECUTABLE='ExeNoRead_EXECUTABLE-NOTFOUND'
diff --git a/Tests/RunCMake/find_program/RunCMakeTest.cmake b/Tests/RunCMake/find_program/RunCMakeTest.cmake
index 95ffd84..2bb777b 100644
--- a/Tests/RunCMake/find_program/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_program/RunCMakeTest.cmake
@@ -9,8 +9,14 @@ run_cmake(Required)
if(CMAKE_SYSTEM_NAME MATCHES "^(Windows|CYGWIN)$")
run_cmake(WindowsCom)
run_cmake(WindowsExe)
-endif()
+else()
+ # test non readable file only if not root
+ execute_process(
+ COMMAND id -u $ENV{USER}
+ OUTPUT_VARIABLE uid
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
-if(UNIX)
- run_cmake(ExeNoRead)
+ if(NOT "${uid}" STREQUAL "0")
+ run_cmake(ExeNoRead)
+ endif()
endif()