From 9fa0f2eb5638b5863c573c0ef1922d4cb2c729d5 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 18 Apr 2018 07:28:47 -0400 Subject: [PATCH 1/4] CMakeFindPackageMode: Perform platform-specific initialization Since commit v3.1.0-rc1~565^2~3 (Add platform-specific initialization step when enabling languages, 2014-04-29) the main enable-language logic includes the `CMakeSystemSpecificInitialize` module to perform platform-specific initialization based on `CMAKE_SYSTEM_NAME`. This should be done during `cmake --find-package` mode too. --- Modules/CMakeFindPackageMode.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/CMakeFindPackageMode.cmake b/Modules/CMakeFindPackageMode.cmake index 7c41d49e27..ec3652cfa2 100644 --- a/Modules/CMakeFindPackageMode.cmake +++ b/Modules/CMakeFindPackageMode.cmake @@ -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) From 84f9f63fccdadb9b8a0bdb3260a0c7a3f71cb251 Mon Sep 17 00:00:00 2001 From: Gregor Jasny Date: Sun, 1 Apr 2018 22:49:59 +0200 Subject: [PATCH 2/4] Modules: Introduce CMAKE_EFFECTIVE_SYSTEM_NAME to lookup compiler info Create a `CMAKE_EFFECTIVE_SYSTEM_NAME` variable to use for looking up compiler information modules instead of using `CMAKE_SYSTEM_NAME` directly. This will allow multiple platforms to share the same set of compiler information modules without spelling out all of them. Issue: #17870 --- Modules/CMakeASMInformation.cmake | 8 ++++---- Modules/CMakeCInformation.cmake | 8 ++++---- Modules/CMakeCUDAInformation.cmake | 4 ++-- Modules/CMakeCXXInformation.cmake | 8 ++++---- Modules/CMakeFortranInformation.cmake | 4 ++-- Modules/CMakeLanguageInformation.cmake | 4 ++-- Modules/CMakeSwiftInformation.cmake | 4 ++-- Modules/CMakeSystemSpecificInitialize.cmake | 8 ++++++++ 8 files changed, 28 insertions(+), 20 deletions(-) diff --git a/Modules/CMakeASMInformation.cmake b/Modules/CMakeASMInformation.cmake index 125c4e3723..6b7373067e 100644 --- a/Modules/CMakeASMInformation.cmake +++ b/Modules/CMakeASMInformation.cmake @@ -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 diff --git a/Modules/CMakeCInformation.cmake b/Modules/CMakeCInformation.cmake index 1e46cacaac..df43559c95 100644 --- a/Modules/CMakeCInformation.cmake +++ b/Modules/CMakeCInformation.cmake @@ -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 () diff --git a/Modules/CMakeCUDAInformation.cmake b/Modules/CMakeCUDAInformation.cmake index 4788cbf3d0..479493b0e4 100644 --- a/Modules/CMakeCUDAInformation.cmake +++ b/Modules/CMakeCUDAInformation.cmake @@ -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() diff --git a/Modules/CMakeCXXInformation.cmake b/Modules/CMakeCXXInformation.cmake index 9ac9560e08..2975874d84 100644 --- a/Modules/CMakeCXXInformation.cmake +++ b/Modules/CMakeCXXInformation.cmake @@ -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 () diff --git a/Modules/CMakeFortranInformation.cmake b/Modules/CMakeFortranInformation.cmake index 5f028e4f3e..cceac83c69 100644 --- a/Modules/CMakeFortranInformation.cmake +++ b/Modules/CMakeFortranInformation.cmake @@ -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 () diff --git a/Modules/CMakeLanguageInformation.cmake b/Modules/CMakeLanguageInformation.cmake index 18c8624faa..674ab86969 100644 --- a/Modules/CMakeLanguageInformation.cmake +++ b/Modules/CMakeLanguageInformation.cmake @@ -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 diff --git a/Modules/CMakeSwiftInformation.cmake b/Modules/CMakeSwiftInformation.cmake index d9b408d3be..07ba6d077c 100644 --- a/Modules/CMakeSwiftInformation.cmake +++ b/Modules/CMakeSwiftInformation.cmake @@ -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 diff --git a/Modules/CMakeSystemSpecificInitialize.cmake b/Modules/CMakeSystemSpecificInitialize.cmake index 6200e9c0d3..629f226c13 100644 --- a/Modules/CMakeSystemSpecificInitialize.cmake +++ b/Modules/CMakeSystemSpecificInitialize.cmake @@ -5,6 +5,14 @@ # 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. +set(CMAKE_EFFECTIVE_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}") + include(Platform/${CMAKE_SYSTEM_NAME}-Initialize OPTIONAL) set(CMAKE_SYSTEM_SPECIFIC_INITIALIZE_LOADED 1) From e95b3fd9bbca94cb5f217847031c9c8f393aee78 Mon Sep 17 00:00:00 2001 From: Gregor Jasny Date: Sun, 1 Apr 2018 22:49:59 +0200 Subject: [PATCH 3/4] 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 --- Modules/CMakeSystemSpecificInitialize.cmake | 5 +++++ ...rwin-Absoft-Fortran.cmake => Apple-Absoft-Fortran.cmake} | 0 .../{Darwin-AppleClang-C.cmake => Apple-AppleClang-C.cmake} | 2 +- ...rwin-AppleClang-CXX.cmake => Apple-AppleClang-CXX.cmake} | 2 +- Modules/Platform/Apple-Clang-C.cmake | 2 ++ Modules/Platform/Apple-Clang-CXX.cmake | 2 ++ Modules/Platform/{Darwin-Clang.cmake => Apple-Clang.cmake} | 6 +++--- Modules/Platform/{Darwin-GNU-C.cmake => Apple-GNU-C.cmake} | 4 ++-- .../Platform/{Darwin-GNU-CXX.cmake => Apple-GNU-CXX.cmake} | 4 ++-- .../{Darwin-GNU-Fortran.cmake => Apple-GNU-Fortran.cmake} | 4 ++-- Modules/Platform/{Darwin-GNU.cmake => Apple-GNU.cmake} | 6 +++--- Modules/Platform/Apple-Intel-C.cmake | 2 ++ Modules/Platform/Apple-Intel-CXX.cmake | 2 ++ ...Darwin-Intel-Fortran.cmake => Apple-Intel-Fortran.cmake} | 4 ++-- Modules/Platform/{Darwin-Intel.cmake => Apple-Intel.cmake} | 6 +++--- .../{Darwin-NAG-Fortran.cmake => Apple-NAG-Fortran.cmake} | 0 .../{Darwin-NVIDIA-CUDA.cmake => Apple-NVIDIA-CUDA.cmake} | 0 Modules/Platform/Apple-PGI-C.cmake | 2 ++ Modules/Platform/Apple-PGI-CXX.cmake | 2 ++ Modules/Platform/Apple-PGI-Fortran.cmake | 2 ++ Modules/Platform/{Darwin-PGI.cmake => Apple-PGI.cmake} | 6 +++--- Modules/Platform/Apple-VisualAge-C.cmake | 1 + Modules/Platform/Apple-VisualAge-CXX.cmake | 1 + Modules/Platform/{Darwin-XL-C.cmake => Apple-XL-C.cmake} | 0 .../Platform/{Darwin-XL-CXX.cmake => Apple-XL-CXX.cmake} | 0 Modules/Platform/Darwin-Clang-C.cmake | 2 -- Modules/Platform/Darwin-Clang-CXX.cmake | 2 -- Modules/Platform/Darwin-Initialize.cmake | 4 ++++ Modules/Platform/Darwin-Intel-C.cmake | 2 -- Modules/Platform/Darwin-Intel-CXX.cmake | 2 -- Modules/Platform/Darwin-PGI-C.cmake | 2 -- Modules/Platform/Darwin-PGI-CXX.cmake | 2 -- Modules/Platform/Darwin-PGI-Fortran.cmake | 2 -- Modules/Platform/Darwin-VisualAge-C.cmake | 1 - Modules/Platform/Darwin-VisualAge-CXX.cmake | 1 - 35 files changed, 47 insertions(+), 38 deletions(-) rename Modules/Platform/{Darwin-Absoft-Fortran.cmake => Apple-Absoft-Fortran.cmake} (100%) rename Modules/Platform/{Darwin-AppleClang-C.cmake => Apple-AppleClang-C.cmake} (83%) rename Modules/Platform/{Darwin-AppleClang-CXX.cmake => Apple-AppleClang-CXX.cmake} (83%) create mode 100644 Modules/Platform/Apple-Clang-C.cmake create mode 100644 Modules/Platform/Apple-Clang-CXX.cmake rename Modules/Platform/{Darwin-Clang.cmake => Apple-Clang.cmake} (94%) rename Modules/Platform/{Darwin-GNU-C.cmake => Apple-GNU-C.cmake} (57%) rename Modules/Platform/{Darwin-GNU-CXX.cmake => Apple-GNU-CXX.cmake} (58%) rename Modules/Platform/{Darwin-GNU-Fortran.cmake => Apple-GNU-Fortran.cmake} (86%) rename Modules/Platform/{Darwin-GNU.cmake => Apple-GNU.cmake} (96%) create mode 100644 Modules/Platform/Apple-Intel-C.cmake create mode 100644 Modules/Platform/Apple-Intel-CXX.cmake rename Modules/Platform/{Darwin-Intel-Fortran.cmake => Apple-Intel-Fortran.cmake} (81%) rename Modules/Platform/{Darwin-Intel.cmake => Apple-Intel.cmake} (87%) rename Modules/Platform/{Darwin-NAG-Fortran.cmake => Apple-NAG-Fortran.cmake} (100%) rename Modules/Platform/{Darwin-NVIDIA-CUDA.cmake => Apple-NVIDIA-CUDA.cmake} (100%) create mode 100644 Modules/Platform/Apple-PGI-C.cmake create mode 100644 Modules/Platform/Apple-PGI-CXX.cmake create mode 100644 Modules/Platform/Apple-PGI-Fortran.cmake rename Modules/Platform/{Darwin-PGI.cmake => Apple-PGI.cmake} (83%) create mode 100644 Modules/Platform/Apple-VisualAge-C.cmake create mode 100644 Modules/Platform/Apple-VisualAge-CXX.cmake rename Modules/Platform/{Darwin-XL-C.cmake => Apple-XL-C.cmake} (100%) rename Modules/Platform/{Darwin-XL-CXX.cmake => Apple-XL-CXX.cmake} (100%) delete mode 100644 Modules/Platform/Darwin-Clang-C.cmake delete mode 100644 Modules/Platform/Darwin-Clang-CXX.cmake delete mode 100644 Modules/Platform/Darwin-Intel-C.cmake delete mode 100644 Modules/Platform/Darwin-Intel-CXX.cmake delete mode 100644 Modules/Platform/Darwin-PGI-C.cmake delete mode 100644 Modules/Platform/Darwin-PGI-CXX.cmake delete mode 100644 Modules/Platform/Darwin-PGI-Fortran.cmake delete mode 100644 Modules/Platform/Darwin-VisualAge-C.cmake delete mode 100644 Modules/Platform/Darwin-VisualAge-CXX.cmake diff --git a/Modules/CMakeSystemSpecificInitialize.cmake b/Modules/CMakeSystemSpecificInitialize.cmake index 629f226c13..de4d7f5728 100644 --- a/Modules/CMakeSystemSpecificInitialize.cmake +++ b/Modules/CMakeSystemSpecificInitialize.cmake @@ -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) diff --git a/Modules/Platform/Darwin-Absoft-Fortran.cmake b/Modules/Platform/Apple-Absoft-Fortran.cmake similarity index 100% rename from Modules/Platform/Darwin-Absoft-Fortran.cmake rename to Modules/Platform/Apple-Absoft-Fortran.cmake diff --git a/Modules/Platform/Darwin-AppleClang-C.cmake b/Modules/Platform/Apple-AppleClang-C.cmake similarity index 83% rename from Modules/Platform/Darwin-AppleClang-C.cmake rename to Modules/Platform/Apple-AppleClang-C.cmake index 3216b29094..f45ccf4134 100644 --- a/Modules/Platform/Darwin-AppleClang-C.cmake +++ b/Modules/Platform/Apple-AppleClang-C.cmake @@ -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() diff --git a/Modules/Platform/Darwin-AppleClang-CXX.cmake b/Modules/Platform/Apple-AppleClang-CXX.cmake similarity index 83% rename from Modules/Platform/Darwin-AppleClang-CXX.cmake rename to Modules/Platform/Apple-AppleClang-CXX.cmake index 3fedf8c076..1128204cf4 100644 --- a/Modules/Platform/Darwin-AppleClang-CXX.cmake +++ b/Modules/Platform/Apple-AppleClang-CXX.cmake @@ -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() diff --git a/Modules/Platform/Apple-Clang-C.cmake b/Modules/Platform/Apple-Clang-C.cmake new file mode 100644 index 0000000000..4d0dc82943 --- /dev/null +++ b/Modules/Platform/Apple-Clang-C.cmake @@ -0,0 +1,2 @@ +include(Platform/Apple-Clang) +__apple_compiler_clang(C) diff --git a/Modules/Platform/Apple-Clang-CXX.cmake b/Modules/Platform/Apple-Clang-CXX.cmake new file mode 100644 index 0000000000..6c1ddc104d --- /dev/null +++ b/Modules/Platform/Apple-Clang-CXX.cmake @@ -0,0 +1,2 @@ +include(Platform/Apple-Clang) +__apple_compiler_clang(CXX) diff --git a/Modules/Platform/Darwin-Clang.cmake b/Modules/Platform/Apple-Clang.cmake similarity index 94% rename from Modules/Platform/Darwin-Clang.cmake rename to Modules/Platform/Apple-Clang.cmake index f8a07ec2dd..70fc75e9d5 100644 --- a/Modules/Platform/Darwin-Clang.cmake +++ b/Modules/Platform/Apple-Clang.cmake @@ -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") diff --git a/Modules/Platform/Darwin-GNU-C.cmake b/Modules/Platform/Apple-GNU-C.cmake similarity index 57% rename from Modules/Platform/Darwin-GNU-C.cmake rename to Modules/Platform/Apple-GNU-C.cmake index efdfd0014a..5481c99d84 100644 --- a/Modules/Platform/Darwin-GNU-C.cmake +++ b/Modules/Platform/Apple-GNU-C.cmake @@ -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) diff --git a/Modules/Platform/Darwin-GNU-CXX.cmake b/Modules/Platform/Apple-GNU-CXX.cmake similarity index 58% rename from Modules/Platform/Darwin-GNU-CXX.cmake rename to Modules/Platform/Apple-GNU-CXX.cmake index e3c2ea7c57..727f726410 100644 --- a/Modules/Platform/Darwin-GNU-CXX.cmake +++ b/Modules/Platform/Apple-GNU-CXX.cmake @@ -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) diff --git a/Modules/Platform/Darwin-GNU-Fortran.cmake b/Modules/Platform/Apple-GNU-Fortran.cmake similarity index 86% rename from Modules/Platform/Darwin-GNU-Fortran.cmake rename to Modules/Platform/Apple-GNU-Fortran.cmake index 568d79b0c2..2f53603cbc 100644 --- a/Modules/Platform/Darwin-GNU-Fortran.cmake +++ b/Modules/Platform/Apple-GNU-Fortran.cmake @@ -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) diff --git a/Modules/Platform/Darwin-GNU.cmake b/Modules/Platform/Apple-GNU.cmake similarity index 96% rename from Modules/Platform/Darwin-GNU.cmake rename to Modules/Platform/Apple-GNU.cmake index 9f9ef01cb4..9985dddd7d 100644 --- a/Modules/Platform/Darwin-GNU.cmake +++ b/Modules/Platform/Apple-GNU.cmake @@ -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") diff --git a/Modules/Platform/Apple-Intel-C.cmake b/Modules/Platform/Apple-Intel-C.cmake new file mode 100644 index 0000000000..95bb270d3d --- /dev/null +++ b/Modules/Platform/Apple-Intel-C.cmake @@ -0,0 +1,2 @@ +include(Platform/Apple-Intel) +__apple_compiler_intel(C) diff --git a/Modules/Platform/Apple-Intel-CXX.cmake b/Modules/Platform/Apple-Intel-CXX.cmake new file mode 100644 index 0000000000..b87e512dfc --- /dev/null +++ b/Modules/Platform/Apple-Intel-CXX.cmake @@ -0,0 +1,2 @@ +include(Platform/Apple-Intel) +__apple_compiler_intel(CXX) diff --git a/Modules/Platform/Darwin-Intel-Fortran.cmake b/Modules/Platform/Apple-Intel-Fortran.cmake similarity index 81% rename from Modules/Platform/Darwin-Intel-Fortran.cmake rename to Modules/Platform/Apple-Intel-Fortran.cmake index 2299da9cec..e54e237623 100644 --- a/Modules/Platform/Darwin-Intel-Fortran.cmake +++ b/Modules/Platform/Apple-Intel-Fortran.cmake @@ -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 ") diff --git a/Modules/Platform/Darwin-Intel.cmake b/Modules/Platform/Apple-Intel.cmake similarity index 87% rename from Modules/Platform/Darwin-Intel.cmake rename to Modules/Platform/Apple-Intel.cmake index dd33cec4b9..9f92d9592a 100644 --- a/Modules/Platform/Darwin-Intel.cmake +++ b/Modules/Platform/Apple-Intel.cmake @@ -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") diff --git a/Modules/Platform/Darwin-NAG-Fortran.cmake b/Modules/Platform/Apple-NAG-Fortran.cmake similarity index 100% rename from Modules/Platform/Darwin-NAG-Fortran.cmake rename to Modules/Platform/Apple-NAG-Fortran.cmake diff --git a/Modules/Platform/Darwin-NVIDIA-CUDA.cmake b/Modules/Platform/Apple-NVIDIA-CUDA.cmake similarity index 100% rename from Modules/Platform/Darwin-NVIDIA-CUDA.cmake rename to Modules/Platform/Apple-NVIDIA-CUDA.cmake diff --git a/Modules/Platform/Apple-PGI-C.cmake b/Modules/Platform/Apple-PGI-C.cmake new file mode 100644 index 0000000000..1e117247b1 --- /dev/null +++ b/Modules/Platform/Apple-PGI-C.cmake @@ -0,0 +1,2 @@ +include(Platform/Apple-PGI) +__apple_compiler_pgi(C) diff --git a/Modules/Platform/Apple-PGI-CXX.cmake b/Modules/Platform/Apple-PGI-CXX.cmake new file mode 100644 index 0000000000..aa5daf7dd4 --- /dev/null +++ b/Modules/Platform/Apple-PGI-CXX.cmake @@ -0,0 +1,2 @@ +include(Platform/Apple-PGI) +__apple_compiler_pgi(CXX) diff --git a/Modules/Platform/Apple-PGI-Fortran.cmake b/Modules/Platform/Apple-PGI-Fortran.cmake new file mode 100644 index 0000000000..1e3e4b1a7b --- /dev/null +++ b/Modules/Platform/Apple-PGI-Fortran.cmake @@ -0,0 +1,2 @@ +include(Platform/Apple-PGI) +__apple_compiler_pgi(Fortran) diff --git a/Modules/Platform/Darwin-PGI.cmake b/Modules/Platform/Apple-PGI.cmake similarity index 83% rename from Modules/Platform/Darwin-PGI.cmake rename to Modules/Platform/Apple-PGI.cmake index 04479a8979..a68c08dea7 100644 --- a/Modules/Platform/Darwin-PGI.cmake +++ b/Modules/Platform/Apple-PGI.cmake @@ -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") diff --git a/Modules/Platform/Apple-VisualAge-C.cmake b/Modules/Platform/Apple-VisualAge-C.cmake new file mode 100644 index 0000000000..7fa603231a --- /dev/null +++ b/Modules/Platform/Apple-VisualAge-C.cmake @@ -0,0 +1 @@ +include(Platform/Apple-XL-C) diff --git a/Modules/Platform/Apple-VisualAge-CXX.cmake b/Modules/Platform/Apple-VisualAge-CXX.cmake new file mode 100644 index 0000000000..12dd34740f --- /dev/null +++ b/Modules/Platform/Apple-VisualAge-CXX.cmake @@ -0,0 +1 @@ +include(Platform/Apple-XL-CXX) diff --git a/Modules/Platform/Darwin-XL-C.cmake b/Modules/Platform/Apple-XL-C.cmake similarity index 100% rename from Modules/Platform/Darwin-XL-C.cmake rename to Modules/Platform/Apple-XL-C.cmake diff --git a/Modules/Platform/Darwin-XL-CXX.cmake b/Modules/Platform/Apple-XL-CXX.cmake similarity index 100% rename from Modules/Platform/Darwin-XL-CXX.cmake rename to Modules/Platform/Apple-XL-CXX.cmake diff --git a/Modules/Platform/Darwin-Clang-C.cmake b/Modules/Platform/Darwin-Clang-C.cmake deleted file mode 100644 index 0a1502ea9b..0000000000 --- a/Modules/Platform/Darwin-Clang-C.cmake +++ /dev/null @@ -1,2 +0,0 @@ -include(Platform/Darwin-Clang) -__darwin_compiler_clang(C) diff --git a/Modules/Platform/Darwin-Clang-CXX.cmake b/Modules/Platform/Darwin-Clang-CXX.cmake deleted file mode 100644 index f8e8d888e7..0000000000 --- a/Modules/Platform/Darwin-Clang-CXX.cmake +++ /dev/null @@ -1,2 +0,0 @@ -include(Platform/Darwin-Clang) -__darwin_compiler_clang(CXX) diff --git a/Modules/Platform/Darwin-Initialize.cmake b/Modules/Platform/Darwin-Initialize.cmake index b539e457d1..3db77aacbb 100644 --- a/Modules/Platform/Darwin-Initialize.cmake +++ b/Modules/Platform/Darwin-Initialize.cmake @@ -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}- +set(CMAKE_EFFECTIVE_SYSTEM_NAME "Apple") + #---------------------------------------------------------------------------- # _CURRENT_OSX_VERSION - as a two-component string: 10.5, 10.6, ... # diff --git a/Modules/Platform/Darwin-Intel-C.cmake b/Modules/Platform/Darwin-Intel-C.cmake deleted file mode 100644 index 81c630f4ad..0000000000 --- a/Modules/Platform/Darwin-Intel-C.cmake +++ /dev/null @@ -1,2 +0,0 @@ -include(Platform/Darwin-Intel) -__darwin_compiler_intel(C) diff --git a/Modules/Platform/Darwin-Intel-CXX.cmake b/Modules/Platform/Darwin-Intel-CXX.cmake deleted file mode 100644 index 90ae53be32..0000000000 --- a/Modules/Platform/Darwin-Intel-CXX.cmake +++ /dev/null @@ -1,2 +0,0 @@ -include(Platform/Darwin-Intel) -__darwin_compiler_intel(CXX) diff --git a/Modules/Platform/Darwin-PGI-C.cmake b/Modules/Platform/Darwin-PGI-C.cmake deleted file mode 100644 index 790919b08e..0000000000 --- a/Modules/Platform/Darwin-PGI-C.cmake +++ /dev/null @@ -1,2 +0,0 @@ -include(Platform/Darwin-PGI) -__darwin_compiler_pgi(C) diff --git a/Modules/Platform/Darwin-PGI-CXX.cmake b/Modules/Platform/Darwin-PGI-CXX.cmake deleted file mode 100644 index ceaed71528..0000000000 --- a/Modules/Platform/Darwin-PGI-CXX.cmake +++ /dev/null @@ -1,2 +0,0 @@ -include(Platform/Darwin-PGI) -__darwin_compiler_pgi(CXX) diff --git a/Modules/Platform/Darwin-PGI-Fortran.cmake b/Modules/Platform/Darwin-PGI-Fortran.cmake deleted file mode 100644 index 146807ba9b..0000000000 --- a/Modules/Platform/Darwin-PGI-Fortran.cmake +++ /dev/null @@ -1,2 +0,0 @@ -include(Platform/Darwin-PGI) -__darwin_compiler_pgi(Fortran) diff --git a/Modules/Platform/Darwin-VisualAge-C.cmake b/Modules/Platform/Darwin-VisualAge-C.cmake deleted file mode 100644 index 859914f867..0000000000 --- a/Modules/Platform/Darwin-VisualAge-C.cmake +++ /dev/null @@ -1 +0,0 @@ -include(Platform/Darwin-XL-C) diff --git a/Modules/Platform/Darwin-VisualAge-CXX.cmake b/Modules/Platform/Darwin-VisualAge-CXX.cmake deleted file mode 100644 index 46c1005df9..0000000000 --- a/Modules/Platform/Darwin-VisualAge-CXX.cmake +++ /dev/null @@ -1 +0,0 @@ -include(Platform/Darwin-XL-CXX) From 459739678443d2d2074d6e1475e4267c6c110e05 Mon Sep 17 00:00:00 2001 From: Gregor Jasny Date: Sun, 15 Apr 2018 21:47:10 +0200 Subject: [PATCH 4/4] Apple: Use include_guard() within compiler config --- Modules/Platform/Apple-Clang.cmake | 5 +---- Modules/Platform/Apple-GNU.cmake | 5 +---- Modules/Platform/Apple-Intel.cmake | 5 +---- Modules/Platform/Apple-PGI.cmake | 5 +---- 4 files changed, 4 insertions(+), 16 deletions(-) diff --git a/Modules/Platform/Apple-Clang.cmake b/Modules/Platform/Apple-Clang.cmake index 70fc75e9d5..0681bfb059 100644 --- a/Modules/Platform/Apple-Clang.cmake +++ b/Modules/Platform/Apple-Clang.cmake @@ -3,10 +3,7 @@ # This module is shared by multiple languages; use include blocker. -if(__APPLE_COMPILER_CLANG) - return() -endif() -set(__APPLE_COMPILER_CLANG 1) +include_guard() macro(__apple_compiler_clang lang) set(CMAKE_${lang}_VERBOSE_FLAG "-v -Wl,-v") # also tell linker to print verbose output diff --git a/Modules/Platform/Apple-GNU.cmake b/Modules/Platform/Apple-GNU.cmake index 9985dddd7d..0eb8168310 100644 --- a/Modules/Platform/Apple-GNU.cmake +++ b/Modules/Platform/Apple-GNU.cmake @@ -3,10 +3,7 @@ # This module is shared by multiple languages; use include blocker. -if(__APPLE_COMPILER_GNU) - return() -endif() -set(__APPLE_COMPILER_GNU 1) +include_guard() macro(__apple_compiler_gnu lang) set(CMAKE_${lang}_VERBOSE_FLAG "-v -Wl,-v") # also tell linker to print verbose output diff --git a/Modules/Platform/Apple-Intel.cmake b/Modules/Platform/Apple-Intel.cmake index 9f92d9592a..2d4f7e5917 100644 --- a/Modules/Platform/Apple-Intel.cmake +++ b/Modules/Platform/Apple-Intel.cmake @@ -3,10 +3,7 @@ # This module is shared by multiple languages; use include blocker. -if(__APPLE_COMPILER_INTEL) - return() -endif() -set(__APPLE_COMPILER_INTEL 1) +include_guard() macro(__apple_compiler_intel lang) set(CMAKE_${lang}_VERBOSE_FLAG "-v -Wl,-v") # also tell linker to print verbose output diff --git a/Modules/Platform/Apple-PGI.cmake b/Modules/Platform/Apple-PGI.cmake index a68c08dea7..8d343b7d16 100644 --- a/Modules/Platform/Apple-PGI.cmake +++ b/Modules/Platform/Apple-PGI.cmake @@ -2,10 +2,7 @@ # file Copyright.txt or https://cmake.org/licensing for details. # This module is shared by multiple languages; use include blocker. -if(__APPLE_COMPILER_PGI) - return() -endif() -set(__APPLE_COMPILER_PGI 1) +include_guard() macro(__apple_compiler_pgi lang) set(CMAKE_${lang}_OSX_COMPATIBILITY_VERSION_FLAG "-Wl,-compatibility_version,")