summaryrefslogtreecommitdiffstats
path: root/Modules/Platform
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/Platform')
-rw-r--r--Modules/Platform/Android-Common.cmake12
-rw-r--r--Modules/Platform/Android-Determine.cmake91
-rw-r--r--Modules/Platform/Android-Initialize.cmake3
-rw-r--r--Modules/Platform/Android/abi-common.cmake4
-rw-r--r--Modules/Platform/Generic-SDCC-C.cmake2
-rw-r--r--Modules/Platform/Windows-NVIDIA-CUDA.cmake12
6 files changed, 98 insertions, 26 deletions
diff --git a/Modules/Platform/Android-Common.cmake b/Modules/Platform/Android-Common.cmake
index cf2785a..ac72676 100644
--- a/Modules/Platform/Android-Common.cmake
+++ b/Modules/Platform/Android-Common.cmake
@@ -156,6 +156,14 @@ macro(__android_compiler_common lang)
# necessary so that Android API-version-specific headers are preferred
# over those in the toolchain's `include-fixed` directory (which cannot
# possibly match all versions).
- list(APPEND CMAKE_${lang}_STANDARD_INCLUDE_DIRECTORIES "${CMAKE_SYSROOT}/usr/include")
- list(REMOVE_ITEM CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES "/usr/include")
+ #
+ # Do not do this for a standalone toolchain because it is already
+ # tied to a specific API version.
+ if(CMAKE_ANDROID_NDK)
+ list(APPEND CMAKE_${lang}_STANDARD_INCLUDE_DIRECTORIES "${CMAKE_SYSROOT}/usr/include")
+ if(NOT CMAKE_ANDROID_NDK_DEPRECATED_HEADERS)
+ list(APPEND CMAKE_${lang}_STANDARD_INCLUDE_DIRECTORIES "${CMAKE_SYSROOT}/usr/include/${CMAKE_ANDROID_ARCH_HEADER_TRIPLE}")
+ endif()
+ list(REMOVE_ITEM CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES "/usr/include")
+ endif()
endmacro()
diff --git a/Modules/Platform/Android-Determine.cmake b/Modules/Platform/Android-Determine.cmake
index 6d370ab..add1dc1 100644
--- a/Modules/Platform/Android-Determine.cmake
+++ b/Modules/Platform/Android-Determine.cmake
@@ -100,11 +100,34 @@ endif()
set(_ANDROID_STANDALONE_TOOLCHAIN_API "")
if(CMAKE_ANDROID_STANDALONE_TOOLCHAIN)
- set(_ANDROID_API_LEVEL_H_REGEX "^[\t ]*#[\t ]*define[\t ]+__ANDROID_API__[\t ]+([0-9]+)")
- file(STRINGS "${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/sysroot/usr/include/android/api-level.h"
- _ANDROID_API_LEVEL_H_CONTENT REGEX "${_ANDROID_API_LEVEL_H_REGEX}")
- if(_ANDROID_API_LEVEL_H_CONTENT MATCHES "${_ANDROID_API_LEVEL_H_REGEX}")
- set(_ANDROID_STANDALONE_TOOLCHAIN_API "${CMAKE_MATCH_1}")
+ # Try to read the API level from the toolchain launcher.
+ if(EXISTS "${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/bin/clang")
+ set(_ANDROID_API_LEVEL_CLANG_REGEX "__ANDROID_API__=([0-9]+)")
+ file(STRINGS "${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/bin/clang" _ANDROID_STANDALONE_TOOLCHAIN_BIN_CLANG
+ REGEX "${_ANDROID_API_LEVEL_CLANG_REGEX}" LIMIT_COUNT 1 LIMIT_INPUT 65536)
+ if(_ANDROID_STANDALONE_TOOLCHAIN_BIN_CLANG MATCHES "${_ANDROID_API_LEVEL_CLANG_REGEX}")
+ set(_ANDROID_STANDALONE_TOOLCHAIN_API "${CMAKE_MATCH_1}")
+ endif()
+ unset(_ANDROID_STANDALONE_TOOLCHAIN_BIN_CLANG)
+ unset(_ANDROID_API_LEVEL_CLANG_REGEX)
+ endif()
+ if(NOT _ANDROID_STANDALONE_TOOLCHAIN_API)
+ # The compiler launcher does not know __ANDROID_API__. Assume this
+ # is not unified headers and look for it in the api-level.h header.
+ set(_ANDROID_API_LEVEL_H_REGEX "^[\t ]*#[\t ]*define[\t ]+__ANDROID_API__[\t ]+([0-9]+)")
+ file(STRINGS "${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/sysroot/usr/include/android/api-level.h"
+ _ANDROID_API_LEVEL_H_CONTENT REGEX "${_ANDROID_API_LEVEL_H_REGEX}")
+ if(_ANDROID_API_LEVEL_H_CONTENT MATCHES "${_ANDROID_API_LEVEL_H_REGEX}")
+ set(_ANDROID_STANDALONE_TOOLCHAIN_API "${CMAKE_MATCH_1}")
+ endif()
+ endif()
+ if(NOT _ANDROID_STANDALONE_TOOLCHAIN_API)
+ message(WARNING
+ "Android: Did not detect API level from\n"
+ " ${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/bin/clang\n"
+ "or\n"
+ " ${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/sysroot/usr/include/android/api-level.h\n"
+ )
endif()
endif()
@@ -174,22 +197,30 @@ 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_armeabi-v7a_PROC "armv7-a")
-set(_ANDROID_ABI_armeabi-v7a_ARCH "arm")
-set(_ANDROID_ABI_armeabi-v6_PROC "armv6")
-set(_ANDROID_ABI_armeabi-v6_ARCH "arm")
-set(_ANDROID_ABI_armeabi_PROC "armv5te")
-set(_ANDROID_ABI_armeabi_ARCH "arm")
-set(_ANDROID_ABI_mips_PROC "mips")
-set(_ANDROID_ABI_mips_ARCH "mips")
-set(_ANDROID_ABI_mips64_PROC "mips64")
-set(_ANDROID_ABI_mips64_ARCH "mips64")
-set(_ANDROID_ABI_x86_PROC "i686")
-set(_ANDROID_ABI_x86_ARCH "x86")
-set(_ANDROID_ABI_x86_64_PROC "x86_64")
-set(_ANDROID_ABI_x86_64_ARCH "x86_64")
+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_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-v6_PROC "armv6")
+set(_ANDROID_ABI_armeabi-v6_ARCH "arm")
+set(_ANDROID_ABI_armeabi-v6_HEADER "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_mips_PROC "mips")
+set(_ANDROID_ABI_mips_ARCH "mips")
+set(_ANDROID_ABI_mips_HEADER "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_x86_PROC "i686")
+set(_ANDROID_ABI_x86_ARCH "x86")
+set(_ANDROID_ABI_x86_HEADER "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_PROC_aarch64_ARCH_ABI "arm64-v8a")
set(_ANDROID_PROC_armv7-a_ARCH_ABI "armeabi-v7a")
@@ -241,6 +272,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}")
# Select a processor.
if(NOT CMAKE_SYSTEM_PROCESSOR)
@@ -252,6 +284,16 @@ if(NOT _ANDROID_ABI_${CMAKE_ANDROID_ARCH_ABI}_PROC STREQUAL CMAKE_SYSTEM_PROCESS
message(FATAL_ERROR "Android: The specified CMAKE_ANDROID_ARCH_ABI='${CMAKE_ANDROID_ARCH_ABI}' and CMAKE_SYSTEM_PROCESSOR='${CMAKE_SYSTEM_PROCESSOR}' is not a valid combination.")
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}")
+ # Unified headers exist so we use them by default.
+ set(CMAKE_ANDROID_NDK_DEPRECATED_HEADERS 0)
+ else()
+ # Unified headers do not exist so use the deprecated headers.
+ set(CMAKE_ANDROID_NDK_DEPRECATED_HEADERS 1)
+ endif()
+endif()
+
# Save the Android-specific information in CMakeSystem.cmake.
set(CMAKE_SYSTEM_CUSTOM_CODE "
set(CMAKE_ANDROID_NDK \"${CMAKE_ANDROID_NDK}\")
@@ -260,6 +302,13 @@ set(CMAKE_ANDROID_ARCH \"${CMAKE_ANDROID_ARCH}\")
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_NDK_DEPRECATED_HEADERS \"${CMAKE_ANDROID_NDK_DEPRECATED_HEADERS}\")\n"
+ )
+endif()
+
# Select an ARM variant.
if(CMAKE_ANDROID_ARCH_ABI MATCHES "^armeabi")
if(CMAKE_ANDROID_ARM_MODE)
diff --git a/Modules/Platform/Android-Initialize.cmake b/Modules/Platform/Android-Initialize.cmake
index a327223..a434f90 100644
--- a/Modules/Platform/Android-Initialize.cmake
+++ b/Modules/Platform/Android-Initialize.cmake
@@ -20,6 +20,9 @@ endif()
if(NOT CMAKE_SYSROOT)
if(CMAKE_ANDROID_NDK)
set(CMAKE_SYSROOT "${CMAKE_ANDROID_NDK}/platforms/android-${CMAKE_SYSTEM_VERSION}/arch-${CMAKE_ANDROID_ARCH}")
+ if(NOT CMAKE_ANDROID_NDK_DEPRECATED_HEADERS)
+ set(CMAKE_SYSROOT_COMPILE "${CMAKE_ANDROID_NDK}/sysroot")
+ endif()
elseif(CMAKE_ANDROID_STANDALONE_TOOLCHAIN)
set(CMAKE_SYSROOT "${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/sysroot")
endif()
diff --git a/Modules/Platform/Android/abi-common.cmake b/Modules/Platform/Android/abi-common.cmake
index 3b0eb01..10fb897 100644
--- a/Modules/Platform/Android/abi-common.cmake
+++ b/Modules/Platform/Android/abi-common.cmake
@@ -3,6 +3,10 @@ string(APPEND _ANDROID_ABI_INIT_CFLAGS
" -no-canonical-prefixes"
)
+if(CMAKE_ANDROID_NDK AND NOT CMAKE_ANDROID_NDK_DEPRECATED_HEADERS)
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -D__ANDROID_API__=${CMAKE_SYSTEM_VERSION}")
+endif()
+
if(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE
AND NOT CMAKE_SYSTEM_VERSION VERSION_LESS 16)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
diff --git a/Modules/Platform/Generic-SDCC-C.cmake b/Modules/Platform/Generic-SDCC-C.cmake
index bbefe19..4b3912a 100644
--- a/Modules/Platform/Generic-SDCC-C.cmake
+++ b/Modules/Platform/Generic-SDCC-C.cmake
@@ -41,7 +41,7 @@ endif()
set(CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>")
# link object files to an executable
-set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <FLAGS> <OBJECTS> --out-fmt-ihx -o <TARGET> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>")
+set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <FLAGS> <OBJECTS> -o <TARGET> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>")
# needs sdcc 2.7.0 + sddclib from cvs
set(CMAKE_C_CREATE_STATIC_LIBRARY
diff --git a/Modules/Platform/Windows-NVIDIA-CUDA.cmake b/Modules/Platform/Windows-NVIDIA-CUDA.cmake
index 845fa4b..970c2c6 100644
--- a/Modules/Platform/Windows-NVIDIA-CUDA.cmake
+++ b/Modules/Platform/Windows-NVIDIA-CUDA.cmake
@@ -30,10 +30,18 @@ set(CMAKE_CUDA_LINK_EXECUTABLE
unset(_CMAKE_VS_LINK_EXE)
unset(_CMAKE_VS_LINK_EXE)
+if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "8.0.0")
+ set(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS "-Wno-deprecated-gpu-targets")
+else()
+ set(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS "")
+endif()
+
set(CMAKE_CUDA_DEVICE_LINK_LIBRARY
- "<CMAKE_CUDA_COMPILER> <CMAKE_CUDA_LINK_FLAGS> <LANGUAGE_COMPILE_FLAGS> -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS")
+ "<CMAKE_CUDA_COMPILER> <CMAKE_CUDA_LINK_FLAGS> <LANGUAGE_COMPILE_FLAGS> ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS")
set(CMAKE_CUDA_DEVICE_LINK_EXECUTABLE
- "<CMAKE_CUDA_COMPILER> <FLAGS> <CMAKE_CUDA_LINK_FLAGS> -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS")
+ "<CMAKE_CUDA_COMPILER> <FLAGS> <CMAKE_CUDA_LINK_FLAGS> ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS")
+
+unset(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS)
string(REPLACE "/D" "-D" _PLATFORM_DEFINES_CUDA "${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_CXX}")