From 707a06761fbceba35bf52d943a8fab2c76e79717 Mon Sep 17 00:00:00 2001 From: Haibo Huang Date: Tue, 27 Oct 2020 15:08:00 -0700 Subject: Android: add NDK hooks This change adds hooks to key Android support files, so that NDK can inject information or change cmake behaviors. --- Modules/Platform/Android-Clang.cmake | 12 ++++++++++++ Modules/Platform/Android-Determine.cmake | 12 ++++++++++++ Modules/Platform/Android-Initialize.cmake | 12 ++++++++++++ Modules/Platform/Android.cmake | 12 ++++++++++++ Modules/Platform/Android/Determine-Compiler.cmake | 12 ++++++++++++ 5 files changed, 60 insertions(+) diff --git a/Modules/Platform/Android-Clang.cmake b/Modules/Platform/Android-Clang.cmake index 160eada..44d48cd 100644 --- a/Modules/Platform/Android-Clang.cmake +++ b/Modules/Platform/Android-Clang.cmake @@ -7,6 +7,12 @@ if(__ANDROID_COMPILER_CLANG) endif() set(__ANDROID_COMPILER_CLANG 1) +# Include the NDK hook. +# It can be used by NDK to inject necessary fixes for an earlier cmake. +if(CMAKE_ANDROID_NDK) + include(${CMAKE_ANDROID_NDK}/build/cmake/hooks/pre/Android-Clang.cmake OPTIONAL) +endif() + # Support for NVIDIA Nsight Tegra Visual Studio Edition was previously # implemented in the CMake VS IDE generators. Avoid interfering with # that functionality for now. Later we may try to integrate this. @@ -57,3 +63,9 @@ macro(__android_compiler_clang lang) set(_ANDROID_STL_NOSTDLIBXX 1) endif() endmacro() + +# Include the NDK hook. +# It can be used by NDK to inject necessary fixes for an earlier cmake. +if(CMAKE_ANDROID_NDK) + include(${CMAKE_ANDROID_NDK}/build/cmake/hooks/post/Android-Clang.cmake OPTIONAL) +endif() diff --git a/Modules/Platform/Android-Determine.cmake b/Modules/Platform/Android-Determine.cmake index f7d8d13..3206c83 100644 --- a/Modules/Platform/Android-Determine.cmake +++ b/Modules/Platform/Android-Determine.cmake @@ -5,6 +5,12 @@ # This module detects platform-wide information about the Android target # in order to store it in "CMakeSystem.cmake". +# Include the NDK hook. +# It can be used by NDK to inject necessary fixes for an earlier cmake. +if(CMAKE_ANDROID_NDK) + include(${CMAKE_ANDROID_NDK}/build/cmake/hooks/pre/Android-Determine.cmake OPTIONAL) +endif() + # Support for NVIDIA Nsight Tegra Visual Studio Edition was previously # implemented in the CMake VS IDE generators. Avoid interfering with # that functionality for now. @@ -519,3 +525,9 @@ endif() message(STATUS "Android: Targeting API '${CMAKE_SYSTEM_VERSION}' with architecture '${CMAKE_ANDROID_ARCH}', ABI '${CMAKE_ANDROID_ARCH_ABI}', and processor '${CMAKE_SYSTEM_PROCESSOR}'") cmake_policy(POP) + +# Include the NDK hook. +# It can be used by NDK to inject necessary fixes for an earlier cmake. +if(CMAKE_ANDROID_NDK) + include(${CMAKE_ANDROID_NDK}/build/cmake/hooks/post/Android-Determine.cmake OPTIONAL) +endif() diff --git a/Modules/Platform/Android-Initialize.cmake b/Modules/Platform/Android-Initialize.cmake index 5019c28..db75703 100644 --- a/Modules/Platform/Android-Initialize.cmake +++ b/Modules/Platform/Android-Initialize.cmake @@ -4,6 +4,12 @@ # When CMAKE_SYSTEM_NAME is "Android", CMakeSystemSpecificInitialize loads this # module. +# Include the NDK hook. +# It can be used by NDK to inject necessary fixes for an earlier cmake. +if(CMAKE_ANDROID_NDK) + include(${CMAKE_ANDROID_NDK}/build/cmake/hooks/pre/Android-Initialize.cmake OPTIONAL) +endif() + # Support for NVIDIA Nsight Tegra Visual Studio Edition was previously # implemented in the CMake VS IDE generators. Avoid interfering with # that functionality for now. @@ -53,3 +59,9 @@ else() "Android: No CMAKE_SYSROOT was selected." ) endif() + +# Include the NDK hook. +# It can be used by NDK to inject necessary fixes for an earlier cmake. +if(CMAKE_ANDROID_NDK) + include(${CMAKE_ANDROID_NDK}/build/cmake/hooks/post/Android-Initialize.cmake OPTIONAL) +endif() diff --git a/Modules/Platform/Android.cmake b/Modules/Platform/Android.cmake index 80d81aa..2a1a7a3 100644 --- a/Modules/Platform/Android.cmake +++ b/Modules/Platform/Android.cmake @@ -1,3 +1,9 @@ +# Include the NDK hook. +# It can be used by NDK to inject necessary fixes for an earlier cmake. +if(CMAKE_ANDROID_NDK) + include(${CMAKE_ANDROID_NDK}/build/cmake/hooks/pre/Android.cmake OPTIONAL) +endif() + include(Platform/Linux) set(ANDROID 1) @@ -96,3 +102,9 @@ if(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED) list(APPEND CMAKE_SYSTEM_PROGRAM_PATH "${CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED}/bin") endif() + +# Include the NDK hook. +# It can be used by NDK to inject necessary fixes for an earlier cmake. +if(CMAKE_ANDROID_NDK) + include(${CMAKE_ANDROID_NDK}/build/cmake/hooks/post/Android.cmake OPTIONAL) +endif() diff --git a/Modules/Platform/Android/Determine-Compiler.cmake b/Modules/Platform/Android/Determine-Compiler.cmake index f9c2d89..f8eae62 100644 --- a/Modules/Platform/Android/Determine-Compiler.cmake +++ b/Modules/Platform/Android/Determine-Compiler.cmake @@ -7,6 +7,12 @@ if(__ANDROID_DETERMINE_COMPILER) endif() set(__ANDROID_DETERMINE_COMPILER 1) +# Include the NDK hook. +# It can be used by NDK to inject necessary fixes for an earlier cmake. +if(CMAKE_ANDROID_NDK) + include(${CMAKE_ANDROID_NDK}/build/cmake/hooks/pre/Determine-Compiler.cmake OPTIONAL) +endif() + # Support for NVIDIA Nsight Tegra Visual Studio Edition was previously # implemented in the CMake VS IDE generators. Avoid interfering with # that functionality for now. Later we may try to integrate this. @@ -83,3 +89,9 @@ set(CMAKE_${lang}_ANDROID_TOOLCHAIN_SUFFIX \"${_ANDROID_TOOL_${lang}_TOOLCHAIN_S ") endif() endmacro() + +# Include the NDK hook. +# It can be used by NDK to inject necessary fixes for an earlier cmake. +if(CMAKE_ANDROID_NDK) + include(${CMAKE_ANDROID_NDK}/build/cmake/hooks/post/Determine-Compiler.cmake OPTIONAL) +endif() -- cgit v0.12