diff options
45 files changed, 237 insertions, 402 deletions
diff --git a/Help/release/3.20.rst b/Help/release/3.20.rst index da27174..42e95be 100644 --- a/Help/release/3.20.rst +++ b/Help/release/3.20.rst @@ -363,8 +363,8 @@ Changes made since CMake 3.20.0 include the following. The oneAPI 2021.2 Fortran compiler defines the proper identification macro and so is identified as ``IntelLLVM`` by all CMake 3.20 versions. -3.20.3, 3.20.4, 3.20.5 ----------------------- +3.20.3, 3.20.4, 3.20.5, 3.20.6 +------------------------------ These versions made no changes to documented features or interfaces. Some implementation updates were made to support ecosystem changes diff --git a/Help/release/3.21.rst b/Help/release/3.21.rst index 5d8c200..a468817 100644 --- a/Help/release/3.21.rst +++ b/Help/release/3.21.rst @@ -319,3 +319,13 @@ Changes made since CMake 3.21.0 include the following. * The :generator:`Visual Studio 17 2022` generator is now based on "Visual Studio 2022 Preview 4". Previously it was based on "Preview 3.1". + +* The AMD ROCm Platform ``hipcc`` compiler was identifed by CMake 3.21.0 + through 3.21.2 as a distinct compiler with id ``ROCMClang``. This has + been removed because it caused regressions. Instead: + + * ``hipcc`` may no longer be used as a ``HIP`` compiler because it + interferes with flags CMake needs to pass to Clang. Use Clang directly. + + * ``hipcc`` may once again be used as a ``CXX`` compiler, and is treated as + whatever compiler it selects underneath, as CMake 3.20 and below did. diff --git a/Help/variable/CMAKE_HIP_ARCHITECTURES.rst b/Help/variable/CMAKE_HIP_ARCHITECTURES.rst index 0cf0201..bcc6b35 100644 --- a/Help/variable/CMAKE_HIP_ARCHITECTURES.rst +++ b/Help/variable/CMAKE_HIP_ARCHITECTURES.rst @@ -5,7 +5,8 @@ CMAKE_HIP_ARCHITECTURES Default value for :prop_tgt:`HIP_ARCHITECTURES` property of targets. -This is initialized to the default architecture chosen by the compiler. +This is initialized to the architectures reported by ``rocm_agent_enumerator``, +if available, and otherwise to the default chosen by the compiler. This variable is used to initialize the :prop_tgt:`HIP_ARCHITECTURES` property on all targets. See the target property for additional information. diff --git a/Help/variable/CMAKE_LANG_COMPILER_ID.rst b/Help/variable/CMAKE_LANG_COMPILER_ID.rst index f23b7a2..0abedde 100644 --- a/Help/variable/CMAKE_LANG_COMPILER_ID.rst +++ b/Help/variable/CMAKE_LANG_COMPILER_ID.rst @@ -34,7 +34,6 @@ include: OpenWatcom = Open Watcom (openwatcom.org) PGI = The Portland Group (pgroup.com) PathScale = PathScale (pathscale.com) - ROCMClang = ROCm Toolkit Clang-based Compiler (rocmdocs.amd.com) SDCC = Small Device C Compiler (sdcc.sourceforge.net) SunPro = Oracle Solaris Studio (oracle.com) TI = Texas Instruments (ti.com) diff --git a/Modules/CMakeCompilerIdDetection.cmake b/Modules/CMakeCompilerIdDetection.cmake index dd70d82..e6b3ee3 100644 --- a/Modules/CMakeCompilerIdDetection.cmake +++ b/Modules/CMakeCompilerIdDetection.cmake @@ -82,9 +82,6 @@ function(compiler_id_detection outvar lang) AppleClang ARMClang ) - if(NOT __skip_rocmclang) - list(APPEND ordered_compilers ROCMClang) - endif() list(APPEND ordered_compilers Clang GNU diff --git a/Modules/CMakeDetermineCompiler.cmake b/Modules/CMakeDetermineCompiler.cmake index 6430793..c967ab7 100644 --- a/Modules/CMakeDetermineCompiler.cmake +++ b/Modules/CMakeDetermineCompiler.cmake @@ -32,7 +32,7 @@ macro(_cmake_find_compiler lang) endif() # Look for directories containing compilers of reference languages. - set(_${lang}_COMPILER_HINTS) + set(_${lang}_COMPILER_HINTS "${CMAKE_${lang}_COMPILER_HINTS}") foreach(l ${_languages}) if(CMAKE_${l}_COMPILER AND IS_ABSOLUTE "${CMAKE_${l}_COMPILER}") get_filename_component(_hint "${CMAKE_${l}_COMPILER}" PATH) diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 16243c7..d54e2b0 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -150,41 +150,6 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) endif() endif() - # When invoked with HIPCC we need to extract the path to the underlying - # clang compiler when possible. This fixes the following issues: - # env variables can change how hipcc behaves - # allows us to properly find the binutils bundled with hip - if(CMAKE_${lang}_COMPILER_ID STREQUAL "ROCMClang" - AND CMAKE_${lang}_COMPILER MATCHES ".*hipcc") - get_filename_component(_hipcc_dir "${CMAKE_${lang}_COMPILER}" DIRECTORY) - execute_process( - COMMAND "${_hipcc_dir}/hipconfig" - --hipclangpath - OUTPUT_VARIABLE output - RESULT_VARIABLE result - ) - if(result EQUAL 0 AND EXISTS "${output}") - if(lang STREQUAL "C") - set_property(CACHE CMAKE_${lang}_COMPILER PROPERTY VALUE "${output}/clang") - set(CMAKE_${lang}_COMPILER "${output}/clang" PARENT_SCOPE) - else() - set_property(CACHE CMAKE_${lang}_COMPILER PROPERTY VALUE "${output}/clang++") - set(CMAKE_${lang}_COMPILER "${output}/clang++" PARENT_SCOPE) - endif() - endif() - if(lang STREQUAL "HIP") - execute_process( - COMMAND "${_hipcc_dir}/hipconfig" - --rocmpath - OUTPUT_VARIABLE output - RESULT_VARIABLE result - ) - if(result EQUAL 0) - set(_CMAKE_HIP_COMPILER_ROCM_ROOT "${output}" PARENT_SCOPE) - endif() - endif() - endif() - if (COMPILER_QNXNTO AND CMAKE_${lang}_COMPILER_ID STREQUAL "GNU") execute_process( COMMAND "${CMAKE_${lang}_COMPILER}" diff --git a/Modules/CMakeDetermineHIPCompiler.cmake b/Modules/CMakeDetermineHIPCompiler.cmake index ed0110a..7b7d7a3 100644 --- a/Modules/CMakeDetermineHIPCompiler.cmake +++ b/Modules/CMakeDetermineHIPCompiler.cmake @@ -15,6 +15,13 @@ if(NOT CMAKE_HIP_COMPILER) # prefer the environment variable HIPCXX if(NOT $ENV{HIPCXX} STREQUAL "") + if("$ENV{HIPCXX}" MATCHES "hipcc") + message(FATAL_ERROR + "The HIPCXX environment variable is set to the hipcc wrapper:\n" + " $ENV{HIPCXX}\n" + "This is not supported. Use Clang directly, or let CMake pick a default." + ) + endif() get_filename_component(CMAKE_HIP_COMPILER_INIT $ENV{HIPCXX} PROGRAM PROGRAM_ARGS CMAKE_HIP_FLAGS_ENV_INIT) if(CMAKE_HIP_FLAGS_ENV_INIT) set(CMAKE_HIP_COMPILER_ARG1 "${CMAKE_HIP_FLAGS_ENV_INIT}" CACHE STRING "Arguments to CXX compiler") @@ -26,10 +33,25 @@ if(NOT CMAKE_HIP_COMPILER) # finally list compilers to try if(NOT CMAKE_HIP_COMPILER_INIT) - set(CMAKE_HIP_COMPILER_LIST hipcc clang++) + set(CMAKE_HIP_COMPILER_LIST clang++) + + # Look for the Clang coming with ROCm to support HIP. + execute_process(COMMAND hipconfig --hipclangpath + OUTPUT_VARIABLE _CMAKE_HIPCONFIG_CLANGPATH + RESULT_VARIABLE _CMAKE_HIPCONFIG_RESULT + ) + if(_CMAKE_HIPCONFIG_RESULT EQUAL 0 AND EXISTS "${_CMAKE_HIPCONFIG_CLANGPATH}") + set(CMAKE_HIP_COMPILER_HINTS "${_CMAKE_HIPCONFIG_CLANGPATH}") + endif() endif() _cmake_find_compiler(HIP) +elseif(CMAKE_HIP_COMPILER MATCHES "hipcc") + message(FATAL_ERROR + "CMAKE_HIP_COMPILER is set to the hipcc wrapper:\n" + " ${CMAKE_HIP_COMPILER}\n" + "This is not supported. Use Clang directly, or let CMake pick a default." + ) else() _cmake_find_compiler_path(HIP) endif() @@ -52,7 +74,40 @@ if(NOT CMAKE_HIP_COMPILER_ID_RUN) CMAKE_DETERMINE_COMPILER_ID(HIP HIPFLAGS CMakeHIPCompilerId.hip) _cmake_find_compiler_sysroot(HIP) +endif() +if(NOT CMAKE_HIP_COMPILER_ROCM_ROOT AND CMAKE_HIP_COMPILER_ID STREQUAL "Clang") + execute_process(COMMAND "${CMAKE_HIP_COMPILER}" -v -print-targets + OUTPUT_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE _CMAKE_HIP_COMPILER_RESULT + OUTPUT_VARIABLE _CMAKE_HIP_COMPILER_STDOUT + ERROR_VARIABLE _CMAKE_HIP_COMPILER_STDERR + ) + + if(_CMAKE_HIP_COMPILER_RESULT EQUAL 0 AND _CMAKE_HIP_COMPILER_STDERR MATCHES "Found HIP installation: *([^,]*)[,\n]") + set(CMAKE_HIP_COMPILER_ROCM_ROOT "${CMAKE_MATCH_1}") + endif() +endif() +if(NOT CMAKE_HIP_COMPILER_ROCM_ROOT) + execute_process( + COMMAND hipconfig --rocmpath + OUTPUT_VARIABLE _CMAKE_HIPCONFIG_ROCMPATH + RESULT_VARIABLE _CMAKE_HIPCONFIG_RESULT + ) + if(_CMAKE_HIPCONFIG_RESULT EQUAL 0 AND EXISTS "${_CMAKE_HIPCONFIG_ROCMPATH}") + set(CMAKE_HIP_COMPILER_ROCM_ROOT "${_CMAKE_HIPCONFIG_ROCMPATH}") + endif() +endif() +if(NOT CMAKE_HIP_COMPILER_ROCM_ROOT) + message(FATAL_ERROR "Failed to find ROCm root directory.") +endif() +if(NOT EXISTS "${CMAKE_HIP_COMPILER_ROCM_ROOT}/lib/cmake/hip-lang/hip-lang-config.cmake") + message(FATAL_ERROR + "The ROCm root directory:\n" + " ${CMAKE_HIP_COMPILER_ROCM_ROOT}\n" + "does not contain the HIP runtime CMake package, expected at:\n" + " ${CMAKE_HIP_COMPILER_ROCM_ROOT}/lib/cmake/hip-lang/hip-lang-config.cmake\n" + ) endif() if (NOT _CMAKE_TOOLCHAIN_LOCATION) @@ -85,12 +140,44 @@ if(MSVC_HIP_ARCHITECTURE_ID) endif() if(NOT DEFINED CMAKE_HIP_ARCHITECTURES) - # Analyze output from hipcc to get the current GPU architecture. - if(CMAKE_HIP_COMPILER_PRODUCED_OUTPUT MATCHES " -target-cpu ([a-z0-9]+) ") + # Use 'rocm_agent_enumerator' to get the current GPU architecture. + set(_CMAKE_HIP_ARCHITECTURES) + find_program(_CMAKE_HIP_ROCM_AGENT_ENUMERATOR + NAMES rocm_agent_enumerator + HINTS "${CMAKE_HIP_COMPILER_ROCM_ROOT}/bin" + NO_CACHE) + if(_CMAKE_HIP_ROCM_AGENT_ENUMERATOR) + execute_process(COMMAND "${_CMAKE_HIP_ROCM_AGENT_ENUMERATOR}" -t GPU + RESULT_VARIABLE _CMAKE_ROCM_AGENT_ENUMERATOR_RESULT + OUTPUT_VARIABLE _CMAKE_ROCM_AGENT_ENUMERATOR_STDOUT + ERROR_VARIABLE _CMAKE_ROCM_AGENT_ENUMERATOR_STDERR + ) + if(_CMAKE_ROCM_AGENT_ENUMERATOR_RESULT EQUAL 0) + separate_arguments(_hip_archs NATIVE_COMMAND "${_CMAKE_ROCM_AGENT_ENUMERATOR_STDOUT}") + foreach(_hip_arch ${_hip_archs}) + if(_hip_arch STREQUAL "gfx000") + continue() + endif() + string(FIND ${_hip_arch} ":" pos) + if(NOT pos STREQUAL "-1") + string(SUBSTRING ${_hip_arch} 0 ${pos} _hip_arch) + endif() + list(APPEND _CMAKE_HIP_ARCHITECTURES "${_hip_arch}") + endforeach() + endif() + unset(_CMAKE_ROCM_AGENT_ENUMERATOR_RESULT) + unset(_CMAKE_ROCM_AGENT_ENUMERATOR_STDOUT) + unset(_CMAKE_ROCM_AGENT_ENUMERATOR_STDERR) + endif() + unset(_CMAKE_HIP_ROCM_AGENT_ENUMERATOR) + if(_CMAKE_HIP_ARCHITECTURES) + set(CMAKE_HIP_ARCHITECTURES "${_CMAKE_HIP_ARCHITECTURES}" CACHE STRING "HIP architectures") + elseif(CMAKE_HIP_COMPILER_PRODUCED_OUTPUT MATCHES " -target-cpu ([a-z0-9]+) ") set(CMAKE_HIP_ARCHITECTURES "${CMAKE_MATCH_1}" CACHE STRING "HIP architectures") else() - message(FATAL_ERROR "Failed to find a working HIP architecture.") + message(FATAL_ERROR "Failed to find a default HIP architecture.") endif() + unset(_CMAKE_HIP_ARCHITECTURES) endif() # configure variables set in this file for fast reload later on diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index bb97f4a..27d9131 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -20,6 +20,9 @@ # on UNIX, cygwin and mingw +cmake_policy(PUSH) +cmake_policy(SET CMP0057 NEW) # if IN_LIST + # Resolve full path of CMAKE_TOOL from user-defined name and SEARCH_PATH. function(__resolve_tool_path CMAKE_TOOL SEARCH_PATH DOCSTRING) @@ -240,3 +243,5 @@ if("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" MATCHES "^xIAR$") set(CMAKE_IAR_LINKER "${CMAKE_LINKER}" CACHE FILEPATH "The IAR ILINK linker") mark_as_advanced(CMAKE_IAR_LINKER CMAKE_IAR_AR) endif() + +cmake_policy(POP) diff --git a/Modules/CMakeHIPCompiler.cmake.in b/Modules/CMakeHIPCompiler.cmake.in index 9a30a45..17633a8 100644 --- a/Modules/CMakeHIPCompiler.cmake.in +++ b/Modules/CMakeHIPCompiler.cmake.in @@ -16,6 +16,7 @@ set(CMAKE_HIP_COMPILER_FRONTEND_VARIANT "@CMAKE_HIP_COMPILER_FRONTEND_VARIANT@") set(CMAKE_HIP_SIMULATE_VERSION "@CMAKE_HIP_SIMULATE_VERSION@") @SET_MSVC_HIP_ARCHITECTURE_ID@ @_SET_CMAKE_HIP_COMPILER_SYSROOT@ +set(CMAKE_HIP_COMPILER_ROCM_ROOT "@CMAKE_HIP_COMPILER_ROCM_ROOT@") set(CMAKE_HIP_COMPILER_ENV_VAR "HIPCXX") diff --git a/Modules/CMakeHIPInformation.cmake b/Modules/CMakeHIPInformation.cmake index 9862f24..4c57677 100644 --- a/Modules/CMakeHIPInformation.cmake +++ b/Modules/CMakeHIPInformation.cmake @@ -141,8 +141,11 @@ endif() set(CMAKE_HIP_INFORMATION_LOADED 1) # Load the file and find the relevant HIP runtime. -# This file will only exist after all compiler detection has finished -include(${CMAKE_PLATFORM_INFO_DIR}/CMakeHIPRuntime.cmake OPTIONAL) -if(COMMAND _CMAKE_FIND_HIP_RUNTIME) - _CMAKE_FIND_HIP_RUNTIME() +if(NOT DEFINED _CMAKE_HIP_DEVICE_RUNTIME_TARGET) + set(hip-lang_DIR "${CMAKE_HIP_COMPILER_ROCM_ROOT}/lib/cmake/hip-lang") + find_package(hip-lang CONFIG QUIET NO_DEFAULT_PATH) +endif() +if(DEFINED _CMAKE_HIP_DEVICE_RUNTIME_TARGET) + list(APPEND CMAKE_HIP_RUNTIME_LIBRARIES_STATIC ${_CMAKE_HIP_DEVICE_RUNTIME_TARGET}) + list(APPEND CMAKE_HIP_RUNTIME_LIBRARIES_SHARED ${_CMAKE_HIP_DEVICE_RUNTIME_TARGET}) endif() diff --git a/Modules/CMakeHIPRuntime.cmake.in b/Modules/CMakeHIPRuntime.cmake.in deleted file mode 100644 index ade26bb..0000000 --- a/Modules/CMakeHIPRuntime.cmake.in +++ /dev/null @@ -1,99 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - - -function(_CMAKE_FIND_HIP_RUNTIME ) - # Determined when hipcc is the HIP compiler - set(_CMAKE_HIP_COMPILER_ROCM_ROOT "@_CMAKE_HIP_COMPILER_ROCM_ROOT@") - - # Forward facing value that can be provided by the user - set(CMAKE_HIP_COMPILER_TOOLKIT_ROOT @CMAKE_HIP_COMPILER_TOOLKIT_ROOT@) - - if(NOT DEFINED _CMAKE_HIP_DEVICE_RUNTIME_TARGET) - set(message_on_found TRUE) - endif() - - set(explicit_search_only FALSE) - set(rocm_root_dirs ) - if(DEFINED CMAKE_HIP_COMPILER_TOOLKIT_ROOT) - set(rocm_root_dirs "${CMAKE_HIP_COMPILER_TOOLKIT_ROOT}") - set(explicit_search_only TRUE) - set(error_message_location "the variable CMAKE_HIP_COMPILER_TOOLKIT_ROOT [\"${CMAKE_HIP_COMPILER_TOOLKIT_ROOT}\"]") - elseif(DEFINED ENV{CMAKE_HIP_COMPILER_TOOLKIT_ROOT}) - set(rocm_root_dirs "$ENV{CMAKE_HIP_COMPILER_TOOLKIT_ROOT}") - set(explicit_search_only TRUE) - set(error_message_location "CMAKE_HIP_COMPILER_TOOLKIT_ROOT") - set(error_message_location "the environment variable CMAKE_HIP_COMPILER_TOOLKIT_ROOT [\"$ENV{CMAKE_HIP_COMPILER_TOOLKIT_ROOT}\"]") - elseif(DEFINED _CMAKE_HIP_COMPILER_ROCM_ROOT) - set(rocm_root_dirs "${_CMAKE_HIP_COMPILER_ROCM_ROOT}") - set(explicit_search_only TRUE) - set(error_message_location "the associated hipconfig --rocmpath [\"${_CMAKE_HIP_COMPILER_ROCM_ROOT}\"]") - endif() - - # Guess on where rocm is installed - if(NOT rocm_root_dirs AND (UNIX AND NOT APPLE)) - set(platform_base "/opt/rocm-") - - # Finad all default rocm installations - file(GLOB possible_paths "${platform_base}*") - - set(versions) - foreach(p ${possible_paths}) - # Extract version number from end of string - string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+$" p_version ${p}) - if(IS_DIRECTORY ${p} AND p_version) - list(APPEND versions ${p_version}) - endif() - endforeach() - - # Sort numerically in descending order, so we try the newest versions first. - list(SORT versions COMPARE NATURAL ORDER DESCENDING) - - # With a descending list of versions, populate possible paths to search. - set(rocm_root_dirs "/opt/rocm") - foreach(v IN LISTS versions) - list(APPEND rocm_root_dirs "${platform_base}${v}") - endforeach() - endif() - - set(search_rel_path "/lib/cmake/hip-lang/") - list(TRANSFORM rocm_root_dirs APPEND "${search_rel_path}") - - find_package(hip-lang - CONFIG - PATHS ${rocm_root_dirs} - QUIET - NO_DEFAULT_PATH - ) - if(NOT DEFINED _CMAKE_HIP_DEVICE_RUNTIME_TARGET AND NOT explicit_search_only) - find_package(hip-lang CONFIG QUIET) - endif() - - if(DEFINED _CMAKE_HIP_DEVICE_RUNTIME_TARGET) - set(CMAKE_HIP_RUNTIME_LIBRARIES_STATIC - ${CMAKE_HIP_RUNTIME_LIBRARIES_STATIC} - ${_CMAKE_HIP_DEVICE_RUNTIME_TARGET} PARENT_SCOPE) - set(CMAKE_HIP_RUNTIME_LIBRARIES_SHARED - ${CMAKE_HIP_RUNTIME_LIBRARIES_SHARED} - ${_CMAKE_HIP_DEVICE_RUNTIME_TARGET} PARENT_SCOPE) - endif() - - if(DEFINED _CMAKE_HIP_DEVICE_RUNTIME_TARGET AND message_on_found) - message(STATUS "Found HIP runtime: ${hip-lang_DIR}") - elseif(NOT DEFINED _CMAKE_HIP_DEVICE_RUNTIME_TARGET) - if(explicit_search_only) - set(error_message "Failed to find the HIP runtime, Could not find hip-lang-config.cmake at the following location(s):\n") - foreach(p IN LISTS rocm_root_dirs) - string(APPEND error_message "\t${p}\n") - endforeach() - string(APPEND "which are computed from the location specified by ${error_message_location}. \ - Please specify CMAKE_HIP_COMPILER_TOOLKIT_ROOT to the location of") - message(FATAL_ERROR "${error_message}") - else() - message(FATAL_ERROR - "Failed to find the HIP runtime, Could not find hip-lang-config.cmake.\ - Try setting CMAKE_HIP_COMPILER_TOOLKIT_ROOT") - endif() - endif() - -endfunction() diff --git a/Modules/CMakeTestHIPCompiler.cmake b/Modules/CMakeTestHIPCompiler.cmake index 62f0657..5acd806 100644 --- a/Modules/CMakeTestHIPCompiler.cmake +++ b/Modules/CMakeTestHIPCompiler.cmake @@ -81,20 +81,6 @@ unset(__CMAKE_HIP_FLAGS) include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake) CMAKE_DETERMINE_COMPILE_FEATURES(HIP) - -# Setup the following: -# Configure the new template file CMakeHipRuntime.cmake to -# - ${CMAKE_PLATFORM_INFO_DIR}/ -# This file will do the actual find_package query. We than have -# CMakeHIPInformation.cmake include `CMakeHipRuntime` -# So it is included once system information has been finished -# -configure_file( - ${CMAKE_ROOT}/Modules/CMakeHIPRuntime.cmake.in - ${CMAKE_PLATFORM_INFO_DIR}/CMakeHIPRuntime.cmake - @ONLY -) - # Re-configure to save learned information. configure_file( ${CMAKE_ROOT}/Modules/CMakeHIPCompiler.cmake.in @@ -113,10 +99,3 @@ endif() set(CMAKE_TRY_COMPILE_TARGET_TYPE ${__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE}) unset(__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE) unset(__CMAKE_HIP_COMPILER_OUTPUT) - -# Load the file and find the relevant HIP runtime. -# This file will only exist after all compiler detection has finished -include(${CMAKE_PLATFORM_INFO_DIR}/CMakeHIPRuntime.cmake) -if(COMMAND _CMAKE_FIND_HIP_RUNTIME) - _CMAKE_FIND_HIP_RUNTIME() -endif() diff --git a/Modules/Compiler/Clang-HIP.cmake b/Modules/Compiler/Clang-HIP.cmake index 1030a43..4dbe2e8 100644 --- a/Modules/Compiler/Clang-HIP.cmake +++ b/Modules/Compiler/Clang-HIP.cmake @@ -15,6 +15,6 @@ set(CMAKE_HIP_RUNTIME_LIBRARY_DEFAULT "SHARED") set(CMAKE_HIP_RUNTIME_LIBRARY_LINK_OPTIONS_STATIC "") set(CMAKE_HIP_RUNTIME_LIBRARY_LINK_OPTIONS_SHARED "") -# Populated by CMakeHIPRuntime.cmake +# Populated by CMakeHIPInformation.cmake set(CMAKE_HIP_RUNTIME_LIBRARIES_STATIC "") set(CMAKE_HIP_RUNTIME_LIBRARIES_SHARED "") diff --git a/Modules/Compiler/ROCMClang-ASM.cmake b/Modules/Compiler/ROCMClang-ASM.cmake deleted file mode 100644 index 85d1110..0000000 --- a/Modules/Compiler/ROCMClang-ASM.cmake +++ /dev/null @@ -1,2 +0,0 @@ -include(Compiler/ROCMClang) -__compiler_rocmclang(ASM) diff --git a/Modules/Compiler/ROCMClang-C.cmake b/Modules/Compiler/ROCMClang-C.cmake deleted file mode 100644 index cdfa95d..0000000 --- a/Modules/Compiler/ROCMClang-C.cmake +++ /dev/null @@ -1,7 +0,0 @@ -include(Compiler/ROCMClang) -__compiler_rocmclang(C) - -set(_rocm_clang_ver "${CMAKE_C_COMPILER_VERSION_INTERNAL}") -set(CMAKE_C_COMPILER_VERSION "${CMAKE_C_COMPILER_VERSION_INTERNAL}") -include(Compiler/Clang-C) -set(CMAKE_C_COMPILER_VERSION "${_rocm_clang_ver}") diff --git a/Modules/Compiler/ROCMClang-CXX.cmake b/Modules/Compiler/ROCMClang-CXX.cmake deleted file mode 100644 index 5739c8e..0000000 --- a/Modules/Compiler/ROCMClang-CXX.cmake +++ /dev/null @@ -1,7 +0,0 @@ -include(Compiler/ROCMClang) -__compiler_rocmclang(CXX) - -set(_rocm_clang_ver "${CMAKE_CXX_COMPILER_VERSION_INTERNAL}") -set(CMAKE_CXX_COMPILER_VERSION "${CMAKE_CXX_COMPILER_VERSION_INTERNAL}") -include(Compiler/Clang-CXX) -set(CMAKE_CXX_COMPILER_VERSION "${_rocm_clang_ver}") diff --git a/Modules/Compiler/ROCMClang-DetermineCompiler.cmake b/Modules/Compiler/ROCMClang-DetermineCompiler.cmake deleted file mode 100644 index c2fc99b..0000000 --- a/Modules/Compiler/ROCMClang-DetermineCompiler.cmake +++ /dev/null @@ -1,19 +0,0 @@ - -set(_compiler_id_pp_test "defined(__clang__) && __has_include(<hip/hip_version.h>)") - -set(_compiler_id_version_compute " -# if defined(__clang__) && __has_include(<hip/hip_version.h>) -# include <hip/hip_version.h> -# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(HIP_VERSION_MAJOR) -# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(HIP_VERSION_MINOR) -# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(HIP_VERSION_PATCH) -# endif") - -set(_compiler_id_simulate " -# if defined(_MSC_VER) -# define @PREFIX@SIMULATE_ID \"MSVC\" -# elif defined(__clang__) -# define @PREFIX@SIMULATE_ID \"Clang\" -# elif defined(__GNUC__) -# define @PREFIX@SIMULATE_ID \"GNU\" -# endif") diff --git a/Modules/Compiler/ROCMClang-FindBinUtils.cmake b/Modules/Compiler/ROCMClang-FindBinUtils.cmake deleted file mode 100644 index e721c87..0000000 --- a/Modules/Compiler/ROCMClang-FindBinUtils.cmake +++ /dev/null @@ -1 +0,0 @@ -include(Compiler/Clang-FindBinUtils) diff --git a/Modules/Compiler/ROCMClang-HIP.cmake b/Modules/Compiler/ROCMClang-HIP.cmake deleted file mode 100644 index 7af7699..0000000 --- a/Modules/Compiler/ROCMClang-HIP.cmake +++ /dev/null @@ -1,49 +0,0 @@ -include(Compiler/ROCMClang) -__compiler_rocmclang(HIP) - -set(_CMAKE_COMPILE_AS_HIP_FLAG "-x hip") -set(_CMAKE_HIP_RDC_FLAG "-fgpu-rdc") - -if(NOT "x${CMAKE_${lang}_SIMULATE_ID}" STREQUAL "xMSVC") - set(CMAKE_HIP_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") - string(APPEND CMAKE_HIP_FLAGS_DEBUG_INIT " -O") -endif() - -if(CMAKE_HIP_SIMULATE_ID STREQUAL "GNU") - set(CMAKE_HIP_LINKER_WRAPPER_FLAG "-Wl,") - set(CMAKE_HIP_LINKER_WRAPPER_FLAG_SEP ",") -elseif(CMAKE_HIP_SIMULATE_ID STREQUAL "Clang") - set(CMAKE_HIP_LINKER_WRAPPER_FLAG "-Xlinker" " ") - set(CMAKE_HIP_LINKER_WRAPPER_FLAG_SEP) -endif() - -if(NOT CMAKE_HIP_COMPILER_VERSION VERSION_LESS 1.0) - set(CMAKE_HIP98_STANDARD_COMPILE_OPTION "-std=c++98") - set(CMAKE_HIP98_EXTENSION_COMPILE_OPTION "-std=gnu++98") - set(CMAKE_HIP98_STANDARD__HAS_FULL_SUPPORT ON) - - set(CMAKE_HIP11_STANDARD_COMPILE_OPTION "-std=c++11") - set(CMAKE_HIP11_EXTENSION_COMPILE_OPTION "-std=gnu++11") - set(CMAKE_HIP11_STANDARD__HAS_FULL_SUPPORT ON) - - set(CMAKE_HIP14_STANDARD_COMPILE_OPTION "-std=c++14") - set(CMAKE_HIP14_EXTENSION_COMPILE_OPTION "-std=gnu++14") - set(CMAKE_HIP14_STANDARD__HAS_FULL_SUPPORT ON) - - set(CMAKE_HIP17_STANDARD_COMPILE_OPTION "-std=c++17") - set(CMAKE_HIP17_EXTENSION_COMPILE_OPTION "-std=gnu++17") - set(CMAKE_HIP17_STANDARD__HAS_FULL_SUPPORT ON) - - set(CMAKE_HIP20_STANDARD_COMPILE_OPTION "-std=c++20") - set(CMAKE_HIP20_EXTENSION_COMPILE_OPTION "-std=gnu++20") -endif() - -set(CMAKE_HIP_RUNTIME_LIBRARY_DEFAULT "SHARED") -set(CMAKE_HIP_RUNTIME_LIBRARY_LINK_OPTIONS_STATIC "") -set(CMAKE_HIP_RUNTIME_LIBRARY_LINK_OPTIONS_SHARED "") - -# Populated by CMakeHIPRuntime.cmake -set(CMAKE_HIP_RUNTIME_LIBRARIES_STATIC "") -set(CMAKE_HIP_RUNTIME_LIBRARIES_SHARED "") - -__compiler_check_default_language_standard(HIP 3.5 11) diff --git a/Modules/Compiler/ROCMClang-OBJC.cmake b/Modules/Compiler/ROCMClang-OBJC.cmake deleted file mode 100644 index 794973d..0000000 --- a/Modules/Compiler/ROCMClang-OBJC.cmake +++ /dev/null @@ -1,7 +0,0 @@ -include(Compiler/ROCMClang) -__compiler_rocmclang(OBJC) - -set(_rocm_clang_ver "${CMAKE_OBJC_COMPILER_VERSION_INTERNAL}") -set(CMAKE_OBJC_COMPILER_VERSION "${CMAKE_OBJC_COMPILER_VERSION_INTERNAL}") -include(Compiler/Clang-OBJC) -set(CMAKE_OBJC_COMPILER_VERSION "${_rocm_clang_ver}") diff --git a/Modules/Compiler/ROCMClang-OBJCXX.cmake b/Modules/Compiler/ROCMClang-OBJCXX.cmake deleted file mode 100644 index 82238e1..0000000 --- a/Modules/Compiler/ROCMClang-OBJCXX.cmake +++ /dev/null @@ -1,7 +0,0 @@ -include(Compiler/ROCMClang) -__compiler_rocmclang(OBJCXX) - -set(_rocm_clang_ver "${CMAKE_OBJCXX_COMPILER_VERSION_INTERNAL}") -set(CMAKE_OBJCXX_COMPILER_VERSION "${CMAKE_OBJCXX_COMPILER_VERSION_INTERNAL}") -include(Compiler/Clang-OBJCXX) -set(CMAKE_OBJCXX_COMPILER_VERSION "${_rocm_clang_ver}") diff --git a/Modules/Compiler/ROCMClang.cmake b/Modules/Compiler/ROCMClang.cmake deleted file mode 100644 index 6b38c2d..0000000 --- a/Modules/Compiler/ROCMClang.cmake +++ /dev/null @@ -1,35 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - - -# This module is shared by multiple languages; use include blocker. -include_guard() - -include(Compiler/CMakeCommonCompilerMacros) - -macro(__compiler_rocmclang lang) - - set(CMAKE_${lang}_VERBOSE_FLAG "-v") - - if(NOT "x${CMAKE_${lang}_SIMULATE_ID}" STREQUAL "xMSVC") - # Feature flags. - set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC") - set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE") - set(CMAKE_HIP_COMPILE_OPTIONS_VISIBILITY -fvisibility=) - - string(APPEND CMAKE_HIP_FLAGS_INIT " ") - string(APPEND CMAKE_HIP_FLAGS_DEBUG_INIT " -g") - string(APPEND CMAKE_HIP_FLAGS_RELEASE_INIT " -O3 -DNDEBUG") - string(APPEND CMAKE_HIP_FLAGS_MINSIZEREL_INIT " -Os -DNDEBUG") - string(APPEND CMAKE_HIP_FLAGS_RELWITHDEBINFO_INIT " -O2 -g -DNDEBUG") - endif() - - set(CMAKE_SHARED_LIBRARY_CREATE_HIP_FLAGS -shared) - set(CMAKE_INCLUDE_SYSTEM_FLAG_HIP "-isystem ") - - set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_INCLUDES 1) - set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_LIBRARIES 1) - set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS 1) - set(CMAKE_${lang}_RESPONSE_FILE_FLAG "@") - set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "@") -endmacro() diff --git a/Modules/Platform/Android-Initialize.cmake b/Modules/Platform/Android-Initialize.cmake index 50f0620..63bc949 100644 --- a/Modules/Platform/Android-Initialize.cmake +++ b/Modules/Platform/Android-Initialize.cmake @@ -56,11 +56,6 @@ if(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) endif() - # Don't search paths in PATH environment variable. - if(NOT DEFINED CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH) - set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF) - endif() - # Allows CMake to find headers in the architecture-specific include directories. set(CMAKE_LIBRARY_ARCHITECTURE "${CMAKE_ANDROID_ARCH_TRIPLE}") diff --git a/Modules/WriteCompilerDetectionHeader.cmake b/Modules/WriteCompilerDetectionHeader.cmake index 54eb40e..0e4e028 100644 --- a/Modules/WriteCompilerDetectionHeader.cmake +++ b/Modules/WriteCompilerDetectionHeader.cmake @@ -384,7 +384,6 @@ elseif(_WCDH_policy STREQUAL "") ) endif() -set(__skip_rocmclang TRUE) include(${CMAKE_CURRENT_LIST_DIR}/CMakeCompilerIdDetection.cmake) function(_load_compiler_variables CompilerId lang) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 7fdda7b..caa4806 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 21) -set(CMake_VERSION_PATCH 20210916) +set(CMake_VERSION_PATCH 20210921) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/CPack/IFW/cmCPackIFWCommon.cxx b/Source/CPack/IFW/cmCPackIFWCommon.cxx index 177a959..c7ab994 100644 --- a/Source/CPack/IFW/cmCPackIFWCommon.cxx +++ b/Source/CPack/IFW/cmCPackIFWCommon.cxx @@ -51,7 +51,7 @@ bool cmCPackIFWCommon::IsVersionLess(const char* version) const } return cmSystemTools::VersionCompare( - cmSystemTools::OP_LESS, this->Generator->FrameworkVersion.data(), version); + cmSystemTools::OP_LESS, this->Generator->FrameworkVersion, version); } bool cmCPackIFWCommon::IsVersionGreater(const char* version) const @@ -61,8 +61,7 @@ bool cmCPackIFWCommon::IsVersionGreater(const char* version) const } return cmSystemTools::VersionCompare( - cmSystemTools::OP_GREATER, this->Generator->FrameworkVersion.data(), - version); + cmSystemTools::OP_GREATER, this->Generator->FrameworkVersion, version); } bool cmCPackIFWCommon::IsVersionEqual(const char* version) const @@ -72,8 +71,7 @@ bool cmCPackIFWCommon::IsVersionEqual(const char* version) const } return cmSystemTools::VersionCompare( - cmSystemTools::OP_EQUAL, this->Generator->FrameworkVersion.data(), - version); + cmSystemTools::OP_EQUAL, this->Generator->FrameworkVersion, version); } void cmCPackIFWCommon::ExpandListArgument( diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx index 68bc4d8..1d7696d 100644 --- a/Source/cmConditionEvaluator.cxx +++ b/Source/cmConditionEvaluator.cxx @@ -729,10 +729,9 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList& newArgs, keyVERSION_LESS_EQUAL, keyVERSION_GREATER, keyVERSION_GREATER_EQUAL, keyVERSION_EQUAL))) { const auto op = MATCH2CMPOP[matchNo - 1]; - const cmProp lhs = this->GetVariableOrString(*args.current); - const cmProp rhs = this->GetVariableOrString(*args.nextnext); - const auto result = - cmSystemTools::VersionCompare(op, lhs->c_str(), rhs->c_str()); + const std::string& lhs = this->GetVariableOrString(*args.current); + const std::string& rhs = this->GetVariableOrString(*args.nextnext); + const auto result = cmSystemTools::VersionCompare(op, lhs, rhs); newArgs.ReduceTwoArgs(result, args); } diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 3e90ead..4e06a07 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -771,8 +771,7 @@ struct CompilerVersionNode : public cmGeneratorExpressionNode } return cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL, - parameters.front().c_str(), - compilerVersion.c_str()) + parameters.front(), compilerVersion) ? "1" : "0"; } @@ -830,8 +829,7 @@ struct VersionNode : public cmGeneratorExpressionNode const GeneratorExpressionContent* /*content*/, cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override { - return cmSystemTools::VersionCompare(Op, parameters.front().c_str(), - parameters[1].c_str()) + return cmSystemTools::VersionCompare(Op, parameters.front(), parameters[1]) ? "1" : "0"; } diff --git a/Source/cmGlobalNMakeMakefileGenerator.cxx b/Source/cmGlobalNMakeMakefileGenerator.cxx index f08b1da..5ca8d52 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.cxx +++ b/Source/cmGlobalNMakeMakefileGenerator.cxx @@ -70,7 +70,7 @@ bool cmGlobalNMakeMakefileGenerator::FindMakeProgram(cmMakefile* mf) void cmGlobalNMakeMakefileGenerator::CheckNMakeFeatures() { this->NMakeSupportsUTF8 = !cmSystemTools::VersionCompare( - cmSystemTools::OP_LESS, this->NMakeVersion.c_str(), "9"); + cmSystemTools::OP_LESS, this->NMakeVersion, "9"); } void cmGlobalNMakeMakefileGenerator::GetDocumentation( diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index e2f195f..768c045 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -558,9 +558,8 @@ void cmGlobalNinjaGenerator::GetDocumentation(cmDocumentationEntry& entry) void cmGlobalNinjaGenerator::Generate() { // Check minimum Ninja version. - if (cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, - this->NinjaVersion.c_str(), - RequiredNinjaVersion().c_str())) { + if (cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, this->NinjaVersion, + RequiredNinjaVersion())) { std::ostringstream msg; msg << "The detected version of Ninja (" << this->NinjaVersion; msg << ") is less than the version of Ninja required by CMake ("; @@ -721,21 +720,21 @@ bool cmGlobalNinjaGenerator::FindMakeProgram(cmMakefile* mf) void cmGlobalNinjaGenerator::CheckNinjaFeatures() { - this->NinjaSupportsConsolePool = !cmSystemTools::VersionCompare( - cmSystemTools::OP_LESS, this->NinjaVersion.c_str(), - RequiredNinjaVersionForConsolePool().c_str()); + this->NinjaSupportsConsolePool = + !cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, this->NinjaVersion, + RequiredNinjaVersionForConsolePool()); this->NinjaSupportsImplicitOuts = !cmSystemTools::VersionCompare( - cmSystemTools::OP_LESS, this->NinjaVersion.c_str(), - cmGlobalNinjaGenerator::RequiredNinjaVersionForImplicitOuts().c_str()); - this->NinjaSupportsManifestRestat = !cmSystemTools::VersionCompare( - cmSystemTools::OP_LESS, this->NinjaVersion.c_str(), - RequiredNinjaVersionForManifestRestat().c_str()); - this->NinjaSupportsMultilineDepfile = !cmSystemTools::VersionCompare( - cmSystemTools::OP_LESS, this->NinjaVersion.c_str(), - RequiredNinjaVersionForMultilineDepfile().c_str()); - this->NinjaSupportsDyndeps = !cmSystemTools::VersionCompare( - cmSystemTools::OP_LESS, this->NinjaVersion.c_str(), - RequiredNinjaVersionForDyndeps().c_str()); + cmSystemTools::OP_LESS, this->NinjaVersion, + cmGlobalNinjaGenerator::RequiredNinjaVersionForImplicitOuts()); + this->NinjaSupportsManifestRestat = + !cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, this->NinjaVersion, + RequiredNinjaVersionForManifestRestat()); + this->NinjaSupportsMultilineDepfile = + !cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, this->NinjaVersion, + RequiredNinjaVersionForMultilineDepfile()); + this->NinjaSupportsDyndeps = + !cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, this->NinjaVersion, + RequiredNinjaVersionForDyndeps()); if (!this->NinjaSupportsDyndeps) { // The ninja version number is not new enough to have upstream support. // Our ninja branch adds ".dyndep-#" to its version number, @@ -753,21 +752,21 @@ void cmGlobalNinjaGenerator::CheckNinjaFeatures() } this->NinjaSupportsUnconditionalRecompactTool = !cmSystemTools::VersionCompare( - cmSystemTools::OP_LESS, this->NinjaVersion.c_str(), - RequiredNinjaVersionForUnconditionalRecompactTool().c_str()); - this->NinjaSupportsRestatTool = !cmSystemTools::VersionCompare( - cmSystemTools::OP_LESS, this->NinjaVersion.c_str(), - RequiredNinjaVersionForRestatTool().c_str()); - this->NinjaSupportsMultipleOutputs = !cmSystemTools::VersionCompare( - cmSystemTools::OP_LESS, this->NinjaVersion.c_str(), - RequiredNinjaVersionForMultipleOutputs().c_str()); + cmSystemTools::OP_LESS, this->NinjaVersion, + RequiredNinjaVersionForUnconditionalRecompactTool()); + this->NinjaSupportsRestatTool = + !cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, this->NinjaVersion, + RequiredNinjaVersionForRestatTool()); + this->NinjaSupportsMultipleOutputs = + !cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, this->NinjaVersion, + RequiredNinjaVersionForMultipleOutputs()); this->NinjaSupportsMetadataOnRegeneration = !cmSystemTools::VersionCompare( - cmSystemTools::OP_LESS, this->NinjaVersion.c_str(), - RequiredNinjaVersionForMetadataOnRegeneration().c_str()); + cmSystemTools::OP_LESS, this->NinjaVersion, + RequiredNinjaVersionForMetadataOnRegeneration()); #ifdef _WIN32 - this->NinjaSupportsCodePage = !cmSystemTools::VersionCompare( - cmSystemTools::OP_LESS, this->NinjaVersion.c_str(), - RequiredNinjaVersionForCodePage().c_str()); + this->NinjaSupportsCodePage = + !cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, this->NinjaVersion, + RequiredNinjaVersionForCodePage()); if (this->NinjaSupportsCodePage) { this->CheckNinjaCodePage(); } else { diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index fa76b01..4ccc955 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -3809,7 +3809,7 @@ void cmGlobalXCodeGenerator::AddEmbeddedObjects( copyFilesBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing", this->CreateString("0")); cmXCodeObject* buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST); - // Collect all embedded frameworks and add them to build phase + // Collect all embedded frameworks and dylibs and add them to build phase std::vector<std::string> relFiles = cmExpandedList(*files); for (std::string const& relFile : relFiles) { cmXCodeObject* buildFile{ nullptr }; @@ -3839,7 +3839,8 @@ void cmGlobalXCodeGenerator::AddEmbeddedObjects( } else { buildFile = it->second; } - } else if (cmSystemTools::IsPathToFramework(relFile)) { + } else if (cmSystemTools::IsPathToFramework(relFile) || + cmSystemTools::IsPathToMacOSSharedLibrary(relFile)) { // This is a regular string path - create file reference auto it = this->EmbeddedLibRefs.find(relFile); if (it == this->EmbeddedLibRefs.end()) { @@ -3905,6 +3906,8 @@ void cmGlobalXCodeGenerator::AddEmbeddedFrameworks(cmXCodeObject* target) { static const auto dstSubfolderSpec = "10"; + // Despite the name, by default Xcode uses "Embed Frameworks" build phase for + // both frameworks and dynamic libraries this->AddEmbeddedObjects(target, "Embed Frameworks", "XCODE_EMBED_FRAMEWORKS", dstSubfolderSpec, NoActionOnCopyByDefault); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 5042874..4c3e8ec 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1961,10 +1961,10 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, cmStrCat("CMAKE_", lang, "_SIMULATE_ID")); if (lang == "Swift") { if (cmProp v = target->GetProperty("Swift_LANGUAGE_VERSION")) { - if (cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER_EQUAL, - cmToCStr(this->Makefile->GetDefinition( - "CMAKE_Swift_COMPILER_VERSION")), - "4.2")) { + if (cmSystemTools::VersionCompare( + cmSystemTools::OP_GREATER_EQUAL, + this->Makefile->GetDefinition("CMAKE_Swift_COMPILER_VERSION"), + "4.2")) { this->AppendFlags(flags, "-swift-version " + *v); } } @@ -2622,8 +2622,8 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target) // MSVC 2008 is producing both .pdb and .idb files with /Zi. bool msvc2008OrLess = - cmSystemTools::VersionCompare( - cmSystemTools::OP_LESS, compilerVersion.c_str(), "16.0") && + cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, + compilerVersion, "16.0") && compilerId == "MSVC"; // but not when used via toolset -Tv90 if (this->Makefile->GetSafeDefinition( diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index ef31d76..f9b2562 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -926,8 +926,7 @@ void cmMakefile::Generate(cmLocalGenerator& lg) this->DoGenerate(lg); cmProp oldValue = this->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY"); if (oldValue && - cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, oldValue->c_str(), - "2.4")) { + cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, oldValue, "2.4")) { this->GetCMakeInstance()->IssueMessage( MessageType::FATAL_ERROR, "You have set CMAKE_BACKWARDS_COMPATIBILITY to a CMake version less " diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 54fe7a1..27cb90f 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1592,6 +1592,12 @@ bool cmSystemTools::IsPathToFramework(const std::string& path) cmHasLiteralSuffix(path, ".framework")); } +bool cmSystemTools::IsPathToMacOSSharedLibrary(const std::string& path) +{ + return (cmSystemTools::FileIsFullPath(path) && + cmHasLiteralSuffix(path, ".dylib")); +} + bool cmSystemTools::CreateTar(const std::string& outFileName, const std::vector<std::string>& files, cmTarCompression compressType, bool verbose, @@ -2879,8 +2885,9 @@ bool cmSystemTools::SetRPath(std::string const& file, return false; } -bool cmSystemTools::VersionCompare(cmSystemTools::CompareOp op, - const char* lhss, const char* rhss) +namespace { +bool VersionCompare(cmSystemTools::CompareOp op, const char* lhss, + const char* rhss) { const char* endl = lhss; const char* endr = rhss; @@ -2913,26 +2920,37 @@ bool cmSystemTools::VersionCompare(cmSystemTools::CompareOp op, // lhs == rhs, so true if operation is EQUAL return (op & cmSystemTools::OP_EQUAL) != 0; } +} + +bool cmSystemTools::VersionCompare(cmSystemTools::CompareOp op, + const std::string& lhs, + const std::string& rhs) +{ + return ::VersionCompare(op, lhs.c_str(), rhs.c_str()); +} +bool cmSystemTools::VersionCompare(cmSystemTools::CompareOp op, + const std::string& lhs, const char rhs[]) +{ + return ::VersionCompare(op, lhs.c_str(), rhs); +} bool cmSystemTools::VersionCompareEqual(std::string const& lhs, std::string const& rhs) { - return cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL, lhs.c_str(), - rhs.c_str()); + return cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL, lhs, rhs); } bool cmSystemTools::VersionCompareGreater(std::string const& lhs, std::string const& rhs) { - return cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER, lhs.c_str(), - rhs.c_str()); + return cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER, lhs, rhs); } bool cmSystemTools::VersionCompareGreaterEq(std::string const& lhs, std::string const& rhs) { - return cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER_EQUAL, - lhs.c_str(), rhs.c_str()); + return cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER_EQUAL, lhs, + rhs); } static size_t cm_strverscmp_find_first_difference_or_end(const char* lhs, diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 44ccbf7..715724c 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -102,7 +102,11 @@ public: } //! Return true if the path is a framework - static bool IsPathToFramework(const std::string& value); + static bool IsPathToFramework(const std::string& path); + + //! Return true if the path is a macOS non-framework shared library (aka + //! .dylib) + static bool IsPathToMacOSSharedLibrary(const std::string& path); static bool DoesFileExistWithExtensions( const std::string& name, const std::vector<std::string>& sourceExts); @@ -280,7 +284,10 @@ public: /** * Compare versions */ - static bool VersionCompare(CompareOp op, const char* lhs, const char* rhs); + static bool VersionCompare(CompareOp op, const std::string& lhs, + const std::string& rhs); + static bool VersionCompare(CompareOp op, const std::string& lhs, + const char rhs[]); static bool VersionCompareEqual(std::string const& lhs, std::string const& rhs); static bool VersionCompareGreater(std::string const& lhs, diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 4ccbfeb..da6b670 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1656,6 +1656,8 @@ if(BUILD_TESTING) "${CMake_SOURCE_DIR}/Tests/CMakeLists.txt" # random source file that exists "${CMake_BINARY_DIR}/Tests/try_to_create_symlink" # random target file in existing directory RESULT_VARIABLE _symlink_result + OUTPUT_VARIABLE _symlink_stdout + ERROR_VARIABLE _symlink_stderr ) if(_symlink_result EQUAL 0) file(REMOVE "${CMake_BINARY_DIR}/Tests/try_to_create_symlink") diff --git a/Tests/HIP/WithDefs/CMakeLists.txt b/Tests/HIP/WithDefs/CMakeLists.txt index e2db182..270f957 100644 --- a/Tests/HIP/WithDefs/CMakeLists.txt +++ b/Tests/HIP/WithDefs/CMakeLists.txt @@ -19,7 +19,7 @@ target_compile_options(HIPOnlyWithDefs PRIVATE --offload-arch=gfx900 -DFLAG_COMPILE_LANG_$<COMPILE_LANGUAGE> - $<$<HIP_COMPILER_ID:ROCMClang>:-DFLAG_LANG_IS_HIP=$<COMPILE_LANGUAGE:HIP>> # Host-only defines are possible only on NVCC. + $<$<HIP_COMPILER_ID:Clang>:-DFLAG_LANG_IS_HIP=$<COMPILE_LANGUAGE:HIP>> # Host-only defines are possible only on NVCC. ) target_compile_definitions(HIPOnlyWithDefs diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOff.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOff.cmake index f4fe07f..54375d5 100644 --- a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOff.cmake +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOff.cmake @@ -1,7 +1,7 @@ add_executable(app MACOSX_BUNDLE main.m) set_target_properties(app PROPERTIES - XCODE_EMBED_FRAMEWORKS "${EXTERNAL_FWK}" + XCODE_EMBED_FRAMEWORKS "${EXTERNAL_DEPENDENCY}" XCODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY OFF XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY OFF ) diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnNoSubdir-build-check.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnNoSubdir-build-check.cmake index e4ea55d..23fd49d 100644 --- a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnNoSubdir-build-check.cmake +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnNoSubdir-build-check.cmake @@ -1,3 +1,3 @@ -if(NOT EXISTS ${RunCMake_TEST_BINARY_DIR}/Debug/app.app/Contents/Frameworks/sharedFrameworkExt.framework) - set(RunCMake_TEST_FAILED "Framework was not embedded at the expected location") +if(NOT EXISTS ${RunCMake_TEST_BINARY_DIR}/Debug/app.app/Contents/Frameworks/${EXTERNAL_DEPENDENCY_NAME}) + set(RunCMake_TEST_FAILED "${EXTERNAL_DEPENDENCY_NAME} was not embedded at the expected location") endif() diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnNoSubdir.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnNoSubdir.cmake index 79d8d77..c76226f 100644 --- a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnNoSubdir.cmake +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnNoSubdir.cmake @@ -1,7 +1,7 @@ add_executable(app MACOSX_BUNDLE main.m) set_target_properties(app PROPERTIES - XCODE_EMBED_FRAMEWORKS "${EXTERNAL_FWK}" + XCODE_EMBED_FRAMEWORKS "${EXTERNAL_DEPENDENCY}" XCODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY ON XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY ON ) diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnWithSubdir-build-check.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnWithSubdir-build-check.cmake index 57c79ea..732f04c 100644 --- a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnWithSubdir-build-check.cmake +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnWithSubdir-build-check.cmake @@ -1,3 +1,3 @@ -if(NOT EXISTS ${RunCMake_TEST_BINARY_DIR}/Debug/app.app/Contents/Frameworks/subdir/sharedFrameworkExt.framework) - set(RunCMake_TEST_FAILED "Framework was not embedded at the expected location") +if(NOT EXISTS ${RunCMake_TEST_BINARY_DIR}/Debug/app.app/Contents/Frameworks/subdir/${EXTERNAL_DEPENDENCY_NAME}) + set(RunCMake_TEST_FAILED "${EXTERNAL_DEPENDENCY_NAME} was not embedded at the expected location") endif() diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnWithSubdir.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnWithSubdir.cmake index 4c78199..f83b1bf 100644 --- a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnWithSubdir.cmake +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnWithSubdir.cmake @@ -1,7 +1,7 @@ add_executable(app MACOSX_BUNDLE main.m) set_target_properties(app PROPERTIES - XCODE_EMBED_FRAMEWORKS "${EXTERNAL_FWK}" + XCODE_EMBED_FRAMEWORKS "${EXTERNAL_DEPENDENCY}" XCODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY ON XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY ON XCODE_EMBED_FRAMEWORKS_PATH "subdir" diff --git a/Tests/RunCMake/XcodeProject-Embed/ExternalFramework.cmake b/Tests/RunCMake/XcodeProject-Embed/ExternalDependencies.cmake index 64e2f95..8c7b06a 100644 --- a/Tests/RunCMake/XcodeProject-Embed/ExternalFramework.cmake +++ b/Tests/RunCMake/XcodeProject-Embed/ExternalDependencies.cmake @@ -1,2 +1,4 @@ add_library(sharedFrameworkExt SHARED func.m) set_target_properties(sharedFrameworkExt PROPERTIES FRAMEWORK TRUE) + +add_library(sharedDylibExt SHARED func.m) diff --git a/Tests/RunCMake/XcodeProject-Embed/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject-Embed/RunCMakeTest.cmake index e94d084..f3a6918 100644 --- a/Tests/RunCMake/XcodeProject-Embed/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject-Embed/RunCMakeTest.cmake @@ -1,47 +1,49 @@ include(RunCMake) -# Build a framework that the other tests will use and treat as external. +# Build dependencies that the other tests will use and treat as external. # Always build in the Debug configuration so that the path to the framework # is predictable. -function(ExternalFramework) +function(ExternalDependencies) set(RunCMake_TEST_NO_CLEAN 1) - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ExternalFramework-build) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ExternalDependencies-build) set(externalFramework ${RunCMake_TEST_BINARY_DIR}/Debug/sharedFrameworkExt.framework PARENT_SCOPE) + set(externalDylib ${RunCMake_TEST_BINARY_DIR}/Debug/libsharedDylibExt.dylib PARENT_SCOPE) file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") - run_cmake(ExternalFramework) - run_cmake_command(ExternalFramework-build + run_cmake(ExternalDependencies) + run_cmake_command(ExternalDependencies-build ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR} --config Debug - --target sharedFrameworkExt + --target sharedFrameworkExt sharedDylibExt ) endfunction() -ExternalFramework() +ExternalDependencies() -set(RunCMake_TEST_OPTIONS -DEXTERNAL_FWK=${externalFramework}) - -run_cmake(EmbedFrameworksFlagsOff) - -function(TestFlagsOn testName) +function(TestFlagsOn testName dependencyName) set(RunCMake_TEST_NO_CLEAN 1) - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${testName}-build) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${testName}-${dependencyName}-build) file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") run_cmake(${testName}) - run_cmake_command(${testName}-build + run_cmake_command(${testName}-${dependencyName}-build ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR} --config Debug --target app ) endfunction() -TestFlagsOn(EmbedFrameworksFlagsOnNoSubdir) -TestFlagsOn(EmbedFrameworksFlagsOnWithSubdir) - +foreach(dependency ${externalFramework} ${externalDylib}) + cmake_path(GET dependency FILENAME dependencyName) + set(RunCMake_TEST_OPTIONS -DEXTERNAL_DEPENDENCY=${dependency} -DEXTERNAL_DEPENDENCY_NAME=${dependencyName}) + run_cmake(EmbedFrameworksFlagsOff) + TestFlagsOn(EmbedFrameworksFlagsOnNoSubdir ${dependencyName}) + TestFlagsOn(EmbedFrameworksFlagsOnWithSubdir ${dependencyName}) +endforeach() +unset(RunCMake_TEST_OPTIONS) function(TestAppExtension platform) set(testName EmbedAppExtensions-${platform}) |