@@ -16,27 +16,37 @@ does the following:
1616
1717include (CMakeParseArguments) # Backwards compatibility
1818
19- # This must be a macro since project defines scope-local variables
20- # that we generally rely on being in the root context.
2119# IMPORTANT: Note that if there is no *direct* call to 'project' in the root CMakeLists.txt
2220# file, CMake will automatically inject one with the default languages of C and CXX.
2321# This will cause the toolchain file to be parsed multiple times, and will
2422# make much of the work done in standard_project_preinit useless.
2523macro (standard_project project_name )
26- cmake_parse_arguments (standard "" "VERSION" "LANGUAGES" ${ARGN} )
24+ message (AUTHOR_WARNING "Standard_project has been replaced by an override of project." )
25+ project (${ARGV} )
26+ endmacro ()
2727
28- if (NOT standard_VERSION )
29- message (FATAL_ERROR "Standard compliant projects must specify a version" )
30- endif ()
28+ if (NOT DEFINED standard_project_OVERRIDE )
29+ set (standard_project_OVERRIDE ON )
30+ endif ()
3131
32- set (_language_arg "" )
33- if (standard_LANGUAGES)
34- set (_language_arg LANGUAGES ${standard_LANGUAGES} )
35- endif ()
32+ # This must be a macro since project defines scope-local variables
33+ # that we generally rely on being in the root context.
34+ macro (project project_name )
35+ if (standard_project_OVERRIDE)
36+ cmake_parse_arguments (standard "" "VERSION" "" ${ARGN} )
37+
38+ if (NOT standard_VERSION)
39+ message (FATAL_ERROR "Standard compliant projects must specify a version" )
40+ endif ()
41+
42+ standard_project_preinit()
43+ _project(${project_name} VERSION ${standard_VERSION} ${standard_UNPARSED_ARGUMENTS} )
44+ standard_project_postinit()
3645
37- standard_project_preinit()
38- project (${project_name} VERSION ${standard_VERSION} ${_language_arg} )
39- standard_project_postinit()
46+ set (standard_project_OVERRIDE OFF ) #we generally only want to modify the root project.
47+ else ()
48+ _project(${ARGV} )
49+ endif ()
4050endmacro ()
4151
4252function (standard_project_preinit)
@@ -48,30 +58,28 @@ function(standard_project_preinit)
4858 else ()
4959 # Build Fat binaries on OSX by default
5060 set (CMAKE_OSX_ARCHITECTURES "x86_64;i386" CACHE STRING "Mac OS X build architectures" FORCE)
61+ if (NOT CMAKE_OSX_SYSROOT)
62+ # CLANG_VERSION requires a sysroot to obtain, so resort to execute_process() here
63+ execute_process (COMMAND clang -v ERROR_VARIABLE _clang_version)
64+ if (_clang_version MATCHES "clang-7" )
65+ set (_developer_sdk_version 10.11)
66+ elseif (_clang_version MATCHES "clang-8" )
67+ set (_developer_sdk_version 10.12)
68+ endif ()
69+ if (_developer_sdk_version)
70+ set (CMAKE_OSX_SYSROOT "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${_developer_sdk_version} .sdk" CACHE STRING "Mac OS X build environment" FORCE)
71+ if (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
72+ set (CMAKE_OSX_DEPLOYMENT_TARGET "10.10" CACHE STRING "Mac OS X deployment target" FORCE)
73+ endif ()
74+ endif ()
75+ endif ()
5176 endif ()
5277 endif ()
5378
5479 if (NOT MSVC AND NOT CMAKE_BUILD_TYPE )
5580 set (CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release." FORCE)
5681 endif ()
5782
58- if (APPLE AND NOT (CMAKE_SYSTEM_PROCESSOR STREQUAL "arm" ))
59- if (NOT CMAKE_OSX_SYSROOT)
60- # CLANG_VERSION requires a sysroot to obtain, so resort to execute_process() here
61- execute_process (COMMAND clang -v ERROR_VARIABLE _clang_version)
62- if (_clang_version MATCHES "clang-7" )
63- set (_developer_sdk_version 10.11)
64- elseif (_clang_version MATCHES "clang-8" )
65- set (_developer_sdk_version 10.12)
66- endif ()
67- if (_developer_sdk_version)
68- set (CMAKE_OSX_SYSROOT "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${_developer_sdk_version} .sdk" CACHE STRING "Mac OS X build environment" FORCE)
69- if (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
70- set (CMAKE_OSX_DEPLOYMENT_TARGET "10.10" CACHE STRING "Mac OS X deployment target" FORCE)
71- endif ()
72- endif ()
73- endif ()
74- endif ()
7583endfunction ()
7684
7785function (standard_project_postinit)
@@ -122,19 +130,16 @@ function(standard_project_postinit)
122130 # CMAKE_SYSTEM_PROCESSOR is set by the toolchain, so must happen strictly after project()
123131 if (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64" )
124132 set (standard_BUILD_ARCHITECTURES "aarch64" PARENT_SCOPE)
125- set (standard_BUILD_64 ON PARENT_SCOPE)
126- elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "arm" )
133+ elseif (CMAKE_SYSTEM_NAME MATCHES "Android" )
134+ set (standard_BUILD_ARCHITECTURES "${CMAKE_ANDROID_ARCH_ABI} " PARENT_SCOPE) #prevent mixing armeabi & armeabi-v7a
135+ elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" )
127136 set (standard_BUILD_ARCHITECTURES "arm" PARENT_SCOPE)
128- set (standard_BUILD_64 OFF PARENT_SCOPE)
129137 elseif (CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64;i386" )
130138 set (standard_BUILD_ARCHITECTURES x64 x86 PARENT_SCOPE)
131- set (standard_BUILD_64 ON PARENT_SCOPE)
132139 elseif (CMAKE_SIZEOF_VOID_P STREQUAL 4)
133140 set (standard_BUILD_ARCHITECTURES "x86" PARENT_SCOPE)
134- set (standard_BUILD_64 OFF PARENT_SCOPE)
135141 else ()
136142 set (standard_BUILD_ARCHITECTURES "x64" PARENT_SCOPE)
137- set (standard_BUILD_64 ON PARENT_SCOPE)
138143 endif ()
139144 message (STATUS "Using architecture: ${standard_BUILD_ARCHITECTURES} " )
140145
0 commit comments