mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-31 10:50:16 -06:00
Apple: Use CMAKE_EFFECTIVE_SYSTEM_NAME to share compiler info
Apple platforms macOS, iOS, tvOS, and watchOS can all share the same compiler information. Rename `Darwin-*` modules to `Apple-*` and load them all through `CMAKE_EFFECTIVE_SYSTEM_NAME`. This saves duplication of 4 * 21 compiler information modules. Issue: #17870
This commit is contained in:
@@ -11,6 +11,11 @@
|
||||
#
|
||||
# It is useful to share the same aforementioned configuration files and
|
||||
# avoids duplicating them in case of tightly related platforms.
|
||||
#
|
||||
# An example are the platforms supported by Xcode (macOS, iOS, tvOS,
|
||||
# and watchOS). For all of those the CMAKE_EFFECTIVE_SYSTEM_NAME is
|
||||
# set to Apple which results in using
|
||||
# Platfom/Apple-AppleClang-CXX.cmake for the Apple C++ compiler.
|
||||
set(CMAKE_EFFECTIVE_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}")
|
||||
|
||||
include(Platform/${CMAKE_SYSTEM_NAME}-Initialize OPTIONAL)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
include(Platform/Darwin-Clang-C)
|
||||
include(Platform/Apple-Clang-C)
|
||||
if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.2)
|
||||
set(CMAKE_C_SYSTEM_FRAMEWORK_SEARCH_FLAG "-iframework ")
|
||||
else()
|
||||
@@ -1,4 +1,4 @@
|
||||
include(Platform/Darwin-Clang-CXX)
|
||||
include(Platform/Apple-Clang-CXX)
|
||||
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.2)
|
||||
set(CMAKE_CXX_SYSTEM_FRAMEWORK_SEARCH_FLAG "-iframework ")
|
||||
else()
|
||||
2
Modules/Platform/Apple-Clang-C.cmake
Normal file
2
Modules/Platform/Apple-Clang-C.cmake
Normal file
@@ -0,0 +1,2 @@
|
||||
include(Platform/Apple-Clang)
|
||||
__apple_compiler_clang(C)
|
||||
2
Modules/Platform/Apple-Clang-CXX.cmake
Normal file
2
Modules/Platform/Apple-Clang-CXX.cmake
Normal file
@@ -0,0 +1,2 @@
|
||||
include(Platform/Apple-Clang)
|
||||
__apple_compiler_clang(CXX)
|
||||
@@ -3,12 +3,12 @@
|
||||
|
||||
|
||||
# This module is shared by multiple languages; use include blocker.
|
||||
if(__DARWIN_COMPILER_CLANG)
|
||||
if(__APPLE_COMPILER_CLANG)
|
||||
return()
|
||||
endif()
|
||||
set(__DARWIN_COMPILER_CLANG 1)
|
||||
set(__APPLE_COMPILER_CLANG 1)
|
||||
|
||||
macro(__darwin_compiler_clang lang)
|
||||
macro(__apple_compiler_clang lang)
|
||||
set(CMAKE_${lang}_VERBOSE_FLAG "-v -Wl,-v") # also tell linker to print verbose output
|
||||
set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-dynamiclib -Wl,-headerpad_max_install_names")
|
||||
set(CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS "-bundle -Wl,-headerpad_max_install_names")
|
||||
@@ -1,4 +1,4 @@
|
||||
include(Platform/Darwin-GNU)
|
||||
__darwin_compiler_gnu(C)
|
||||
include(Platform/Apple-GNU)
|
||||
__apple_compiler_gnu(C)
|
||||
cmake_gnu_set_sysroot_flag(C)
|
||||
cmake_gnu_set_osx_deployment_target_flag(C)
|
||||
@@ -1,4 +1,4 @@
|
||||
include(Platform/Darwin-GNU)
|
||||
__darwin_compiler_gnu(CXX)
|
||||
include(Platform/Apple-GNU)
|
||||
__apple_compiler_gnu(CXX)
|
||||
cmake_gnu_set_sysroot_flag(CXX)
|
||||
cmake_gnu_set_osx_deployment_target_flag(CXX)
|
||||
@@ -1,8 +1,8 @@
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
include(Platform/Darwin-GNU)
|
||||
__darwin_compiler_gnu(Fortran)
|
||||
include(Platform/Apple-GNU)
|
||||
__apple_compiler_gnu(Fortran)
|
||||
cmake_gnu_set_sysroot_flag(Fortran)
|
||||
cmake_gnu_set_osx_deployment_target_flag(Fortran)
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
|
||||
|
||||
# This module is shared by multiple languages; use include blocker.
|
||||
if(__DARWIN_COMPILER_GNU)
|
||||
if(__APPLE_COMPILER_GNU)
|
||||
return()
|
||||
endif()
|
||||
set(__DARWIN_COMPILER_GNU 1)
|
||||
set(__APPLE_COMPILER_GNU 1)
|
||||
|
||||
macro(__darwin_compiler_gnu lang)
|
||||
macro(__apple_compiler_gnu lang)
|
||||
set(CMAKE_${lang}_VERBOSE_FLAG "-v -Wl,-v") # also tell linker to print verbose output
|
||||
# GNU does not have -shared on OS X
|
||||
set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-dynamiclib -Wl,-headerpad_max_install_names")
|
||||
2
Modules/Platform/Apple-Intel-C.cmake
Normal file
2
Modules/Platform/Apple-Intel-C.cmake
Normal file
@@ -0,0 +1,2 @@
|
||||
include(Platform/Apple-Intel)
|
||||
__apple_compiler_intel(C)
|
||||
2
Modules/Platform/Apple-Intel-CXX.cmake
Normal file
2
Modules/Platform/Apple-Intel-CXX.cmake
Normal file
@@ -0,0 +1,2 @@
|
||||
include(Platform/Apple-Intel)
|
||||
__apple_compiler_intel(CXX)
|
||||
@@ -1,8 +1,8 @@
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
include(Platform/Darwin-Intel)
|
||||
__darwin_compiler_intel(Fortran)
|
||||
include(Platform/Apple-Intel)
|
||||
__apple_compiler_intel(Fortran)
|
||||
|
||||
set(CMAKE_Fortran_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ")
|
||||
set(CMAKE_Fortran_OSX_CURRENT_VERSION_FLAG "-current_version ")
|
||||
@@ -3,12 +3,12 @@
|
||||
|
||||
|
||||
# This module is shared by multiple languages; use include blocker.
|
||||
if(__DARWIN_COMPILER_INTEL)
|
||||
if(__APPLE_COMPILER_INTEL)
|
||||
return()
|
||||
endif()
|
||||
set(__DARWIN_COMPILER_INTEL 1)
|
||||
set(__APPLE_COMPILER_INTEL 1)
|
||||
|
||||
macro(__darwin_compiler_intel lang)
|
||||
macro(__apple_compiler_intel lang)
|
||||
set(CMAKE_${lang}_VERBOSE_FLAG "-v -Wl,-v") # also tell linker to print verbose output
|
||||
set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-dynamiclib -Wl,-headerpad_max_install_names")
|
||||
set(CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS "-bundle -Wl,-headerpad_max_install_names")
|
||||
2
Modules/Platform/Apple-PGI-C.cmake
Normal file
2
Modules/Platform/Apple-PGI-C.cmake
Normal file
@@ -0,0 +1,2 @@
|
||||
include(Platform/Apple-PGI)
|
||||
__apple_compiler_pgi(C)
|
||||
2
Modules/Platform/Apple-PGI-CXX.cmake
Normal file
2
Modules/Platform/Apple-PGI-CXX.cmake
Normal file
@@ -0,0 +1,2 @@
|
||||
include(Platform/Apple-PGI)
|
||||
__apple_compiler_pgi(CXX)
|
||||
2
Modules/Platform/Apple-PGI-Fortran.cmake
Normal file
2
Modules/Platform/Apple-PGI-Fortran.cmake
Normal file
@@ -0,0 +1,2 @@
|
||||
include(Platform/Apple-PGI)
|
||||
__apple_compiler_pgi(Fortran)
|
||||
@@ -2,12 +2,12 @@
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
# This module is shared by multiple languages; use include blocker.
|
||||
if(__DARWIN_COMPILER_PGI)
|
||||
if(__APPLE_COMPILER_PGI)
|
||||
return()
|
||||
endif()
|
||||
set(__DARWIN_COMPILER_PGI 1)
|
||||
set(__APPLE_COMPILER_PGI 1)
|
||||
|
||||
macro(__darwin_compiler_pgi lang)
|
||||
macro(__apple_compiler_pgi lang)
|
||||
set(CMAKE_${lang}_OSX_COMPATIBILITY_VERSION_FLAG "-Wl,-compatibility_version,")
|
||||
set(CMAKE_${lang}_OSX_CURRENT_VERSION_FLAG "-Wl,-current_version,")
|
||||
set(CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG "-Wl,-install_name")
|
||||
1
Modules/Platform/Apple-VisualAge-C.cmake
Normal file
1
Modules/Platform/Apple-VisualAge-C.cmake
Normal file
@@ -0,0 +1 @@
|
||||
include(Platform/Apple-XL-C)
|
||||
1
Modules/Platform/Apple-VisualAge-CXX.cmake
Normal file
1
Modules/Platform/Apple-VisualAge-CXX.cmake
Normal file
@@ -0,0 +1 @@
|
||||
include(Platform/Apple-XL-CXX)
|
||||
@@ -1,2 +0,0 @@
|
||||
include(Platform/Darwin-Clang)
|
||||
__darwin_compiler_clang(C)
|
||||
@@ -1,2 +0,0 @@
|
||||
include(Platform/Darwin-Clang)
|
||||
__darwin_compiler_clang(CXX)
|
||||
@@ -20,6 +20,10 @@ execute_process(COMMAND sw_vers -productVersion
|
||||
set(CMAKE_OSX_ARCHITECTURES "$ENV{CMAKE_OSX_ARCHITECTURES}" CACHE STRING
|
||||
"Build architectures for OSX")
|
||||
|
||||
# macOS, iOS, tvOS, and watchOS should lookup compilers from
|
||||
# Platform/Apple-${CMAKE_CXX_COMPILER_ID}-<LANG>
|
||||
set(CMAKE_EFFECTIVE_SYSTEM_NAME "Apple")
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# _CURRENT_OSX_VERSION - as a two-component string: 10.5, 10.6, ...
|
||||
#
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
include(Platform/Darwin-Intel)
|
||||
__darwin_compiler_intel(C)
|
||||
@@ -1,2 +0,0 @@
|
||||
include(Platform/Darwin-Intel)
|
||||
__darwin_compiler_intel(CXX)
|
||||
@@ -1,2 +0,0 @@
|
||||
include(Platform/Darwin-PGI)
|
||||
__darwin_compiler_pgi(C)
|
||||
@@ -1,2 +0,0 @@
|
||||
include(Platform/Darwin-PGI)
|
||||
__darwin_compiler_pgi(CXX)
|
||||
@@ -1,2 +0,0 @@
|
||||
include(Platform/Darwin-PGI)
|
||||
__darwin_compiler_pgi(Fortran)
|
||||
@@ -1 +0,0 @@
|
||||
include(Platform/Darwin-XL-C)
|
||||
@@ -1 +0,0 @@
|
||||
include(Platform/Darwin-XL-CXX)
|
||||
Reference in New Issue
Block a user