summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CPack.cmake16
-rw-r--r--Modules/CheckCXXSymbolExists.cmake11
-rw-r--r--Modules/CheckSymbolExists.cmake25
-rw-r--r--Modules/Compiler/Clang-CXX.cmake7
-rw-r--r--Modules/ExternalProject.cmake68
-rw-r--r--Modules/FindMPI.cmake4
-rw-r--r--Modules/InstallRequiredSystemLibraries.cmake20
-rw-r--r--Modules/Platform/Android-Clang.cmake3
-rw-r--r--Modules/Platform/Android-Common.cmake44
-rw-r--r--Modules/Platform/Android-Determine.cmake58
-rw-r--r--Modules/Platform/Android-Initialize.cmake9
-rw-r--r--Modules/Platform/Android/Determine-Compiler-NDK.cmake58
-rw-r--r--Modules/Platform/Android/Determine-Compiler-Standalone.cmake1
-rw-r--r--Modules/Platform/Android/Determine-Compiler.cmake2
-rw-r--r--Modules/Platform/Android/abi-common.cmake2
15 files changed, 249 insertions, 79 deletions
diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake
index c9008db..8a6a712 100644
--- a/Modules/CPack.cmake
+++ b/Modules/CPack.cmake
@@ -325,7 +325,21 @@ The following variables are for advanced uses of CPack:
.. variable:: CPACK_INSTALL_COMMANDS
- Extra commands to install components.
+ Extra commands to install components. The environment variable
+ ``CMAKE_INSTALL_PREFIX`` is set to the temporary install directory
+ during execution.
+
+.. variable:: CPACK_INSTALL_SCRIPTS
+
+ Extra CMake scripts executed by CPack during its local staging
+ installation, which is done right before packaging the files.
+ The scripts are not called by a standalone install (e.g.: ``make install``).
+ For every script, the following variables will be set:
+ :variable:`CMAKE_CURRENT_SOURCE_DIR`, :variable:`CMAKE_CURRENT_BINARY_DIR`
+ and :variable:`CMAKE_INSTALL_PREFIX` (which is set to the staging install
+ directory). The singular form ``CMAKE_INSTALL_SCRIPT`` is supported as
+ an alternative variable for historical reasons, but its value is ignored if
+ ``CMAKE_INSTALL_SCRIPTS`` is set and a warning will be issued.
.. variable:: CPACK_INSTALLED_DIRECTORIES
diff --git a/Modules/CheckCXXSymbolExists.cmake b/Modules/CheckCXXSymbolExists.cmake
index b112094..5c9079d 100644
--- a/Modules/CheckCXXSymbolExists.cmake
+++ b/Modules/CheckCXXSymbolExists.cmake
@@ -27,6 +27,17 @@ Check if a symbol exists as a function, variable, or macro in ``C++``.
not be recognized: consider using the :module:`CheckTypeSize`
or :module:`CheckCXXSourceCompiles` module instead.
+.. note::
+
+ This command is unreliable when ``<symbol>`` is (potentially) an overloaded
+ function. Since there is no reliable way to predict whether a given function
+ in the system environment may be defined as an overloaded function or may be
+ an overloaded function on other systems or will become so in the future, it
+ is generally advised to use the :module:`CheckCXXSourceCompiles` module for
+ checking any function symbol (unless somehow you surely know the checked
+ function is not overloaded on other systems or will not be so in the
+ future).
+
The following variables may be set before calling this macro to modify
the way the check is run:
diff --git a/Modules/CheckSymbolExists.cmake b/Modules/CheckSymbolExists.cmake
index c2f488a..1053383 100644
--- a/Modules/CheckSymbolExists.cmake
+++ b/Modules/CheckSymbolExists.cmake
@@ -99,8 +99,28 @@ macro(__CHECK_SYMBOL_EXISTS_IMPL SOURCEFILE SYMBOL FILES VARIABLE)
string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT
"#include <${FILE}>\n")
endforeach()
- string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT
- "\nint main(int argc, char** argv)\n{\n (void)argv;\n#ifndef ${SYMBOL}\n return ((int*)(&${SYMBOL}))[argc];\n#else\n (void)argc;\n return 0;\n#endif\n}\n")
+ string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT "
+int main(int argc, char** argv)
+{
+ (void)argv;")
+ set(_CSE_CHECK_NON_MACRO "return ((int*)(&${SYMBOL}))[argc];")
+ if("${SYMBOL}" MATCHES "^[a-zA-Z_][a-zA-Z0-9_]*$")
+ # The SYMBOL has a legal macro name. Test whether it exists as a macro.
+ string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT "
+#ifndef ${SYMBOL}
+ ${_CSE_CHECK_NON_MACRO}
+#else
+ (void)argc;
+ return 0;
+#endif")
+ else()
+ # The SYMBOL cannot be a macro (e.g., a template function).
+ string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT "
+ ${_CSE_CHECK_NON_MACRO}")
+ endif()
+ string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT "
+}")
+ unset(_CSE_CHECK_NON_MACRO)
configure_file("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in"
"${SOURCEFILE}" @ONLY)
@@ -139,6 +159,7 @@ macro(__CHECK_SYMBOL_EXISTS_IMPL SOURCEFILE SYMBOL FILES VARIABLE)
"${OUTPUT}\nFile ${SOURCEFILE}:\n"
"${CMAKE_CONFIGURABLE_FILE_CONTENT}\n")
endif()
+ unset(CMAKE_CONFIGURABLE_FILE_CONTENT)
endif()
endmacro()
diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake
index 17f3917..61709f8 100644
--- a/Modules/Compiler/Clang-CXX.cmake
+++ b/Modules/Compiler/Clang-CXX.cmake
@@ -58,6 +58,13 @@ if("x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU")
unset(_clang_version_std17)
if("x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
+ # The MSVC standard library requires C++14, and MSVC itself has no
+ # notion of operating in a mode not aware of at least that standard.
+ set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++14")
+ set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++14")
+ set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++14")
+ set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++14")
+
# This clang++ is missing some features because of MSVC compatibility.
unset(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT)
unset(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT)
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index 20b37d2..14fc231 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -261,7 +261,9 @@ External Project Definition
``GIT_SUBMODULES <module>...``
Specific git submodules that should also be updated. If this option is
- not provided, all git submodules will be updated.
+ not provided, all git submodules will be updated. When :policy:`CMP0097`
+ is set to ``NEW`` if this value is set to an empty string then no submodules
+ are initialized or updated.
``GIT_SHALLOW <bool>``
When this option is enabled, the ``git clone`` operation will be given
@@ -1016,6 +1018,9 @@ function(_ep_parse_arguments f name ns args)
endif()
else()
set(key "${arg}")
+ if(key MATCHES GIT)
+ get_property(have_key TARGET ${name} PROPERTY ${ns}${key} SET)
+ endif()
endif()
endforeach()
endfunction()
@@ -1060,7 +1065,7 @@ define_property(DIRECTORY PROPERTY "EP_UPDATE_DISCONNECTED" INHERITED
"ExternalProject module."
)
-function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag git_remote_name git_submodules git_shallow git_progress git_config src_name work_dir gitclone_infofile gitclone_stampfile tls_verify)
+function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag git_remote_name init_submodules git_submodules git_shallow git_progress git_config src_name work_dir gitclone_infofile gitclone_stampfile tls_verify)
if(NOT GIT_VERSION_STRING VERSION_LESS 1.8.5)
# Use `git checkout <tree-ish> --` to avoid ambiguity with a local path.
set(git_checkout_explicit-- "--")
@@ -1145,11 +1150,14 @@ if(error_code)
message(FATAL_ERROR \"Failed to checkout tag: '${git_tag}'\")
endif()
-execute_process(
- COMMAND \"${git_EXECUTABLE}\" ${git_options} submodule update --recursive --init ${git_submodules}
- WORKING_DIRECTORY \"${work_dir}/${src_name}\"
- RESULT_VARIABLE error_code
- )
+set(init_submodules ${init_submodules})
+if(init_submodules)
+ execute_process(
+ COMMAND \"${git_EXECUTABLE}\" ${git_options} submodule update --recursive --init ${git_submodules}
+ WORKING_DIRECTORY \"${work_dir}/${src_name}\"
+ RESULT_VARIABLE error_code
+ )
+endif()
if(error_code)
message(FATAL_ERROR \"Failed to update submodules in: '${work_dir}/${src_name}'\")
endif()
@@ -1226,7 +1234,7 @@ endif()
endfunction()
-function(_ep_write_gitupdate_script script_filename git_EXECUTABLE git_tag git_remote_name git_submodules git_repository work_dir)
+function(_ep_write_gitupdate_script script_filename git_EXECUTABLE git_tag git_remote_name init_submodules git_submodules git_repository work_dir)
if("${git_tag}" STREQUAL "")
message(FATAL_ERROR "Tag for git checkout should not be empty.")
endif()
@@ -1383,11 +1391,14 @@ if(error_code OR is_remote_ref OR NOT (\"\${tag_sha}\" STREQUAL \"\${head_sha}\"
endif()
endif()
- execute_process(
- COMMAND \"${git_EXECUTABLE}\" submodule update --recursive --init ${git_submodules}
- WORKING_DIRECTORY \"${work_dir}/${src_name}\"
- RESULT_VARIABLE error_code
- )
+ set(init_submodules ${init_submodules})
+ if(init_submodules)
+ execute_process(
+ COMMAND \"${git_EXECUTABLE}\" submodule update --recursive --init ${git_submodules}
+ WORKING_DIRECTORY \"${work_dir}/${src_name}\"
+ RESULT_VARIABLE error_code
+ )
+ endif()
if(error_code)
message(FATAL_ERROR \"Failed to update submodules in: '${work_dir}/${src_name}'\")
endif()
@@ -1972,7 +1983,7 @@ endif()
set(stderr_log "${logbase}-err.log")
endif()
set(code "
-cmake_minimum_required(VERSION 3.13)
+cmake_minimum_required(VERSION 3.15)
${code_cygpath_make}
set(command \"${command}\")
set(log_merged \"${log_merged}\")
@@ -2420,7 +2431,15 @@ function(_ep_add_download_command name)
if(NOT git_tag)
set(git_tag "master")
endif()
- get_property(git_submodules TARGET ${name} PROPERTY _EP_GIT_SUBMODULES)
+
+ set(git_init_submodules TRUE)
+ get_property(git_submodules_set TARGET ${name} PROPERTY _EP_GIT_SUBMODULES SET)
+ if(git_submodules_set)
+ get_property(git_submodules TARGET ${name} PROPERTY _EP_GIT_SUBMODULES)
+ if(git_submodules STREQUAL "" AND _EP_CMP0097 STREQUAL "NEW")
+ set(git_init_submodules FALSE)
+ endif()
+ endif()
get_property(git_remote_name TARGET ${name} PROPERTY _EP_GIT_REMOTE_NAME)
if(NOT git_remote_name)
@@ -2458,7 +2477,7 @@ function(_ep_add_download_command name)
# The script will delete the source directory and then call git clone.
#
_ep_write_gitclone_script(${tmp_dir}/${name}-gitclone.cmake ${source_dir}
- ${GIT_EXECUTABLE} ${git_repository} ${git_tag} ${git_remote_name} "${git_submodules}" "${git_shallow}" "${git_progress}" "${git_config}" ${src_name} ${work_dir}
+ ${GIT_EXECUTABLE} ${git_repository} ${git_tag} ${git_remote_name} ${git_init_submodules} "${git_submodules}" "${git_shallow}" "${git_progress}" "${git_config}" ${src_name} ${work_dir}
${stamp_dir}/${name}-gitinfo.txt ${stamp_dir}/${name}-gitclone-lastrun.txt "${tls_verify}"
)
set(comment "Performing download step (git clone) for '${name}'")
@@ -2723,9 +2742,18 @@ function(_ep_add_update_command name)
if(NOT git_remote_name)
set(git_remote_name "origin")
endif()
- get_property(git_submodules TARGET ${name} PROPERTY _EP_GIT_SUBMODULES)
+
+ set(git_init_submodules TRUE)
+ get_property(git_submodules_set TARGET ${name} PROPERTY _EP_GIT_SUBMODULES SET)
+ if(git_submodules_set)
+ get_property(git_submodules TARGET ${name} PROPERTY _EP_GIT_SUBMODULES)
+ if(git_submodules STREQUAL "" AND _EP_CMP0097 STREQUAL "NEW")
+ set(git_init_submodules FALSE)
+ endif()
+ endif()
+
_ep_write_gitupdate_script(${tmp_dir}/${name}-gitupdate.cmake
- ${GIT_EXECUTABLE} ${git_tag} ${git_remote_name} "${git_submodules}" ${git_repository} ${work_dir}
+ ${GIT_EXECUTABLE} ${git_tag} ${git_remote_name} ${git_init_submodules} "${git_submodules}" ${git_repository} ${work_dir}
)
set(cmd ${CMAKE_COMMAND} -P ${tmp_dir}/${name}-gitupdate.cmake)
set(always 1)
@@ -3138,6 +3166,10 @@ endfunction()
function(ExternalProject_Add name)
+ cmake_policy(GET CMP0097 _EP_CMP0097
+ PARENT_SCOPE # undocumented, do not use outside of CMake
+ )
+
_ep_get_configuration_subdir_suffix(cfgdir)
# Add a custom target for the external project.
diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake
index 2ff6afe..a79758f 100644
--- a/Modules/FindMPI.cmake
+++ b/Modules/FindMPI.cmake
@@ -1147,9 +1147,7 @@ macro(_MPI_create_imported_target LANG)
set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_DEFINITIONS "${MPI_${LANG}_COMPILE_DEFINITIONS}")
if(MPI_${LANG}_LINK_FLAGS)
- separate_arguments(_MPI_${LANG}_LINK_FLAGS NATIVE_COMMAND "${MPI_${LANG}_LINK_FLAGS}")
- set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_LINK_OPTIONS "${_MPI_${LANG}_LINK_FLAGS}")
- unset(_MPI_${LANG}_LINK_FLAGS)
+ set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_LINK_OPTIONS "SHELL:${MPI_${LANG}_LINK_FLAGS}")
endif()
# If the compiler links MPI implicitly, no libraries will be found as they're contained within
# CMAKE_<LANG>_IMPLICIT_LINK_LIBRARIES already.
diff --git a/Modules/InstallRequiredSystemLibraries.cmake b/Modules/InstallRequiredSystemLibraries.cmake
index 0a98895..e3eeea4 100644
--- a/Modules/InstallRequiredSystemLibraries.cmake
+++ b/Modules/InstallRequiredSystemLibraries.cmake
@@ -210,8 +210,8 @@ if(MSVC)
set(_MSVC_IDE_VERSION "")
if(MSVC_VERSION GREATER_EQUAL 2000)
message(WARNING "MSVC ${MSVC_VERSION} not yet supported.")
- elseif(MSVC_VERSION_VERSION GREATER_EQUAL 143)
- message(WARNING "MSVC toolset v${MSVC_VERSION_VERSION} not yet supported.")
+ elseif(MSVC_TOOLSET_VERSION GREATER_EQUAL 143)
+ message(WARNING "MSVC toolset v${MSVC_TOOLSET_VERSION} not yet supported.")
elseif(MSVC_TOOLSET_VERSION EQUAL 142)
set(MSVC_REDIST_NAME VC142)
set(_MSVC_DLL_VERSION 140)
@@ -251,10 +251,18 @@ if(MSVC)
endif()
if(NOT vs VERSION_LESS 15)
set(_vs_redist_paths "")
- cmake_host_system_information(RESULT _vs_dir QUERY VS_${vs}_DIR) # undocumented query
- if(IS_DIRECTORY "${_vs_dir}")
- file(GLOB _vs_redist_paths "${_vs_dir}/VC/Redist/MSVC/*")
- endif()
+ # The toolset and its redistributables may come with any VS version 15 or newer.
+ set(_MSVC_IDE_VERSIONS 16 15)
+ foreach(_vs_ver ${_MSVC_IDE_VERSIONS})
+ set(_vs_glob_redist_paths "")
+ cmake_host_system_information(RESULT _vs_dir QUERY VS_${_vs_ver}_DIR) # undocumented query
+ if(IS_DIRECTORY "${_vs_dir}")
+ file(GLOB _vs_glob_redist_paths "${_vs_dir}/VC/Redist/MSVC/*")
+ list(APPEND _vs_redist_paths ${_vs_glob_redist_paths})
+ endif()
+ unset(_vs_glob_redist_paths)
+ endforeach()
+ unset(_MSVC_IDE_VERSIONS)
unset(_vs_dir)
else()
get_filename_component(_vs_dir
diff --git a/Modules/Platform/Android-Clang.cmake b/Modules/Platform/Android-Clang.cmake
index 9ed1e01..847178f 100644
--- a/Modules/Platform/Android-Clang.cmake
+++ b/Modules/Platform/Android-Clang.cmake
@@ -40,6 +40,9 @@ macro(__android_compiler_clang lang)
endif()
if(NOT CMAKE_${lang}_COMPILER_TARGET)
set(CMAKE_${lang}_COMPILER_TARGET "${_ANDROID_ABI_CLANG_TARGET}")
+ if(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED)
+ string(APPEND CMAKE_${lang}_COMPILER_TARGET "${CMAKE_SYSTEM_VERSION}")
+ endif()
list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "--target=${CMAKE_${lang}_COMPILER_TARGET}")
endif()
endmacro()
diff --git a/Modules/Platform/Android-Common.cmake b/Modules/Platform/Android-Common.cmake
index f8b9346..1affcd0 100644
--- a/Modules/Platform/Android-Common.cmake
+++ b/Modules/Platform/Android-Common.cmake
@@ -47,7 +47,41 @@ if(CMAKE_ANDROID_NDK)
endif()
if(CMAKE_ANDROID_STL_TYPE)
- if(CMAKE_ANDROID_NDK)
+ if(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED)
+ if(CMAKE_ANDROID_STL_TYPE STREQUAL "system")
+ set(_ANDROID_STL_EXCEPTIONS 0)
+ set(_ANDROID_STL_RTTI 0)
+ macro(__android_stl lang)
+ string(APPEND CMAKE_${lang}_FLAGS_INIT " -stdlib=libstdc++")
+ endmacro()
+ elseif(CMAKE_ANDROID_STL_TYPE STREQUAL "c++_static")
+ set(_ANDROID_STL_EXCEPTIONS 1)
+ set(_ANDROID_STL_RTTI 1)
+ macro(__android_stl lang)
+ string(APPEND CMAKE_${lang}_FLAGS_INIT " -stdlib=libc++")
+ string(APPEND CMAKE_${lang}_STANDARD_LIBRARIES " -static-libstdc++")
+ endmacro()
+ elseif(CMAKE_ANDROID_STL_TYPE STREQUAL "c++_shared")
+ set(_ANDROID_STL_EXCEPTIONS 1)
+ set(_ANDROID_STL_RTTI 1)
+ macro(__android_stl lang)
+ string(APPEND CMAKE_${lang}_FLAGS_INIT " -stdlib=libc++")
+ endmacro()
+ elseif(CMAKE_ANDROID_STL_TYPE STREQUAL "none")
+ set(_ANDROID_STL_RTTI 0)
+ set(_ANDROID_STL_EXCEPTIONS 0)
+ macro(__android_stl lang)
+ # FIXME: Add a way to add project-wide language-specific compile-only flags.
+ set(CMAKE_CXX_COMPILE_OBJECT
+ "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE> -nostdinc++")
+ string(APPEND CMAKE_${lang}_STANDARD_LIBRARIES " -nostdlib++")
+ endmacro()
+ else()
+ message(FATAL_ERROR
+ "Android: STL '${CMAKE_ANDROID_STL_TYPE}' not supported by this NDK."
+ )
+ endif()
+ elseif(CMAKE_ANDROID_NDK)
macro(__android_stl_inc lang dir req)
if(EXISTS "${dir}")
@@ -152,6 +186,10 @@ macro(__android_compiler_common lang)
__android_stl(CXX)
endif()
+ if(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED)
+ string(APPEND CMAKE_${lang}_STANDARD_LIBRARIES " -latomic -lm")
+ endif()
+
# <ndk>/build/core/definitions.mk appends the sysroot's include directory
# explicitly at the end of the command-line include path so that it
# precedes the toolchain's builtin include directories. This is
@@ -161,7 +199,7 @@ macro(__android_compiler_common lang)
#
# Do not do this for a standalone toolchain because it is already
# tied to a specific API version.
- if(CMAKE_ANDROID_NDK)
+ if(CMAKE_ANDROID_NDK AND NOT CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED)
if(CMAKE_SYSROOT_COMPILE)
set(_cmake_sysroot_compile "${CMAKE_SYSROOT_COMPILE}")
else()
@@ -170,7 +208,7 @@ macro(__android_compiler_common lang)
if(NOT CMAKE_ANDROID_NDK_DEPRECATED_HEADERS)
list(APPEND CMAKE_${lang}_STANDARD_INCLUDE_DIRECTORIES
"${_cmake_sysroot_compile}/usr/include"
- "${_cmake_sysroot_compile}/usr/include/${CMAKE_ANDROID_ARCH_HEADER_TRIPLE}"
+ "${_cmake_sysroot_compile}/usr/include/${CMAKE_ANDROID_ARCH_TRIPLE}"
)
else()
list(APPEND CMAKE_${lang}_STANDARD_INCLUDE_DIRECTORIES "${_cmake_sysroot_compile}/usr/include")
diff --git a/Modules/Platform/Android-Determine.cmake b/Modules/Platform/Android-Determine.cmake
index bb42eed..e7c1b48 100644
--- a/Modules/Platform/Android-Determine.cmake
+++ b/Modules/Platform/Android-Determine.cmake
@@ -198,32 +198,66 @@ if(NOT CMAKE_SYSTEM_VERSION MATCHES "^[0-9]+$")
message(FATAL_ERROR "Android: The API specified by CMAKE_SYSTEM_VERSION='${CMAKE_SYSTEM_VERSION}' is not an integer.")
endif()
+if(CMAKE_ANDROID_NDK)
+ # Identify the host platform.
+ if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
+ if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
+ set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG "darwin-x86_64")
+ else()
+ set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG "darwin-x86")
+ endif()
+ elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
+ if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
+ set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG "linux-x86_64")
+ else()
+ set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG "linux-x86")
+ endif()
+ elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
+ if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "AMD64")
+ set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG "windows-x86_64")
+ else()
+ set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG "windows")
+ endif()
+ else()
+ message(FATAL_ERROR "Android: Builds hosted on '${CMAKE_HOST_SYSTEM_NAME}' not supported.")
+ endif()
+
+ # Look for a unified toolchain/sysroot provided with the NDK.
+ set(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED "${CMAKE_ANDROID_NDK}/toolchains/llvm/prebuilt/${CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG}")
+ if(NOT IS_DIRECTORY "${CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED}/sysroot")
+ set(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED "")
+ endif()
+else()
+ set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG "")
+ set(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED "")
+endif()
+
# https://developer.android.com/ndk/guides/abis.html
set(_ANDROID_ABI_arm64-v8a_PROC "aarch64")
set(_ANDROID_ABI_arm64-v8a_ARCH "arm64")
-set(_ANDROID_ABI_arm64-v8a_HEADER "aarch64-linux-android")
+set(_ANDROID_ABI_arm64-v8a_TRIPLE "aarch64-linux-android")
set(_ANDROID_ABI_armeabi-v7a_PROC "armv7-a")
set(_ANDROID_ABI_armeabi-v7a_ARCH "arm")
-set(_ANDROID_ABI_armeabi-v7a_HEADER "arm-linux-androideabi")
+set(_ANDROID_ABI_armeabi-v7a_TRIPLE "arm-linux-androideabi")
set(_ANDROID_ABI_armeabi-v6_PROC "armv6")
set(_ANDROID_ABI_armeabi-v6_ARCH "arm")
-set(_ANDROID_ABI_armeabi-v6_HEADER "arm-linux-androideabi")
+set(_ANDROID_ABI_armeabi-v6_TRIPLE "arm-linux-androideabi")
set(_ANDROID_ABI_armeabi_PROC "armv5te")
set(_ANDROID_ABI_armeabi_ARCH "arm")
-set(_ANDROID_ABI_armeabi_HEADER "arm-linux-androideabi")
+set(_ANDROID_ABI_armeabi_TRIPLE "arm-linux-androideabi")
set(_ANDROID_ABI_mips_PROC "mips")
set(_ANDROID_ABI_mips_ARCH "mips")
-set(_ANDROID_ABI_mips_HEADER "mipsel-linux-android")
+set(_ANDROID_ABI_mips_TRIPLE "mipsel-linux-android")
set(_ANDROID_ABI_mips64_PROC "mips64")
set(_ANDROID_ABI_mips64_ARCH "mips64")
-set(_ANDROID_ABI_mips64_HEADER "mips64el-linux-android")
+set(_ANDROID_ABI_mips64_TRIPLE "mips64el-linux-android")
set(_ANDROID_ABI_x86_PROC "i686")
set(_ANDROID_ABI_x86_ARCH "x86")
-set(_ANDROID_ABI_x86_HEADER "i686-linux-android")
+set(_ANDROID_ABI_x86_TRIPLE "i686-linux-android")
set(_ANDROID_ABI_x86_64_PROC "x86_64")
set(_ANDROID_ABI_x86_64_ARCH "x86_64")
-set(_ANDROID_ABI_x86_64_HEADER "x86_64-linux-android")
+set(_ANDROID_ABI_x86_64_TRIPLE "x86_64-linux-android")
set(_ANDROID_PROC_aarch64_ARCH_ABI "arm64-v8a")
set(_ANDROID_PROC_armv7-a_ARCH_ABI "armeabi-v7a")
@@ -308,7 +342,7 @@ if(_ANDROID_SYSROOT_ARCH AND NOT "x${_ANDROID_SYSROOT_ARCH}" STREQUAL "x${CMAKE_
"does not match architecture '${CMAKE_ANDROID_ARCH}' for the ABI '${CMAKE_ANDROID_ARCH_ABI}'."
)
endif()
-set(CMAKE_ANDROID_ARCH_HEADER_TRIPLE "${_ANDROID_ABI_${CMAKE_ANDROID_ARCH_ABI}_HEADER}")
+set(CMAKE_ANDROID_ARCH_TRIPLE "${_ANDROID_ABI_${CMAKE_ANDROID_ARCH_ABI}_TRIPLE}")
# Select a processor.
if(NOT CMAKE_SYSTEM_PROCESSOR)
@@ -321,7 +355,7 @@ if(NOT _ANDROID_ABI_${CMAKE_ANDROID_ARCH_ABI}_PROC STREQUAL CMAKE_SYSTEM_PROCESS
endif()
if(CMAKE_ANDROID_NDK AND NOT DEFINED CMAKE_ANDROID_NDK_DEPRECATED_HEADERS)
- if(IS_DIRECTORY "${CMAKE_ANDROID_NDK}/sysroot/usr/include/${CMAKE_ANDROID_ARCH_HEADER_TRIPLE}")
+ if(IS_DIRECTORY "${CMAKE_ANDROID_NDK}/sysroot/usr/include/${CMAKE_ANDROID_ARCH_TRIPLE}")
# Unified headers exist so we use them by default.
set(CMAKE_ANDROID_NDK_DEPRECATED_HEADERS 0)
else()
@@ -340,8 +374,10 @@ set(CMAKE_ANDROID_ARCH_ABI \"${CMAKE_ANDROID_ARCH_ABI}\")
if(CMAKE_ANDROID_NDK)
string(APPEND CMAKE_SYSTEM_CUSTOM_CODE
- "set(CMAKE_ANDROID_ARCH_HEADER_TRIPLE \"${CMAKE_ANDROID_ARCH_HEADER_TRIPLE}\")\n"
+ "set(CMAKE_ANDROID_ARCH_TRIPLE \"${CMAKE_ANDROID_ARCH_TRIPLE}\")\n"
"set(CMAKE_ANDROID_NDK_DEPRECATED_HEADERS \"${CMAKE_ANDROID_NDK_DEPRECATED_HEADERS}\")\n"
+ "set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG \"${CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG}\")\n"
+ "set(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED \"${CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED}\")\n"
)
endif()
diff --git a/Modules/Platform/Android-Initialize.cmake b/Modules/Platform/Android-Initialize.cmake
index a434f90..a5d2820 100644
--- a/Modules/Platform/Android-Initialize.cmake
+++ b/Modules/Platform/Android-Initialize.cmake
@@ -17,6 +17,13 @@ if(CMAKE_SYSTEM_VERSION EQUAL 1)
return()
endif()
+set(CMAKE_BUILD_TYPE_INIT Debug)
+
+# Skip sysroot selection if the NDK has a unified toolchain.
+if(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED)
+ return()
+endif()
+
if(NOT CMAKE_SYSROOT)
if(CMAKE_ANDROID_NDK)
set(CMAKE_SYSROOT "${CMAKE_ANDROID_NDK}/platforms/android-${CMAKE_SYSTEM_VERSION}/arch-${CMAKE_ANDROID_ARCH}")
@@ -40,5 +47,3 @@ else()
"Android: No CMAKE_SYSROOT was selected."
)
endif()
-
-set(CMAKE_BUILD_TYPE_INIT Debug)
diff --git a/Modules/Platform/Android/Determine-Compiler-NDK.cmake b/Modules/Platform/Android/Determine-Compiler-NDK.cmake
index 5f2cc52..e009c10 100644
--- a/Modules/Platform/Android/Determine-Compiler-NDK.cmake
+++ b/Modules/Platform/Android/Determine-Compiler-NDK.cmake
@@ -1,6 +1,31 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
+# In Android NDK r19 and above there is a single clang toolchain.
+if(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED)
+ if(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION AND NOT CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION STREQUAL "clang")
+ message(FATAL_ERROR
+ "Android: The CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION value '${CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION}' "
+ "is not supported by this NDK. It must be 'clang' or not set at all."
+ )
+ endif()
+ message(STATUS "Android: Selected unified Clang toolchain")
+ set(_ANDROID_TOOL_NDK_TOOLCHAIN_VERSION "clang")
+ set(_ANDROID_TOOL_C_COMPILER "${CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED}/bin/clang${_ANDROID_HOST_EXT}")
+ set(_ANDROID_TOOL_C_TOOLCHAIN_MACHINE "${CMAKE_ANDROID_ARCH_TRIPLE}")
+ set(_ANDROID_TOOL_C_TOOLCHAIN_VERSION "")
+ set(_ANDROID_TOOL_C_COMPILER_EXTERNAL_TOOLCHAIN "")
+ set(_ANDROID_TOOL_C_TOOLCHAIN_PREFIX "${CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED}/bin/${CMAKE_ANDROID_ARCH_TRIPLE}-")
+ set(_ANDROID_TOOL_C_TOOLCHAIN_SUFFIX "${_ANDROID_HOST_EXT}")
+ set(_ANDROID_TOOL_CXX_COMPILER "${CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED}/bin/clang++${_ANDROID_HOST_EXT}")
+ set(_ANDROID_TOOL_CXX_TOOLCHAIN_MACHINE "${CMAKE_ANDROID_ARCH_TRIPLE}")
+ set(_ANDROID_TOOL_CXX_TOOLCHAIN_VERSION "")
+ set(_ANDROID_TOOL_CXX_COMPILER_EXTERNAL_TOOLCHAIN "")
+ set(_ANDROID_TOOL_CXX_TOOLCHAIN_PREFIX "${CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED}/bin/${CMAKE_ANDROID_ARCH_TRIPLE}-")
+ set(_ANDROID_TOOL_CXX_TOOLCHAIN_SUFFIX "${_ANDROID_HOST_EXT}")
+ return()
+endif()
+
# In Android NDK releases there is build system toolchain selection logic in
# these files:
#
@@ -195,40 +220,16 @@ if(NOT _ANDROID_TOOL_PREFIX AND "${_ANDROID_TOOL_NAME}" MATCHES "^(.*-)[0-9.]+$"
set(_ANDROID_TOOL_PREFIX "${CMAKE_MATCH_1}")
endif()
-# Identify the host platform.
-if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
- if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
- set(_ANDROID_HOST_DIR "darwin-x86_64")
- else()
- set(_ANDROID_HOST_DIR "darwin-x86")
- endif()
-elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
- if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
- set(_ANDROID_HOST_DIR "linux-x86_64")
- else()
- set(_ANDROID_HOST_DIR "linux-x86")
- endif()
-elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
- if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "AMD64")
- set(_ANDROID_HOST_DIR "windows-x86_64")
- else()
- set(_ANDROID_HOST_DIR "windows")
- endif()
-else()
- message(FATAL_ERROR "Android: Builds hosted on '${CMAKE_HOST_SYSTEM_NAME}' not supported.")
-endif()
-
# Help CMakeFindBinUtils locate things.
set(_CMAKE_TOOLCHAIN_PREFIX "${_ANDROID_TOOL_PREFIX}")
-set(_ANDROID_TOOL_NDK_TOOLCHAIN_HOST_TAG "${_ANDROID_HOST_DIR}")
set(_ANDROID_TOOL_NDK_TOOLCHAIN_VERSION "${_ANDROID_TOOL_VERS_NDK}")
# _ANDROID_TOOL_PREFIX should now match `gcc -dumpmachine`.
string(REGEX REPLACE "-$" "" _ANDROID_TOOL_C_TOOLCHAIN_MACHINE "${_ANDROID_TOOL_PREFIX}")
set(_ANDROID_TOOL_C_TOOLCHAIN_VERSION "${_ANDROID_TOOL_VERS}")
-set(_ANDROID_TOOL_C_TOOLCHAIN_PREFIX "${CMAKE_ANDROID_NDK}/toolchains/${_ANDROID_TOOL_NAME}/prebuilt/${_ANDROID_HOST_DIR}/bin/${_ANDROID_TOOL_PREFIX}")
+set(_ANDROID_TOOL_C_TOOLCHAIN_PREFIX "${CMAKE_ANDROID_NDK}/toolchains/${_ANDROID_TOOL_NAME}/prebuilt/${CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG}/bin/${_ANDROID_TOOL_PREFIX}")
set(_ANDROID_TOOL_C_TOOLCHAIN_SUFFIX "${_ANDROID_HOST_EXT}")
set(_ANDROID_TOOL_CXX_TOOLCHAIN_MACHINE "${_ANDROID_TOOL_C_TOOLCHAIN_MACHINE}")
@@ -238,9 +239,9 @@ set(_ANDROID_TOOL_CXX_TOOLCHAIN_SUFFIX "${_ANDROID_TOOL_C_TOOLCHAIN_SUFFIX}")
if(_ANDROID_TOOL_CLANG_NAME)
message(STATUS "Android: Selected Clang toolchain '${_ANDROID_TOOL_CLANG_NAME}' with GCC toolchain '${_ANDROID_TOOL_NAME}'")
- set(_ANDROID_TOOL_C_COMPILER "${CMAKE_ANDROID_NDK}/toolchains/${_ANDROID_TOOL_LLVM_NAME}/prebuilt/${_ANDROID_HOST_DIR}/bin/clang${_ANDROID_HOST_EXT}")
- set(_ANDROID_TOOL_C_COMPILER_EXTERNAL_TOOLCHAIN ${CMAKE_ANDROID_NDK}/toolchains/${_ANDROID_TOOL_NAME}/prebuilt/${_ANDROID_HOST_DIR})
- set(_ANDROID_TOOL_CXX_COMPILER "${CMAKE_ANDROID_NDK}/toolchains/${_ANDROID_TOOL_LLVM_NAME}/prebuilt/${_ANDROID_HOST_DIR}/bin/clang++${_ANDROID_HOST_EXT}")
+ set(_ANDROID_TOOL_C_COMPILER "${CMAKE_ANDROID_NDK}/toolchains/${_ANDROID_TOOL_LLVM_NAME}/prebuilt/${CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG}/bin/clang${_ANDROID_HOST_EXT}")
+ set(_ANDROID_TOOL_C_COMPILER_EXTERNAL_TOOLCHAIN ${CMAKE_ANDROID_NDK}/toolchains/${_ANDROID_TOOL_NAME}/prebuilt/${CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG})
+ set(_ANDROID_TOOL_CXX_COMPILER "${CMAKE_ANDROID_NDK}/toolchains/${_ANDROID_TOOL_LLVM_NAME}/prebuilt/${CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG}/bin/clang++${_ANDROID_HOST_EXT}")
set(_ANDROID_TOOL_CXX_COMPILER_EXTERNAL_TOOLCHAIN "${_ANDROID_TOOL_C_COMPILER_EXTERNAL_TOOLCHAIN}")
else()
message(STATUS "Android: Selected GCC toolchain '${_ANDROID_TOOL_NAME}'")
@@ -267,4 +268,3 @@ unset(_ANDROID_TOOL_PREFIX)
unset(_ANDROID_TOOL_CLANG_NAME)
unset(_ANDROID_TOOL_CLANG_VERS)
unset(_ANDROID_TOOL_LLVM_NAME)
-unset(_ANDROID_HOST_DIR)
diff --git a/Modules/Platform/Android/Determine-Compiler-Standalone.cmake b/Modules/Platform/Android/Determine-Compiler-Standalone.cmake
index 4c1ac1f..5095aff 100644
--- a/Modules/Platform/Android/Determine-Compiler-Standalone.cmake
+++ b/Modules/Platform/Android/Determine-Compiler-Standalone.cmake
@@ -62,5 +62,4 @@ else()
set(_ANDROID_TOOL_CXX_COMPILER_EXTERNAL_TOOLCHAIN "")
endif()
-set(_ANDROID_TOOL_NDK_TOOLCHAIN_HOST_TAG "")
set(_ANDROID_TOOL_NDK_TOOLCHAIN_VERSION "")
diff --git a/Modules/Platform/Android/Determine-Compiler.cmake b/Modules/Platform/Android/Determine-Compiler.cmake
index a03ebcc..5c6b97b 100644
--- a/Modules/Platform/Android/Determine-Compiler.cmake
+++ b/Modules/Platform/Android/Determine-Compiler.cmake
@@ -40,7 +40,6 @@ if(CMAKE_ANDROID_NDK)
elseif(CMAKE_ANDROID_STANDALONE_TOOLCHAIN)
include(Platform/Android/Determine-Compiler-Standalone)
else()
- set(_ANDROID_TOOL_NDK_TOOLCHAIN_HOST_TAG "")
set(_ANDROID_TOOL_NDK_TOOLCHAIN_VERSION "")
set(_ANDROID_TOOL_C_COMPILER "")
set(_ANDROID_TOOL_C_TOOLCHAIN_MACHINE "")
@@ -65,7 +64,6 @@ macro(__android_determine_compiler lang)
# Save the Android-specific information in CMake${lang}Compiler.cmake.
set(CMAKE_${lang}_COMPILER_CUSTOM_CODE "
-set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG \"${_ANDROID_TOOL_NDK_TOOLCHAIN_HOST_TAG}\")
set(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION \"${_ANDROID_TOOL_NDK_TOOLCHAIN_VERSION}\")
set(CMAKE_${lang}_ANDROID_TOOLCHAIN_MACHINE \"${_ANDROID_TOOL_${lang}_TOOLCHAIN_MACHINE}\")
set(CMAKE_${lang}_ANDROID_TOOLCHAIN_VERSION \"${_ANDROID_TOOL_${lang}_TOOLCHAIN_VERSION}\")
diff --git a/Modules/Platform/Android/abi-common.cmake b/Modules/Platform/Android/abi-common.cmake
index 6bce3c7..b01ef61 100644
--- a/Modules/Platform/Android/abi-common.cmake
+++ b/Modules/Platform/Android/abi-common.cmake
@@ -3,7 +3,7 @@ string(APPEND _ANDROID_ABI_INIT_CFLAGS
" -no-canonical-prefixes"
)
-if(CMAKE_ANDROID_NDK AND NOT CMAKE_ANDROID_NDK_DEPRECATED_HEADERS)
+if(CMAKE_ANDROID_NDK AND NOT CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED AND NOT CMAKE_ANDROID_NDK_DEPRECATED_HEADERS)
string(APPEND _ANDROID_ABI_INIT_CFLAGS " -D__ANDROID_API__=${CMAKE_SYSTEM_VERSION}")
endif()