diff options
29 files changed, 165 insertions, 95 deletions
diff --git a/Help/envvar/ASM_DIALECTFLAGS.rst b/Help/envvar/ASM_DIALECTFLAGS.rst index 2e1c6d2..2af4b58 100644 --- a/Help/envvar/ASM_DIALECTFLAGS.rst +++ b/Help/envvar/ASM_DIALECTFLAGS.rst @@ -3,13 +3,16 @@ ASM<DIALECT>FLAGS .. include:: ENV_VAR.txt -Default compilation flags to be used when compiling a specific dialect of an -assembly language. ``ASM<DIALECT>FLAGS`` can be ``ASMFLAGS``, ``ASM_NASMFLAGS``, -``ASM_MASMFLAGS`` or ``ASM-ATTFLAGS``. Will only be used by CMake on the -first configuration to determine ``ASM_<DIALECT>`` default compilation -flags, after which the value for ``ASM<DIALECT>FLAGS`` is stored in the cache -as ``CMAKE_ASM<DIALECT>_FLAGS <CMAKE_<LANG>_FLAGS>``. For any configuration -run (including the first), the environment variable will be ignored, if the -``CMAKE_ASM<DIALECT>_FLAGS <CMAKE_<LANG>_FLAGS>`` variable is defined. +Add default compilation flags to be used when compiling a specific dialect +of an assembly language. ``ASM<DIALECT>FLAGS`` can be one of: + +* ``ASMFLAGS`` +* ``ASM_NASMFLAGS`` +* ``ASM_MASMFLAGS`` +* ``ASM-ATTFLAGS`` + +.. |CMAKE_LANG_FLAGS| replace:: :variable:`CMAKE_ASM<DIALECT>_FLAGS <CMAKE_<LANG>_FLAGS>` +.. |LANG| replace:: ``ASM<DIALECT>`` +.. include:: LANG_FLAGS.txt See also :variable:`CMAKE_ASM<DIALECT>_FLAGS_INIT <CMAKE_<LANG>_FLAGS_INIT>`. diff --git a/Help/envvar/CFLAGS.rst b/Help/envvar/CFLAGS.rst index 190b4f4..a6b2452 100644 --- a/Help/envvar/CFLAGS.rst +++ b/Help/envvar/CFLAGS.rst @@ -3,11 +3,10 @@ CFLAGS .. include:: ENV_VAR.txt -Default compilation flags to be used when compiling ``C`` files. Will only be -used by CMake on the first configuration to determine ``CC`` default compilation -flags, after which the value for ``CFLAGS`` is stored in the cache -as :variable:`CMAKE_C_FLAGS <CMAKE_<LANG>_FLAGS>`. For any configuration run -(including the first), the environment variable will be ignored if the -:variable:`CMAKE_C_FLAGS <CMAKE_<LANG>_FLAGS>` variable is defined. +Add default compilation flags to be used when compiling ``C`` files. + +.. |CMAKE_LANG_FLAGS| replace:: :variable:`CMAKE_C_FLAGS <CMAKE_<LANG>_FLAGS>` +.. |LANG| replace:: ``C`` +.. include:: LANG_FLAGS.txt See also :variable:`CMAKE_C_FLAGS_INIT <CMAKE_<LANG>_FLAGS_INIT>`. diff --git a/Help/envvar/CSFLAGS.rst b/Help/envvar/CSFLAGS.rst index 784328a..6e909fe 100644 --- a/Help/envvar/CSFLAGS.rst +++ b/Help/envvar/CSFLAGS.rst @@ -5,11 +5,10 @@ CSFLAGS .. include:: ENV_VAR.txt -Default compilation flags to be used when compiling ``CSharp`` files. Will only be -used by CMake on the first configuration to determine ``CSharp`` default -compilation flags, after which the value for ``CSFLAGS`` is stored in the cache -as :variable:`CMAKE_CSharp_FLAGS <CMAKE_<LANG>_FLAGS>`. For any configuration -run (including the first), the environment variable will be ignored if the -:variable:`CMAKE_CSharp_FLAGS <CMAKE_<LANG>_FLAGS>` variable is defined. +Add default compilation flags to be used when compiling ``CSharp`` files. + +.. |CMAKE_LANG_FLAGS| replace:: :variable:`CMAKE_CSharp_FLAGS <CMAKE_<LANG>_FLAGS>` +.. |LANG| replace:: ``CSharp`` +.. include:: LANG_FLAGS.txt See also :variable:`CMAKE_CSharp_FLAGS_INIT <CMAKE_<LANG>_FLAGS_INIT>`. diff --git a/Help/envvar/CUDAFLAGS.rst b/Help/envvar/CUDAFLAGS.rst index af577a0..46a91df 100644 --- a/Help/envvar/CUDAFLAGS.rst +++ b/Help/envvar/CUDAFLAGS.rst @@ -5,11 +5,10 @@ CUDAFLAGS .. include:: ENV_VAR.txt -Default compilation flags to be used when compiling ``CUDA`` files. Will only be -used by CMake on the first configuration to determine ``CUDA`` default -compilation flags, after which the value for ``CUDAFLAGS`` is stored in the -cache as :variable:`CMAKE_CUDA_FLAGS <CMAKE_<LANG>_FLAGS>`. For any configuration -run (including the first), the environment variable will be ignored if -the :variable:`CMAKE_CUDA_FLAGS <CMAKE_<LANG>_FLAGS>` variable is defined. +Add default compilation flags to be used when compiling ``CUDA`` files. + +.. |CMAKE_LANG_FLAGS| replace:: :variable:`CMAKE_CUDA_FLAGS <CMAKE_<LANG>_FLAGS>` +.. |LANG| replace:: ``CUDA`` +.. include:: LANG_FLAGS.txt See also :variable:`CMAKE_CUDA_FLAGS_INIT <CMAKE_<LANG>_FLAGS_INIT>`. diff --git a/Help/envvar/CXXFLAGS.rst b/Help/envvar/CXXFLAGS.rst index 460a347..f67431f 100644 --- a/Help/envvar/CXXFLAGS.rst +++ b/Help/envvar/CXXFLAGS.rst @@ -3,11 +3,10 @@ CXXFLAGS .. include:: ENV_VAR.txt -Default compilation flags to be used when compiling ``CXX`` (C++) files. Will -only be used by CMake on the first configuration to determine ``CXX`` default -compilation flags, after which the value for ``CXXFLAGS`` is stored in the cache -as :variable:`CMAKE_CXX_FLAGS <CMAKE_<LANG>_FLAGS>`. For any configuration run ( -including the first), the environment variable will be ignored if -the :variable:`CMAKE_CXX_FLAGS <CMAKE_<LANG>_FLAGS>` variable is defined. +Add default compilation flags to be used when compiling ``CXX`` (C++) files. + +.. |CMAKE_LANG_FLAGS| replace:: :variable:`CMAKE_CXX_FLAGS <CMAKE_<LANG>_FLAGS>` +.. |LANG| replace:: ``CXX`` +.. include:: LANG_FLAGS.txt See also :variable:`CMAKE_CXX_FLAGS_INIT <CMAKE_<LANG>_FLAGS_INIT>`. diff --git a/Help/envvar/FFLAGS.rst b/Help/envvar/FFLAGS.rst index 53bffb6..23bc8d2 100644 --- a/Help/envvar/FFLAGS.rst +++ b/Help/envvar/FFLAGS.rst @@ -3,11 +3,10 @@ FFLAGS .. include:: ENV_VAR.txt -Default compilation flags to be used when compiling ``Fortran`` files. Will only -be used by CMake on the first configuration to determine ``Fortran`` default -compilation flags, after which the value for ``FFLAGS`` is stored in the cache -as :variable:`CMAKE_Fortran_FLAGS <CMAKE_<LANG>_FLAGS>`. For any configuration -run (including the first), the environment variable will be ignored if -the :variable:`CMAKE_Fortran_FLAGS <CMAKE_<LANG>_FLAGS>` variable is defined. +Add default compilation flags to be used when compiling ``Fortran`` files. + +.. |CMAKE_LANG_FLAGS| replace:: :variable:`CMAKE_Fortran_FLAGS <CMAKE_<LANG>_FLAGS>` +.. |LANG| replace:: ``Fortran`` +.. include:: LANG_FLAGS.txt See also :variable:`CMAKE_Fortran_FLAGS_INIT <CMAKE_<LANG>_FLAGS_INIT>`. diff --git a/Help/envvar/HIPFLAGS.rst b/Help/envvar/HIPFLAGS.rst index 0df3416..31e2390 100644 --- a/Help/envvar/HIPFLAGS.rst +++ b/Help/envvar/HIPFLAGS.rst @@ -5,11 +5,10 @@ HIPFLAGS .. include:: ENV_VAR.txt -Default compilation flags to be used when compiling ``HIP`` files. Will only be -used by CMake on the first configuration to determine ``HIP`` default -compilation flags, after which the value for ``HIPFLAGS`` is stored in the -cache as :variable:`CMAKE_HIP_FLAGS <CMAKE_<LANG>_FLAGS>`. For any configuration -run (including the first), the environment variable will be ignored if -the :variable:`CMAKE_HIP_FLAGS <CMAKE_<LANG>_FLAGS>` variable is defined. +Add default compilation flags to be used when compiling ``HIP`` files. + +.. |CMAKE_LANG_FLAGS| replace:: :variable:`CMAKE_HIP_FLAGS <CMAKE_<LANG>_FLAGS>` +.. |LANG| replace:: ``HIP`` +.. include:: LANG_FLAGS.txt See also :variable:`CMAKE_HIP_FLAGS_INIT <CMAKE_<LANG>_FLAGS_INIT>`. diff --git a/Help/envvar/ISPCFLAGS.rst b/Help/envvar/ISPCFLAGS.rst index 21df037..b7a2bd5 100644 --- a/Help/envvar/ISPCFLAGS.rst +++ b/Help/envvar/ISPCFLAGS.rst @@ -5,11 +5,10 @@ ISPCFLAGS .. include:: ENV_VAR.txt -Default compilation flags to be used when compiling ``ISPC`` files. Will only be -used by CMake on the first configuration to determine ``ISPC`` default -compilation flags, after which the value for ``ISPCFLAGS`` is stored in the -cache as :variable:`CMAKE_ISPC_FLAGS <CMAKE_<LANG>_FLAGS>`. For any configuration -run (including the first), the environment variable will be ignored if -the :variable:`CMAKE_ISPC_FLAGS <CMAKE_<LANG>_FLAGS>` variable is defined. +Add default compilation flags to be used when compiling ``ISPC`` files. + +.. |CMAKE_LANG_FLAGS| replace:: :variable:`CMAKE_ISPC_FLAGS <CMAKE_<LANG>_FLAGS>` +.. |LANG| replace:: ``ISPC`` +.. include:: LANG_FLAGS.txt See also :variable:`CMAKE_ISPC_FLAGS_INIT <CMAKE_<LANG>_FLAGS_INIT>`. diff --git a/Help/envvar/LANG_FLAGS.txt b/Help/envvar/LANG_FLAGS.txt new file mode 100644 index 0000000..d01a56d --- /dev/null +++ b/Help/envvar/LANG_FLAGS.txt @@ -0,0 +1,6 @@ +CMake uses this environment variable value, in combination with its own +builtin default flags for the toolchain, to initialize and store the +|CMAKE_LANG_FLAGS| cache entry. +This occurs the first time a build tree is configured for language |LANG|. +For any configuration run (including the first), the environment variable +will be ignored if the |CMAKE_LANG_FLAGS| variable is already defined. diff --git a/Help/envvar/RCFLAGS.rst b/Help/envvar/RCFLAGS.rst index bc43cb2..7df83a7 100644 --- a/Help/envvar/RCFLAGS.rst +++ b/Help/envvar/RCFLAGS.rst @@ -3,11 +3,10 @@ RCFLAGS .. include:: ENV_VAR.txt -Default compilation flags to be used when compiling ``resource`` files. Will -only be used by CMake on the first configuration to determine ``resource`` -default compilation flags, after which the value for ``RCFLAGS`` is stored in -the cache as :variable:`CMAKE_RC_FLAGS <CMAKE_<LANG>_FLAGS>`. For any -configuration run (including the first), the environment variable will be ignored -if the :variable:`CMAKE_RC_FLAGS <CMAKE_<LANG>_FLAGS>` variable is defined. +Add default compilation flags to be used when compiling ``RC`` (resource) files. + +.. |CMAKE_LANG_FLAGS| replace:: :variable:`CMAKE_RC_FLAGS <CMAKE_<LANG>_FLAGS>` +.. |LANG| replace:: ``RC`` +.. include:: LANG_FLAGS.txt See also :variable:`CMAKE_RC_FLAGS_INIT <CMAKE_<LANG>_FLAGS_INIT>`. diff --git a/Help/guide/tutorial/Step1/CMakeLists.txt b/Help/guide/tutorial/Step1/CMakeLists.txt index 282951a..6fcce90 100644 --- a/Help/guide/tutorial/Step1/CMakeLists.txt +++ b/Help/guide/tutorial/Step1/CMakeLists.txt @@ -5,7 +5,7 @@ # TODO 7: Set the project version number as 1.0 in the above project command # TODO 6: Set the variable CMAKE_CXX_STANDARD to 11 -# and the variable CMAKE_CXX_REQUIRED_STANDARD to True +# and the variable CMAKE_CXX_STANDARD_REQUIRED to True # TODO 8: Use configure_file to configure and copy TutorialConfig.h.in to # TutorialConfig.h diff --git a/Help/variable/CMAKE_ANDROID_API.rst b/Help/variable/CMAKE_ANDROID_API.rst index 4388bf2..aba9b6e 100644 --- a/Help/variable/CMAKE_ANDROID_API.rst +++ b/Help/variable/CMAKE_ANDROID_API.rst @@ -8,6 +8,7 @@ Edition`, this variable may be set to specify the default value for the :prop_tgt:`ANDROID_API` target property. See that target property for additional information. -Otherwise, when :ref:`Cross Compiling for Android`, this variable provides -the Android API version number targeted. This will be the same value as -the :variable:`CMAKE_SYSTEM_VERSION` variable for ``Android`` platforms. +When :ref:`Cross Compiling for Android`, the :variable:`CMAKE_SYSTEM_VERSION` +variable represents the Android API version number targeted. For historical +reasons, if a toolchain file sets ``CMAKE_ANDROID_API``, but not +``CMAKE_SYSTEM_VERSION``, the latter will be initialized using the former. diff --git a/Help/variable/CMAKE_LANG_FLAGS.rst b/Help/variable/CMAKE_LANG_FLAGS.rst index 2784397..4b39b1d 100644 --- a/Help/variable/CMAKE_LANG_FLAGS.rst +++ b/Help/variable/CMAKE_LANG_FLAGS.rst @@ -5,7 +5,9 @@ Flags for all build types. ``<LANG>`` flags used regardless of the value of :variable:`CMAKE_BUILD_TYPE`. -This is initialized for each language from environment variables: +For each language, if this variable is not defined, it is initialized +and stored in the cache using values from environment variables in +combination with CMake's builtin defaults for the toolchain: * ``CMAKE_C_FLAGS``: Initialized by the :envvar:`CFLAGS` environment variable. @@ -15,6 +17,12 @@ This is initialized for each language from environment variables: Initialized by the :envvar:`CUDAFLAGS` environment variable. * ``CMAKE_Fortran_FLAGS``: Initialized by the :envvar:`FFLAGS` environment variable. +* ``CMAKE_CSharp_FLAGS``: + Initialized by the :envvar:`CSFLAGS` environment variable. +* ``CMAKE_HIP_FLAGS``: + Initialized by the :envvar:`HIPFLAGS` environment variable. +* ``CMAKE_ISPC_FLAGS``: + Initialized by the :envvar:`ISPCFLAGS` environment variable. This value is a command-line string fragment. Therefore, multiple options should be separated by spaces, and options with spaces should be quoted. diff --git a/Modules/CMakeTestCUDACompiler.cmake b/Modules/CMakeTestCUDACompiler.cmake index a89182b..f2fa6ea 100644 --- a/Modules/CMakeTestCUDACompiler.cmake +++ b/Modules/CMakeTestCUDACompiler.cmake @@ -127,8 +127,10 @@ list(REMOVE_ITEM CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES ${CMAKE_CUDA_IMPLICIT_LINK_L if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA") # Remove the CUDA Toolkit include directories from the set of # implicit system include directories. - # CMake will explicitly mark these as SYSTEM to NVCC since it implicitly - # adds them as user includes and not system + # This resolves the issue that NVCC doesn't specify these + # includes as SYSTEM includes when compiling device code, and sometimes + # they contain headers that generate warnings, so let users mark them + # as SYSTEM explicitly if(CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES) list(REMOVE_ITEM CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES} diff --git a/Modules/FindJNI.cmake b/Modules/FindJNI.cmake index e93b91e..64163b0 100644 --- a/Modules/FindJNI.cmake +++ b/Modules/FindJNI.cmake @@ -107,7 +107,7 @@ include(FindPackageHandleStandardArgs) if(NOT JNI_FIND_COMPONENTS) if(ANDROID) - if(CMAKE_ANDROID_API LESS 31) + if(CMAKE_SYSTEM_VERSION LESS 31) # There are no components for Android NDK set(JNI_FIND_COMPONENTS) else() @@ -125,7 +125,7 @@ else() # On Android, if JVM was requested we need to find NativeHelper as well which # is an implicit dependency of JVM allowing to provide uniform access to basic # JVM/DVM functionality. - if(ANDROID AND CMAKE_ANDROID_API GREATER_EQUAL 31 AND JVM IN_LIST JNI_FIND_COMPONENTS) + if(ANDROID AND CMAKE_SYSTEM_VERSION GREATER_EQUAL 31 AND JVM IN_LIST JNI_FIND_COMPONENTS) if(NOT NativeHelper IN_LIST JNI_FIND_COMPONENTS) list(APPEND JNI_FIND_COMPONENTS NativeHelper) # NativeHelper is required only if JVM was requested as such. diff --git a/Modules/Platform/Android.cmake b/Modules/Platform/Android.cmake index 6944e32..09a12cc 100644 --- a/Modules/Platform/Android.cmake +++ b/Modules/Platform/Android.cmake @@ -13,6 +13,12 @@ if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Android") return() endif() +# NDK organizes API level specific libraries in numbered subdirectories. To +# avoid incorrect inclusion of libraries below the targeted API level, disable +# architecture specific path suffixes by default. +set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS OFF) +set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS OFF) + # Conventionally Android does not use versioned soname # But in modern versions it is acceptable if(NOT DEFINED CMAKE_PLATFORM_NO_VERSIONED_SONAME) diff --git a/Modules/Platform/SerenityOS.cmake b/Modules/Platform/SerenityOS.cmake index 541620c..dc4f369 100644 --- a/Modules/Platform/SerenityOS.cmake +++ b/Modules/Platform/SerenityOS.cmake @@ -1,7 +1,7 @@ set(SERENITYOS 1) -set(CMAKE_DL_LIBS "-ldl") +set(CMAKE_DL_LIBS "") set(CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN "\$ORIGIN") set(CMAKE_SHARED_LIBRARY_SUFFIX ".so") diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 588f44a..867f984 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -630,6 +630,12 @@ bool cmCoreTryCompile::TryCompileCode(Arguments& arguments, fprintf(fout, "cmake_policy(SET CMP0126 OLD)\n"); } + /* Set language extensions policy to match outer project. */ + if (this->Makefile->GetPolicyStatus(cmPolicies::CMP0128) != + cmPolicies::NEW) { + fprintf(fout, "cmake_policy(SET CMP0128 OLD)\n"); + } + std::string projectLangs; for (std::string const& li : testLangs) { projectLangs += " " + li; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 6962b52..c2bf888 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1855,15 +1855,6 @@ void cmGlobalGenerator::FinalizeTargetConfiguration() cmExpandedList(standardIncludesStr); standardIncludesSet.insert(standardIncludesVec.begin(), standardIncludesVec.end()); - if (li == "CUDA") { - std::string const& cudaSystemIncludeVar = - mf->GetSafeDefinition("CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES"); - std::vector<std::string> cudaToolkitIncludeVec = - cmExpandedList(cudaSystemIncludeVar); - standardIncludesSet.insert(cudaToolkitIncludeVec.begin(), - cudaToolkitIncludeVec.end()); - mf->AddIncludeDirectories(cudaToolkitIncludeVec); - } } mf->AddSystemIncludeDirectories(standardIncludesSet); } diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx index 6883535..299ab3a 100644 --- a/Source/cmOutputConverter.cxx +++ b/Source/cmOutputConverter.cxx @@ -527,6 +527,13 @@ bool cmOutputConverter::Shell_ArgumentNeedsQuotes(cm::string_view in, } } + /* UNC paths in MinGW Makefiles need quotes. */ + if ((flags & Shell_Flag_MinGWMake) && (flags & Shell_Flag_Make)) { + if (in.size() > 1 && in[0] == '\\' && in[1] == '\\') { + return true; + } + } + return false; } diff --git a/Tests/CudaOnly/CMakeLists.txt b/Tests/CudaOnly/CMakeLists.txt index d23e929..091872d 100644 --- a/Tests/CudaOnly/CMakeLists.txt +++ b/Tests/CudaOnly/CMakeLists.txt @@ -27,12 +27,10 @@ if(CMake_TEST_CUDA AND NOT CMake_TEST_CUDA STREQUAL "Clang") add_cuda_test_macro(CudaOnly.GPUDebugFlag CudaOnlyGPUDebugFlag) endif() +# The CUDA only ships the shared version of the toolkit libraries +# on windows if(NOT WIN32) - # The CUDA only ships the shared version of the toolkit libraries - # on windows add_cuda_test_macro(CudaOnly.StaticRuntimePlusToolkit CudaOnlyStaticRuntimePlusToolkit) - # `isystem` behaves differently on windows with nvcc - add_cuda_test_macro(CudaOnly.ToolkitIsSystemInclude CudaOnlySystemInclude) endif() add_cuda_test_macro(CudaOnly.DeviceLTO CudaOnlyDeviceLTO) diff --git a/Tests/CudaOnly/ToolkitIsSystemInclude/CMakeLists.txt b/Tests/CudaOnly/ToolkitIsSystemInclude/CMakeLists.txt deleted file mode 100644 index bc347dd..0000000 --- a/Tests/CudaOnly/ToolkitIsSystemInclude/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.24) -project(ToolkitIsSystemInclude CUDA) - -# Verify that the nvrtc.h that is inside `CMAKE_CURRENT_SOURCE_DIR` is still -# the first include for `.cu` files. -add_executable(CudaOnlySystemInclude main.cu) -target_include_directories(CudaOnlySystemInclude SYSTEM PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) diff --git a/Tests/CudaOnly/ToolkitIsSystemInclude/include/nvrtc.h b/Tests/CudaOnly/ToolkitIsSystemInclude/include/nvrtc.h deleted file mode 100644 index 5a015c4..0000000 --- a/Tests/CudaOnly/ToolkitIsSystemInclude/include/nvrtc.h +++ /dev/null @@ -1,5 +0,0 @@ -#define CMAKE_CUDA_TOOLKIT_IS_SYSTEM 1 - -int main() -{ -} diff --git a/Tests/CudaOnly/ToolkitIsSystemInclude/main.cu b/Tests/CudaOnly/ToolkitIsSystemInclude/main.cu deleted file mode 100644 index 6cff8a1..0000000 --- a/Tests/CudaOnly/ToolkitIsSystemInclude/main.cu +++ /dev/null @@ -1,4 +0,0 @@ -#include "nvrtc.h" -#ifndef CMAKE_CUDA_TOOLKIT_IS_SYSTEM -# error "Failed to specify the CUDA Toolkit includes as system" -#endif diff --git a/Tests/RunCMake/try_compile/CMP0128-NEW.cmake b/Tests/RunCMake/try_compile/CMP0128-NEW.cmake new file mode 100644 index 0000000..20e389a --- /dev/null +++ b/Tests/RunCMake/try_compile/CMP0128-NEW.cmake @@ -0,0 +1,7 @@ +cmake_policy(SET CMP0128 NEW) +set(check_cxx_std " +#if __cplusplus > 199711L && __cplusplus <= 201103L +# error Compiler is incorrectly in C++11 mode. +#endif +") +include(CMP0128-common.cmake) diff --git a/Tests/RunCMake/try_compile/CMP0128-WARN.cmake b/Tests/RunCMake/try_compile/CMP0128-WARN.cmake new file mode 100644 index 0000000..266bd22 --- /dev/null +++ b/Tests/RunCMake/try_compile/CMP0128-WARN.cmake @@ -0,0 +1,7 @@ + +set(check_cxx_std " +#if __cplusplus <= 199711L || __cplusplus > 201103L +# error Compiler is incorrectly not in C++11 mode. +#endif +") +include(CMP0128-common.cmake) diff --git a/Tests/RunCMake/try_compile/CMP0128-common.cmake b/Tests/RunCMake/try_compile/CMP0128-common.cmake new file mode 100644 index 0000000..0b8a12b --- /dev/null +++ b/Tests/RunCMake/try_compile/CMP0128-common.cmake @@ -0,0 +1,31 @@ +cmake_policy(SET CMP0067 NEW) +enable_language(CXX) + +# Isolate the one try_compile below in the error log. +set(CMakeError_log "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log") +file(REMOVE "${CMakeError_log}") + +# Add our own -std= flag to the try_compile check. +set(CMAKE_REQUIRED_FLAGS -std=c++11) + +# Tell CMP0128 NEW behavior to append a -std= flag (after ours). +if(CMAKE_CXX_EXTENSIONS_DEFAULT) + set(CMAKE_CXX_EXTENSIONS OFF) +else() + set(CMAKE_CXX_EXTENSIONS ON) +endif() + +include(CheckSourceCompiles) +check_source_compiles(CXX " +${check_cxx_std} +int main() +{ + return 0; +} +" SRC_COMPILED) +if(NOT SRC_COMPILED) + if(EXISTS "${CMakeError_log}") + file(READ "${CMakeError_log}" err_log) + endif() + message("${err_log}") +endif() diff --git a/Tests/RunCMake/try_compile/Inspect.cmake b/Tests/RunCMake/try_compile/Inspect.cmake new file mode 100644 index 0000000..added41 --- /dev/null +++ b/Tests/RunCMake/try_compile/Inspect.cmake @@ -0,0 +1,4 @@ +enable_language(CXX) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/info.cmake" " +set(CMAKE_CXX_EXTENSIONS_DEFAULT \"${CMAKE_CXX_EXTENSIONS_DEFAULT}\") +") diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake index d63624c..a3a3451 100644 --- a/Tests/RunCMake/try_compile/RunCMakeTest.cmake +++ b/Tests/RunCMake/try_compile/RunCMakeTest.cmake @@ -88,6 +88,23 @@ if(RunCMake_GENERATOR MATCHES "Make|Ninja") unset(RunCMake_TEST_NO_CLEAN) endif() +# Lookup CMAKE_CXX_EXTENSIONS_DEFAULT. +# FIXME: Someday we could move this to the top of the file and use it in +# place of some of the values passed by 'Tests/RunCMake/CMakeLists.txt'. +run_cmake(Inspect) +include("${RunCMake_BINARY_DIR}/Inspect-build/info.cmake") + +# FIXME: Support more compilers and default standard levels. +if (CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|AppleClang)$" + AND DEFINED CMAKE_CXX_STANDARD_DEFAULT + AND DEFINED CMAKE_CXX_EXTENSIONS_DEFAULT + ) + run_cmake(CMP0128-WARN) + if(NOT CMAKE_CXX_STANDARD_DEFAULT EQUAL 11) + run_cmake(CMP0128-NEW) + endif() +endif() + if(UNIX) run_cmake(CleanupNoFollowSymlink) endif() |