summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CMakeDetermineCompilerId.cmake4
-rw-r--r--Modules/Compiler/IAR.cmake10
-rw-r--r--Modules/Compiler/NVHPC-Fortran.cmake1
-rw-r--r--Modules/Compiler/NVHPC.cmake2
-rw-r--r--Modules/CompilerId/VS-10.vcxproj.in3
-rw-r--r--Modules/ExternalProject.cmake20
-rw-r--r--Modules/ExternalProject/shared_internal_commands.cmake182
-rw-r--r--Modules/FetchContent.cmake27
-rw-r--r--Modules/FindCUDAToolkit.cmake13
-rw-r--r--Modules/Platform/Android-Determine.cmake34
-rw-r--r--Modules/Platform/Android/VCXProjInspect.vcxproj.in3
11 files changed, 276 insertions, 23 deletions
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index 67044fb3b2..403766e561 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -345,6 +345,7 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
set(id_platform ${CMAKE_VS_PLATFORM_NAME})
set(id_lang "${lang}")
set(id_PostBuildEvent_Command "")
+ set(id_api_level "")
if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "^[Ll][Ll][Vv][Mm](_v[0-9]+(_xp)?)?$")
set(id_cl_var "ClangClExecutable")
elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "^[Cc][Ll][Aa][Nn][Gg]([Cc][Ll]$|_[0-9])")
@@ -430,9 +431,10 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
set(id_system "")
endif()
if(id_keyword STREQUAL "Android")
+ set(id_api_level "<AndroidAPILevel>android-${CMAKE_SYSTEM_VERSION}</AndroidAPILevel>")
if(CMAKE_GENERATOR MATCHES "Visual Studio 14")
set(id_system_version "<ApplicationTypeRevision>2.0</ApplicationTypeRevision>")
- elseif(CMAKE_GENERATOR MATCHES "Visual Studio 1[56]")
+ elseif(CMAKE_GENERATOR MATCHES "Visual Studio 1[567]")
set(id_system_version "<ApplicationTypeRevision>3.0</ApplicationTypeRevision>")
else()
set(id_system_version "")
diff --git a/Modules/Compiler/IAR.cmake b/Modules/Compiler/IAR.cmake
index 0aca2838a7..32a7b3f5af 100644
--- a/Modules/Compiler/IAR.cmake
+++ b/Modules/Compiler/IAR.cmake
@@ -1,6 +1,6 @@
# This file is processed when the IAR C/C++ Compiler is used
#
-# CPU <arch> supported in CMake: 8051, Arm, AVR, MSP430, RH850, RISC-V, RL78, RX and V850
+# CPU <arch> supported in CMake: 8051, Arm, AVR, MSP430, RH850, RISC-V, RL78, RX, STM8 and V850
#
# The compiler user documentation is architecture-dependent
# and it can found with the product installation under <arch>/doc/{EW,BX}<arch>_DevelopmentGuide.ENU.pdf
@@ -35,7 +35,9 @@ macro(__compiler_iar_ilink lang)
__compiler_iar_common(${lang})
- set(CMAKE_${lang}_LINK_EXECUTABLE "<CMAKE_LINKER> --silent <OBJECTS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>")
+ string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " --silent")
+ set(CMAKE_${lang}_LINK_EXECUTABLE "<CMAKE_LINKER> <OBJECTS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>")
+
set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "<CMAKE_AR> <TARGET> --create <LINK_FLAGS> <OBJECTS>")
set(CMAKE_${lang}_ARCHIVE_CREATE "<CMAKE_AR> <TARGET> --create <LINK_FLAGS> <OBJECTS>")
set(CMAKE_${lang}_ARCHIVE_APPEND "<CMAKE_AR> <TARGET> --replace <LINK_FLAGS> <OBJECTS>")
@@ -46,7 +48,9 @@ macro(__compiler_iar_xlink lang)
__compiler_iar_common(${lang})
- set(CMAKE_${lang}_LINK_EXECUTABLE "<CMAKE_LINKER> -S <OBJECTS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>")
+ string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " -S")
+ set(CMAKE_${lang}_LINK_EXECUTABLE "<CMAKE_LINKER> <OBJECTS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>")
+
set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "<CMAKE_AR> <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_${lang}_ARCHIVE_CREATE "<CMAKE_AR> <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_${lang}_ARCHIVE_APPEND "")
diff --git a/Modules/Compiler/NVHPC-Fortran.cmake b/Modules/Compiler/NVHPC-Fortran.cmake
index 5c0645737d..59755b3a71 100644
--- a/Modules/Compiler/NVHPC-Fortran.cmake
+++ b/Modules/Compiler/NVHPC-Fortran.cmake
@@ -1,4 +1,3 @@
include(Compiler/PGI-Fortran)
include(Compiler/NVHPC)
__compiler_nvhpc(Fortran)
-set(CMAKE_Fortran_PREPROCESS_SOURCE_EXCLUDE_FLAGS_REGEX "(^| )-Werror +[a-z][a-z-]+( |$)")
diff --git a/Modules/Compiler/NVHPC.cmake b/Modules/Compiler/NVHPC.cmake
index 474ac80efe..0593456ce7 100644
--- a/Modules/Compiler/NVHPC.cmake
+++ b/Modules/Compiler/NVHPC.cmake
@@ -13,5 +13,5 @@ include(Compiler/PGI)
macro(__compiler_nvhpc lang)
# Logic specific to NVHPC.
set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ")
- set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-Werror" "all-warnings")
+ set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-Werror")
endmacro()
diff --git a/Modules/CompilerId/VS-10.vcxproj.in b/Modules/CompilerId/VS-10.vcxproj.in
index 3598fc7e20..fa324d8214 100644
--- a/Modules/CompilerId/VS-10.vcxproj.in
+++ b/Modules/CompilerId/VS-10.vcxproj.in
@@ -26,6 +26,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@id_platform@'" Label="Configuration">
<ConfigurationType>@id_config_type@</ConfigurationType>
@id_toolset@
+ @id_api_level@
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@@ -44,7 +45,7 @@
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <RuntimeLibrary Condition="'$(ApplicationType)'!='Android'">MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>TurnOffAllWarnings</WarningLevel>
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index 9a6cbd6bc4..e2cc497a65 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -278,6 +278,13 @@ External Project Definition
URL of the git repository. Any URL understood by the ``git`` command
may be used.
+ .. versionchanged:: 3.27
+ A relative URL will be resolved based on the parent project's
+ remote, subject to :policy:`CMP0150`. See the policy documentation
+ for how the remote is selected, including conditions where the
+ remote selection can fail. Local filesystem remotes should
+ always use absolute paths.
+
``GIT_TAG <tag>``
Git branch name, tag or commit hash. Note that branch names and tags
should generally be specified as remote names (i.e. ``origin/myBranch``
@@ -1188,6 +1195,8 @@ The custom step could then be triggered from the main build like so::
#]=======================================================================]
+include(${CMAKE_CURRENT_LIST_DIR}/ExternalProject/shared_internal_commands.cmake)
+
cmake_policy(PUSH)
cmake_policy(SET CMP0054 NEW) # if() quoted variables not dereferenced
cmake_policy(SET CMP0057 NEW) # if() supports IN_LIST
@@ -4159,6 +4168,17 @@ function(ExternalProject_Add name)
set_property(TARGET ${name} PROPERTY EXCLUDE_FROM_ALL TRUE)
endif()
+ get_property(repo TARGET ${name} PROPERTY _EP_GIT_REPOSITORY)
+ if(NOT repo STREQUAL "")
+ cmake_policy(GET CMP0150 cmp0150
+ PARENT_SCOPE # undocumented, do not use outside of CMake
+ )
+ get_property(source_dir TARGET ${name} PROPERTY _EP_SOURCE_DIR)
+ get_filename_component(work_dir "${source_dir}" PATH)
+ _ep_resolve_git_remote(resolved_git_repository "${repo}" "${cmp0150}" "${work_dir}")
+ set_property(TARGET ${name} PROPERTY _EP_GIT_REPOSITORY ${resolved_git_repository})
+ endif()
+
# The 'complete' step depends on all other steps and creates a
# 'done' mark. A dependent external project's 'configure' step
# depends on the 'done' mark so that it rebuilds when this project
diff --git a/Modules/ExternalProject/shared_internal_commands.cmake b/Modules/ExternalProject/shared_internal_commands.cmake
new file mode 100644
index 0000000000..ca3cd9fec7
--- /dev/null
+++ b/Modules/ExternalProject/shared_internal_commands.cmake
@@ -0,0 +1,182 @@
+cmake_policy(VERSION 3.25)
+
+# Determine the remote URL of the project containing the working_directory.
+# This will leave output_variable unset if the URL can't be determined.
+function(_ep_get_git_remote_url output_variable working_directory)
+ set("${output_variable}" "" PARENT_SCOPE)
+
+ find_package(Git QUIET REQUIRED)
+
+ execute_process(
+ COMMAND ${GIT_EXECUTABLE} symbolic-ref --short HEAD
+ WORKING_DIRECTORY "${working_directory}"
+ OUTPUT_VARIABLE git_symbolic_ref
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_QUIET
+ )
+
+ if(NOT git_symbolic_ref STREQUAL "")
+ # We are potentially on a branch. See if that branch is associated with
+ # an upstream remote (might be just a local one or not a branch at all).
+ execute_process(
+ COMMAND ${GIT_EXECUTABLE} config branch.${git_symbolic_ref}.remote
+ WORKING_DIRECTORY "${working_directory}"
+ OUTPUT_VARIABLE git_remote_name
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_QUIET
+ )
+ endif()
+
+ if(NOT git_remote_name)
+ # Can't select a remote based on a branch. If there's only one remote,
+ # or we have multiple remotes but one is called "origin", choose that.
+ execute_process(
+ COMMAND ${GIT_EXECUTABLE} remote
+ WORKING_DIRECTORY "${working_directory}"
+ OUTPUT_VARIABLE git_remote_list
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_QUIET
+ )
+ string(REPLACE "\n" ";" git_remote_list "${git_remote_list}")
+ list(LENGTH git_remote_list git_remote_list_length)
+
+ if(git_remote_list_length EQUAL 0)
+ message(FATAL_ERROR "Git remote not found in parent project.")
+ elseif(git_remote_list_length EQUAL 1)
+ list(GET git_remote_list 0 git_remote_name)
+ else()
+ set(base_warning_msg "Multiple git remotes found for parent project")
+ if("origin" IN_LIST git_remote_list)
+ message(WARNING "${base_warning_msg}, defaulting to origin.")
+ set(git_remote_name "origin")
+ else()
+ message(FATAL_ERROR "${base_warning_msg}, none of which are origin.")
+ endif()
+ endif()
+ endif()
+
+ if(GIT_VERSION VERSION_LESS 1.7.5)
+ set(_git_remote_url_cmd_args config remote.${git_remote_name}.url)
+ elseif(GIT_VERSION VERSION_LESS 2.7)
+ set(_git_remote_url_cmd_args ls-remote --get-url ${git_remote_name})
+ else()
+ set(_git_remote_url_cmd_args remote get-url ${git_remote_name})
+ endif()
+
+ execute_process(
+ COMMAND ${GIT_EXECUTABLE} ${_git_remote_url_cmd_args}
+ WORKING_DIRECTORY "${working_directory}"
+ OUTPUT_VARIABLE git_remote_url
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ COMMAND_ERROR_IS_FATAL LAST
+ ENCODING UTF-8 # Needed to handle non-ascii characters in local paths
+ )
+
+ set("${output_variable}" "${git_remote_url}" PARENT_SCOPE)
+endfunction()
+
+function(_ep_is_relative_git_remote output_variable remote_url)
+ if(remote_url MATCHES "^\\.\\./")
+ set("${output_variable}" TRUE PARENT_SCOPE)
+ else()
+ set("${output_variable}" FALSE PARENT_SCOPE)
+ endif()
+endfunction()
+
+# Return an absolute remote URL given an existing remote URL and relative path.
+# The output_variable will be set to an empty string if an absolute URL
+# could not be computed (no error message is output).
+function(_ep_resolve_relative_git_remote
+ output_variable
+ parent_remote_url
+ relative_remote_url
+)
+ set("${output_variable}" "" PARENT_SCOPE)
+
+ if(parent_remote_url STREQUAL "")
+ return()
+ endif()
+
+ string(REGEX MATCH
+ "^(([A-Za-z0-9][A-Za-z0-9+.-]*)://)?(([^/@]+)@)?(\\[[A-Za-z0-9:]+\\]|[^/:]+)?([/:]/?)(.+(\\.git)?/?)$"
+ git_remote_url_components
+ "${parent_remote_url}"
+ )
+
+ set(protocol "${CMAKE_MATCH_1}")
+ set(auth "${CMAKE_MATCH_3}")
+ set(host "${CMAKE_MATCH_5}")
+ set(separator "${CMAKE_MATCH_6}")
+ set(path "${CMAKE_MATCH_7}")
+
+ string(REPLACE "/" ";" remote_path_components "${path}")
+ string(REPLACE "/" ";" relative_path_components "${relative_remote_url}")
+
+ foreach(relative_path_component IN LISTS relative_path_components)
+ if(NOT relative_path_component STREQUAL "..")
+ break()
+ endif()
+
+ list(LENGTH remote_path_components remote_path_component_count)
+
+ if(remote_path_component_count LESS 1)
+ return()
+ endif()
+
+ list(POP_BACK remote_path_components)
+ list(POP_FRONT relative_path_components)
+ endforeach()
+
+ list(APPEND final_path_components ${remote_path_components} ${relative_path_components})
+ list(JOIN final_path_components "/" path)
+
+ set("${output_variable}" "${protocol}${auth}${host}${separator}${path}" PARENT_SCOPE)
+endfunction()
+
+# The output_variable will be set to the original git_repository if it
+# could not be resolved (no error message is output). The original value is
+# also returned if it doesn't need to be resolved.
+function(_ep_resolve_git_remote
+ output_variable
+ git_repository
+ cmp0150
+ cmp0150_old_base_dir
+)
+ if(git_repository STREQUAL "")
+ set("${output_variable}" "" PARENT_SCOPE)
+ return()
+ endif()
+
+ _ep_is_relative_git_remote(_git_repository_is_relative "${git_repository}")
+
+ if(NOT _git_repository_is_relative)
+ set("${output_variable}" "${git_repository}" PARENT_SCOPE)
+ return()
+ endif()
+
+ if(cmp0150 STREQUAL "NEW")
+ _ep_get_git_remote_url(_parent_git_remote_url "${CMAKE_CURRENT_SOURCE_DIR}")
+ _ep_resolve_relative_git_remote(_resolved_git_remote_url "${_parent_git_remote_url}" "${git_repository}")
+
+ if(_resolved_git_remote_url STREQUAL "")
+ message(FATAL_ERROR
+ "Failed to resolve relative git remote URL:\n"
+ " Relative URL: ${git_repository}\n"
+ " Parent URL: ${_parent_git_remote_url}"
+ )
+ endif()
+ set("${output_variable}" "${_resolved_git_remote_url}" PARENT_SCOPE)
+ return()
+ elseif(cmp0150 STREQUAL "")
+ cmake_policy(GET_WARNING CMP0150 _cmp0150_warning)
+ message(AUTHOR_WARNING
+ "${_cmp0150_warning}\n"
+ "A relative GIT_REPOSITORY path was detected. "
+ "This will be interpreted as a local path to where the project is being cloned. "
+ "Set GIT_REPOSITORY to an absolute path or set policy CMP0150 to NEW to avoid "
+ "this warning."
+ )
+ endif()
+
+ set("${output_variable}" "${cmp0150_old_base_dir}/${git_repository}" PARENT_SCOPE)
+endfunction()
diff --git a/Modules/FetchContent.cmake b/Modules/FetchContent.cmake
index dd5f617acd..74ac8aab2a 100644
--- a/Modules/FetchContent.cmake
+++ b/Modules/FetchContent.cmake
@@ -1076,6 +1076,8 @@ current working directory.
#]=======================================================================]
+include(${CMAKE_CURRENT_LIST_DIR}/ExternalProject/shared_internal_commands.cmake)
+
#=======================================================================
# Recording and retrieving content details for later population
#=======================================================================
@@ -1223,6 +1225,7 @@ function(FetchContent_Declare contentName)
# cannot check for multi-value arguments with this method. We will have to
# handle the URL keyword differently.
set(oneValueArgs
+ GIT_REPOSITORY
SVN_REPOSITORY
DOWNLOAD_NO_EXTRACT
DOWNLOAD_EXTRACT_TIMESTAMP
@@ -1242,6 +1245,30 @@ function(FetchContent_Declare contentName)
set(ARG_SOURCE_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-src")
endif()
+ if(ARG_GIT_REPOSITORY)
+ # We resolve the GIT_REPOSITORY here so that we get the right parent in the
+ # remote selection logic. In the sub-build, ExternalProject_Add() would see
+ # the private sub-build directory as the parent project, but the parent
+ # project should be the one that called FetchContent_Declare(). We resolve
+ # a relative repo here so that the sub-build's ExternalProject_Add() only
+ # ever sees a non-relative repo.
+ # Since these checks may be non-trivial on some platforms (notably Windows),
+ # don't perform them if we won't be using these details. This also allows
+ # projects to override calls with relative URLs when they have checked out
+ # the parent project in an unexpected way, such as from a mirror or fork.
+ set(savedDetailsPropertyName "_FetchContent_${contentNameLower}_savedDetails")
+ get_property(alreadyDefined GLOBAL PROPERTY ${savedDetailsPropertyName} DEFINED)
+ if(NOT alreadyDefined)
+ cmake_policy(GET CMP0150 cmp0150
+ PARENT_SCOPE # undocumented, do not use outside of CMake
+ )
+ _ep_resolve_git_remote(_resolved_git_repository
+ "${ARG_GIT_REPOSITORY}" "${cmp0150}" "${FETCHCONTENT_BASE_DIR}"
+ )
+ set(ARG_GIT_REPOSITORY "${_resolved_git_repository}")
+ endif()
+ endif()
+
if(ARG_SVN_REPOSITORY)
# Add a hash of the svn repository URL to the source dir. This works
# around the problem where if the URL changes, the download would
diff --git a/Modules/FindCUDAToolkit.cmake b/Modules/FindCUDAToolkit.cmake
index 2e1e46dc58..8afef5e332 100644
--- a/Modules/FindCUDAToolkit.cmake
+++ b/Modules/FindCUDAToolkit.cmake
@@ -1041,7 +1041,11 @@ if(CUDAToolkit_FOUND)
endif()
_CUDAToolkit_find_and_add_import_lib(culibos) # it's a static library
- foreach (cuda_lib cublasLt cufft curand nppc nvjpeg)
+ foreach (cuda_lib cublasLt cufft nvjpeg)
+ _CUDAToolkit_find_and_add_import_lib(${cuda_lib})
+ _CUDAToolkit_find_and_add_import_lib(${cuda_lib}_static DEPS cudart_static_deps culibos)
+ endforeach()
+ foreach (cuda_lib curand nppc)
_CUDAToolkit_find_and_add_import_lib(${cuda_lib})
_CUDAToolkit_find_and_add_import_lib(${cuda_lib}_static DEPS culibos)
endforeach()
@@ -1145,7 +1149,12 @@ if(CUDAToolkit_FOUND)
_CUDAToolkit_find_and_add_import_lib(nvrtc DEPS nvrtc_builtins nvJitLink)
if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 11.5.0)
_CUDAToolkit_find_and_add_import_lib(nvrtc_builtins_static ALT nvrtc-builtins_static DEPS cuda_driver)
- _CUDAToolkit_find_and_add_import_lib(nvrtc_static DEPS nvrtc_builtins_static nvptxcompiler_static nvJitLink_static)
+ if(NOT TARGET CUDA::nvrtc_static)
+ _CUDAToolkit_find_and_add_import_lib(nvrtc_static DEPS nvrtc_builtins_static nvptxcompiler_static nvJitLink_static)
+ if(TARGET CUDA::nvrtc_static AND WIN32 AND NOT (BORLAND OR MINGW OR CYGWIN))
+ target_link_libraries(CUDA::nvrtc_static INTERFACE Ws2_32.lib)
+ endif()
+ endif()
endif()
_CUDAToolkit_find_and_add_import_lib(nvml ALT nvidia-ml nvml)
diff --git a/Modules/Platform/Android-Determine.cmake b/Modules/Platform/Android-Determine.cmake
index 715f68bb4e..307e4c9a53 100644
--- a/Modules/Platform/Android-Determine.cmake
+++ b/Modules/Platform/Android-Determine.cmake
@@ -34,18 +34,26 @@ cmake_policy(PUSH)
cmake_policy(SET CMP0057 NEW) # if IN_LIST
# If using Android tools for Visual Studio, compile a sample project to get the
-# sysroot.
+# NDK path and set the processor from the generator platform.
if(CMAKE_GENERATOR MATCHES "Visual Studio")
- if(NOT CMAKE_SYSROOT)
- set(vcx_platform ${CMAKE_GENERATOR_PLATFORM})
- if(CMAKE_GENERATOR MATCHES "Visual Studio 1[45]")
- set(vcx_sysroot_var "Sysroot")
+ if(NOT CMAKE_ANDROID_ARCH_ABI AND NOT CMAKE_SYSTEM_PROCESSOR)
+ if(CMAKE_GENERATOR_PLATFORM STREQUAL "ARM")
+ set(CMAKE_SYSTEM_PROCESSOR "armv7-a")
+ elseif(CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64")
+ set(CMAKE_SYSTEM_PROCESSOR "aarch64")
+ elseif(CMAKE_GENERATOR_PLATFORM STREQUAL "x86")
+ set(CMAKE_SYSTEM_PROCESSOR "i686")
+ elseif(CMAKE_GENERATOR_PLATFORM STREQUAL "x64")
+ set(CMAKE_SYSTEM_PROCESSOR "x86_64")
else()
- set(vcx_sysroot_var "SysrootLink")
+ message(FATAL_ERROR "Unhandled generator platform, please choose ARM, ARM64, x86 or x86_64 using -A")
endif()
+ endif()
+ if(NOT CMAKE_ANDROID_NDK)
+ set(vcx_platform ${CMAKE_GENERATOR_PLATFORM})
if(CMAKE_GENERATOR MATCHES "Visual Studio 14")
set(vcx_revision "2.0")
- elseif(CMAKE_GENERATOR MATCHES "Visual Studio 1[56]")
+ elseif(CMAKE_GENERATOR MATCHES "Visual Studio 1[567]")
set(vcx_revision "3.0")
else()
set(vcx_revision "")
@@ -62,16 +70,16 @@ if(CMAKE_GENERATOR MATCHES "Visual Studio")
RESULT_VARIABLE VCXPROJ_INSPECT_RESULT
)
unset(_msbuild)
- if(NOT CMAKE_SYSROOT AND VCXPROJ_INSPECT_OUTPUT MATCHES "CMAKE_SYSROOT=([^%\r\n]+)[\r\n]")
+ if(VCXPROJ_INSPECT_OUTPUT MATCHES "CMAKE_ANDROID_NDK=([^%\r\n]+)[\r\n]")
# Strip VS diagnostic output from the end of the line.
- string(REGEX REPLACE " \\(TaskId:[0-9]*\\)$" "" _sysroot "${CMAKE_MATCH_1}")
- if(EXISTS "${_sysroot}")
- file(TO_CMAKE_PATH "${_sysroot}" CMAKE_SYSROOT)
+ string(REGEX REPLACE " \\(TaskId:[0-9]*\\)$" "" _ndk "${CMAKE_MATCH_1}")
+ if(EXISTS "${_ndk}")
+ file(TO_CMAKE_PATH "${_ndk}" CMAKE_ANDROID_NDK)
endif()
endif()
if(VCXPROJ_INSPECT_RESULT)
message(CONFIGURE_LOG
- "Determining the sysroot for the Android NDK failed.
+ "Determining the Android NDK failed from msbuild failed.
The output was:
${VCXPROJ_INSPECT_RESULT}
${VCXPROJ_INSPECT_OUTPUT}
@@ -79,7 +87,7 @@ ${VCXPROJ_INSPECT_OUTPUT}
")
else()
message(CONFIGURE_LOG
- "Determining the sysroot for the Android NDK succeeded.
+ "Determining the Android NDK succeeded.
The output was:
${VCXPROJ_INSPECT_RESULT}
${VCXPROJ_INSPECT_OUTPUT}
diff --git a/Modules/Platform/Android/VCXProjInspect.vcxproj.in b/Modules/Platform/Android/VCXProjInspect.vcxproj.in
index 6919d2cd85..f87d59bca2 100644
--- a/Modules/Platform/Android/VCXProjInspect.vcxproj.in
+++ b/Modules/Platform/Android/VCXProjInspect.vcxproj.in
@@ -19,6 +19,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@vcx_platform@'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
+ <AndroidAPILevel>android-21</AndroidAPILevel>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
@@ -29,7 +30,7 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@vcx_platform@'">
<PostBuildEvent>
- <Command>%40echo CMAKE_SYSROOT=$(@vcx_sysroot_var@)</Command>
+ <Command>%40echo CMAKE_ANDROID_NDK=$(VS_NdkRoot)</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />