From 416761e35c828092bc8a7dbe68b3fbe65495f01e Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 29 Apr 2014 09:14:45 -0400 Subject: [PATCH] Add platform-specific initialization step when enabling languages Create a Modules/CMakeSystemSpecificInitialize.cmake module loaded after CMakeSystem.cmake but before per-language initialization. Use it to load an optional Platform/-Initialize.cmake module. This will be useful to do per-platform initialization that does not depend on the language and use the results when enabling specific languages. --- Modules/CMakeSystemSpecificInitialize.cmake | 20 ++++++++++++++++++++ Source/cmGlobalGenerator.cxx | 15 +++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 Modules/CMakeSystemSpecificInitialize.cmake diff --git a/Modules/CMakeSystemSpecificInitialize.cmake b/Modules/CMakeSystemSpecificInitialize.cmake new file mode 100644 index 000000000..5327ac19b --- /dev/null +++ b/Modules/CMakeSystemSpecificInitialize.cmake @@ -0,0 +1,20 @@ + +#============================================================================= +# Copyright 2002-2014 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# This file is included by cmGlobalGenerator::EnableLanguage. +# It is included before the compiler has been determined. + +include(Platform/${CMAKE_SYSTEM_NAME}-Initialize OPTIONAL) + +set(CMAKE_SYSTEM_SPECIFIC_INITIALIZE_LOADED 1) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index beb10daa1..f933f2777 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -308,6 +308,9 @@ void cmGlobalGenerator::FindMakeProgram(cmMakefile* mf) // CMakeSystem.cmake - configured file created by // CMakeDetermineSystem.cmake IF CMAKE_SYSTEM_LOADED +// CMakeSystemSpecificInitialize.cmake +// - includes Platform/${CMAKE_SYSTEM_NAME}-Initialize.cmake + // Next try and enable all languages found in the languages vector // // FOREACH LANG in languages @@ -432,6 +435,18 @@ cmGlobalGenerator::EnableLanguage(std::vectorconst& languages, fpath += "/CMakeSystem.cmake"; mf->ReadListFile(0,fpath.c_str()); } + + // **** Load the system specific initialization if not yet loaded + if (!mf->GetDefinition("CMAKE_SYSTEM_SPECIFIC_INITIALIZE_LOADED")) + { + fpath = mf->GetModulesFile("CMakeSystemSpecificInitialize.cmake"); + if(!mf->ReadListFile(0,fpath.c_str())) + { + cmSystemTools::Error("Could not find cmake module file: ", + fpath.c_str()); + } + } + std::map needTestLanguage; std::map needSetLanguageEnabledMaps; // foreach language