# Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. #[=======================================================================[.rst: CheckFortranCompilerFlag ------------------------ .. versionadded:: 3.3 Check whether the Fortran compiler supports a given flag. .. command:: check_fortran_compiler_flag .. code-block:: cmake check_fortran_compiler_flag( ) Check that the ```` is accepted by the compiler without a diagnostic. Stores the result in an internal cache entry named ````. This command temporarily sets the ``CMAKE_REQUIRED_DEFINITIONS`` variable and calls the ``check_fortran_source_compiles`` macro from the :module:`CheckFortranSourceCompiles` module. See documentation of that module for a listing of variables that can otherwise modify the build. A positive result from this check indicates only that the compiler did not issue a diagnostic message when given the flag. Whether the flag has any effect or even a specific one is beyond the scope of this module. .. note:: Since the :command:`try_compile` command forwards flags from variables like :variable:`CMAKE_Fortran_FLAGS _FLAGS>`, unknown flags in such variables may cause a false negative for this check. #]=======================================================================] include_guard(GLOBAL) include(CheckFortranSourceCompiles) include(CMakeCheckCompilerFlagCommonPatterns) macro (CHECK_Fortran_COMPILER_FLAG _FLAG _RESULT) set(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}") # Normalize locale during test compilation. set(_CheckFortranCompilerFlag_LOCALE_VARS LC_ALL LC_MESSAGES LANG) foreach(v ${_CheckFortranCompilerFlag_LOCALE_VARS}) set(_CheckFortranCompilerFlag_SAVED_${v} "$ENV{${v}}") set(ENV{${v}} C) endforeach() CHECK_COMPILER_FLAG_COMMON_PATTERNS(_CheckFortranCompilerFlag_COMMON_PATTERNS) CHECK_Fortran_SOURCE_COMPILES(" program test\n stop\n end program" ${_RESULT} # Some compilers do not fail with a bad flag FAIL_REGEX "command line option .* is valid for .* but not for Fortran" # GNU ${_CheckFortranCompilerFlag_COMMON_PATTERNS} ) foreach(v ${_CheckFortranCompilerFlag_LOCALE_VARS}) set(ENV{${v}} ${_CheckFortranCompilerFlag_SAVED_${v}}) unset(_CheckFortranCompilerFlag_SAVED_${v}) endforeach() unset(_CheckFortranCompilerFlag_LOCALE_VARS) unset(_CheckFortranCompilerFlag_COMMON_PATTERNS) set (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}") endmacro () n value='2'>2space:mode:
authorSebastian Holtermann <sebholt@xwmw.org>2018-08-03 10:55:50 (GMT)
committerSebastian Holtermann <sebholt@xwmw.org>2018-08-03 10:55:50 (GMT)
commit87e7904c915976456028fcd834bdea9bf07b47fd (patch)
tree534bbb77a4163b6cb090c2e2cac89f3eb7fd9147
parentce309b624aaa756c802a3dfc581c410578f77d3b (diff)
downloadCMake-87e7904c915976456028fcd834bdea9bf07b47fd.zip
CMake-87e7904c915976456028fcd834bdea9bf07b47fd.tar.gz
CMake-87e7904c915976456028fcd834bdea9bf07b47fd.tar.bz2
Autogen: Use a single AUTOGEN setup function in cmGlobalGenerator
By moving all AUTOGEN setup code in ``cmGlobalGenerator`` into a single ``cmGlobalGenerator::QtAutoGen`` function, the ``cmGlobalGenerator::Compute`` function becomes cleaner.
-rw-r--r--Source/cmGlobalGenerator.cxx49
-rw-r--r--Source/cmGlobalGenerator.h7
2 files changed, 28 insertions, 28 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 63bbf04..58821c2 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1313,16 +1313,10 @@ bool cmGlobalGenerator::Compute()
// so create the map from project name to vector of local generators
this->FillProjectMap();
-#ifdef CMAKE_BUILD_WITH_CMAKE
- // Iterate through all targets and set up automoc for those which have
- // the AUTOMOC, AUTOUIC or AUTORCC property set
- auto autogenInits = this->CreateQtAutoGenInitializers();
- for (auto& autoGen : autogenInits) {
- if (!autoGen->InitCustomTargets()) {
- return false;
- }
+ // Iterate through all targets and set up AUTOMOC, AUTOUIC and AUTORCC
+ if (!this->QtAutoGen()) {
+ return false;
}
-#endif
// Add generator specific helper commands
for (cmLocalGenerator* localGen : this->LocalGenerators) {
@@ -1341,16 +1335,6 @@ bool cmGlobalGenerator::Compute()
}
}
-#ifdef CMAKE_BUILD_WITH_CMAKE
- for (auto& autoGen : autogenInits) {
- if (!autoGen->SetupCustomTargets()) {
- return false;
- }
- autoGen.reset(nullptr);
- }
- autogenInits.clear();
-#endif
-
for (cmLocalGenerator* localGen : this->LocalGenerators) {
cmMakefile* mf = localGen->GetMakefile();
for (cmInstallGenerator* g : mf->GetInstallGenerators()) {
@@ -1480,12 +1464,11 @@ bool cmGlobalGenerator::ComputeTargetDepends()
return true;
}
-std::vector<std::unique_ptr<cmQtAutoGenInitializer>>
-cmGlobalGenerator::CreateQtAutoGenInitializers()
+bool cmGlobalGenerator::QtAutoGen()
{
+#ifdef CMAKE_BUILD_WITH_CMAKE
std::vector<std::unique_ptr<cmQtAutoGenInitializer>> autogenInits;
-#ifdef CMAKE_BUILD_WITH_CMAKE
for (cmLocalGenerator* localGen : this->LocalGenerators) {
const std::vector<cmGeneratorTarget*>& targets =
localGen->GetGeneratorTargets();
@@ -1519,12 +1502,30 @@ cmGlobalGenerator::CreateQtAutoGenInitializers()
continue;
}
- autogenInits.emplace_back(new cmQtAutoGenInitializer(
+ autogenInits.emplace_back(cm::make_unique<cmQtAutoGenInitializer>(
target, mocEnabled, uicEnabled, rccEnabled, qtVersionMajor));
}
}
+
+ if (!autogenInits.empty()) {
+ // Initialize custom targets
+ for (auto& autoGen : autogenInits) {
+ if (!autoGen->InitCustomTargets()) {
+ return false;
+ }
+ }
+
+ // Setup custom targets
+ for (auto& autoGen : autogenInits) {
+ if (!autoGen->SetupCustomTargets()) {
+ return false;
+ }
+ autoGen.reset(nullptr);
+ }
+ }
#endif
- return autogenInits;
+
+ return true;
}
cmLinkLineComputer* cmGlobalGenerator::CreateLinkLineComputer(
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h