Merge topic '17870-effective-system-name'

4597396784 Apple: Use include_guard() within compiler config
e95b3fd9bb Apple: Use CMAKE_EFFECTIVE_SYSTEM_NAME to share compiler info
84f9f63fcc Modules: Introduce CMAKE_EFFECTIVE_SYSTEM_NAME to lookup compiler info
9fa0f2eb56 CMakeFindPackageMode: Perform platform-specific initialization

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1964
This commit is contained in:
Brad King
2018-04-19 12:20:08 +00:00
committed by Kitware Robot
43 changed files with 73 additions and 66 deletions

View File

@@ -29,15 +29,15 @@ if(NOT _INCLUDED_FILE)
endif()
if(CMAKE_SYSTEM_PROCESSOR)
include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}-ASM${ASM_DIALECT}-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}-ASM${ASM_DIALECT}-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
if(NOT _INCLUDED_FILE)
include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL)
include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_BASE_NAME}-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL)
endif()
endif()
include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}-ASM${ASM_DIALECT} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}-ASM${ASM_DIALECT} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
if(NOT _INCLUDED_FILE)
include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL)
include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL)
endif()
# This should be included before the _INIT variables are

View File

@@ -35,21 +35,21 @@ endif()
# load a hardware specific file, mostly useful for embedded compilers
if(CMAKE_SYSTEM_PROCESSOR)
if(CMAKE_C_COMPILER_ID)
include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_C_COMPILER_ID}-C-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_C_COMPILER_ID}-C-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
endif()
if (NOT _INCLUDED_FILE)
include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL)
include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_BASE_NAME}-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL)
endif ()
endif()
# load the system- and compiler specific files
if(CMAKE_C_COMPILER_ID)
include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_C_COMPILER_ID}-C
include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_C_COMPILER_ID}-C
OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
endif()
if (NOT _INCLUDED_FILE)
include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}
include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_BASE_NAME}
OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
endif ()

View File

@@ -17,9 +17,9 @@ endif()
if(CMAKE_CUDA_COMPILER_ID)
# load a hardware specific file, mostly useful for embedded compilers
if(CMAKE_SYSTEM_PROCESSOR)
include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_CUDA_COMPILER_ID}-CUDA-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL)
include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_CUDA_COMPILER_ID}-CUDA-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL)
endif()
include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_CUDA_COMPILER_ID}-CUDA OPTIONAL)
include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_CUDA_COMPILER_ID}-CUDA OPTIONAL)
endif()

View File

@@ -36,19 +36,19 @@ endif()
# load a hardware specific file, mostly useful for embedded compilers
if(CMAKE_SYSTEM_PROCESSOR)
if(CMAKE_CXX_COMPILER_ID)
include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_CXX_COMPILER_ID}-CXX-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_CXX_COMPILER_ID}-CXX-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
endif()
if (NOT _INCLUDED_FILE)
include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL)
include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_BASE_NAME}-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL)
endif ()
endif()
# load the system- and compiler specific files
if(CMAKE_CXX_COMPILER_ID)
include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_CXX_COMPILER_ID}-CXX OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_CXX_COMPILER_ID}-CXX OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
endif()
if (NOT _INCLUDED_FILE)
include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL
include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL
RESULT_VARIABLE _INCLUDED_FILE)
endif ()

View File

@@ -65,6 +65,8 @@ if("${CMAKE_SYSTEM_NAME}" MATCHES Darwin AND "${COMPILER_ID}" MATCHES GNU)
set(CMAKE_${LANGUAGE}_OSX_DEPLOYMENT_TARGET_FLAG "")
endif()
include(CMakeSystemSpecificInitialize)
# Also load the system specific file, which sets up e.g. the search paths.
# This makes the FIND_XXX() calls work much better
include(CMakeSystemSpecificInformation)

View File

@@ -22,10 +22,10 @@ if(CMAKE_COMPILER_IS_GNUG77)
set(CMAKE_BASE_NAME g77)
endif()
if(CMAKE_Fortran_COMPILER_ID)
include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_Fortran_COMPILER_ID}-Fortran OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_Fortran_COMPILER_ID}-Fortran OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
endif()
if (NOT _INCLUDED_FILE)
include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL
include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL
RESULT_VARIABLE _INCLUDED_FILE)
endif ()

View File

@@ -9,10 +9,10 @@
macro(__cmake_include_compiler_wrapper lang)
set(_INCLUDED_WRAPPER_FILE 0)
if (CMAKE_${lang}_COMPILER_ID)
include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_${lang}_COMPILER_WRAPPER}-${CMAKE_${lang}_COMPILER_ID}-${lang} OPTIONAL RESULT_VARIABLE _INCLUDED_WRAPPER_FILE)
include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_${lang}_COMPILER_WRAPPER}-${CMAKE_${lang}_COMPILER_ID}-${lang} OPTIONAL RESULT_VARIABLE _INCLUDED_WRAPPER_FILE)
endif()
if (NOT _INCLUDED_WRAPPER_FILE)
include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_${lang}_COMPILER_WRAPPER}-${lang} OPTIONAL RESULT_VARIABLE _INCLUDED_WRAPPER_FILE)
include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_${lang}_COMPILER_WRAPPER}-${lang} OPTIONAL RESULT_VARIABLE _INCLUDED_WRAPPER_FILE)
endif ()
# No platform - wrapper - lang information so maybe there's just wrapper - lang information

View File

@@ -14,9 +14,9 @@ endif()
if(CMAKE_Swift_COMPILER_ID)
# load a hardware specific file, mostly useful for embedded compilers
if(CMAKE_SYSTEM_PROCESSOR)
include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_Swift_COMPILER_ID}-Swift-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL)
include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_Swift_COMPILER_ID}-Swift-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL)
endif()
include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_Swift_COMPILER_ID}-Swift OPTIONAL)
include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_Swift_COMPILER_ID}-Swift OPTIONAL)
endif()
# for most systems a module is the same as a shared library

View File

@@ -5,6 +5,19 @@
# This file is included by cmGlobalGenerator::EnableLanguage.
# It is included before the compiler has been determined.
# The CMAKE_EFFECTIVE_SYSTEM_NAME is used to load compiler and compiler
# wrapper configuration files. By default it equals to CMAKE_SYSTEM_NAME
# but could be overridden in the ${CMAKE_SYSTEM_NAME}-Initialize files.
#
# 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)
set(CMAKE_SYSTEM_SPECIFIC_INITIALIZE_LOADED 1)

View File

@@ -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()

View File

@@ -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()

View File

@@ -0,0 +1,2 @@
include(Platform/Apple-Clang)
__apple_compiler_clang(C)

View File

@@ -0,0 +1,2 @@
include(Platform/Apple-Clang)
__apple_compiler_clang(CXX)

View File

@@ -3,12 +3,9 @@
# This module is shared by multiple languages; use include blocker.
if(__DARWIN_COMPILER_CLANG)
return()
endif()
set(__DARWIN_COMPILER_CLANG 1)
include_guard()
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")

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -3,12 +3,9 @@
# This module is shared by multiple languages; use include blocker.
if(__DARWIN_COMPILER_GNU)
return()
endif()
set(__DARWIN_COMPILER_GNU 1)
include_guard()
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")

View File

@@ -0,0 +1,2 @@
include(Platform/Apple-Intel)
__apple_compiler_intel(C)

View File

@@ -0,0 +1,2 @@
include(Platform/Apple-Intel)
__apple_compiler_intel(CXX)

View File

@@ -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 ")

View File

@@ -3,12 +3,9 @@
# This module is shared by multiple languages; use include blocker.
if(__DARWIN_COMPILER_INTEL)
return()
endif()
set(__DARWIN_COMPILER_INTEL 1)
include_guard()
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")

View File

@@ -0,0 +1,2 @@
include(Platform/Apple-PGI)
__apple_compiler_pgi(C)

View File

@@ -0,0 +1,2 @@
include(Platform/Apple-PGI)
__apple_compiler_pgi(CXX)

View File

@@ -0,0 +1,2 @@
include(Platform/Apple-PGI)
__apple_compiler_pgi(Fortran)

View File

@@ -2,12 +2,9 @@
# file Copyright.txt or https://cmake.org/licensing for details.
# This module is shared by multiple languages; use include blocker.
if(__DARWIN_COMPILER_PGI)
return()
endif()
set(__DARWIN_COMPILER_PGI 1)
include_guard()
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")

View File

@@ -0,0 +1 @@
include(Platform/Apple-XL-C)

View File

@@ -0,0 +1 @@
include(Platform/Apple-XL-CXX)

View File

@@ -1,2 +0,0 @@
include(Platform/Darwin-Clang)
__darwin_compiler_clang(C)

View File

@@ -1,2 +0,0 @@
include(Platform/Darwin-Clang)
__darwin_compiler_clang(CXX)

View File

@@ -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, ...
#

View File

@@ -1,2 +0,0 @@
include(Platform/Darwin-Intel)
__darwin_compiler_intel(C)

View File

@@ -1,2 +0,0 @@
include(Platform/Darwin-Intel)
__darwin_compiler_intel(CXX)

View File

@@ -1,2 +0,0 @@
include(Platform/Darwin-PGI)
__darwin_compiler_pgi(C)

View File

@@ -1,2 +0,0 @@
include(Platform/Darwin-PGI)
__darwin_compiler_pgi(CXX)

View File

@@ -1,2 +0,0 @@
include(Platform/Darwin-PGI)
__darwin_compiler_pgi(Fortran)

View File

@@ -1 +0,0 @@
include(Platform/Darwin-XL-C)

View File

@@ -1 +0,0 @@
include(Platform/Darwin-XL-CXX)