From b976e70063008c0633cb5dd4ecb1f40278c67935 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sat, 2 Jul 2011 17:08:34 +0200 Subject: [PATCH 01/24] Make clLocalGenerator::GetTargetFlags() public This will later on be used for getting the link flags Alex --- Source/cmLocalGenerator.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index aebf9f39a..a204a73d5 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -307,7 +307,6 @@ public: std::string const& dir_max, bool* hasSourceExtension = 0); -protected: /** Fill out these strings for the given target. Libraries to link, * flags, and linkflags. */ void GetTargetFlags(std::string& linkLibs, @@ -315,6 +314,7 @@ protected: std::string& linkFlags, cmTarget&target); +protected: ///! put all the libraries for a target on into the given stream virtual void OutputLinkLibraries(std::ostream&, cmTarget&, bool relink); From a91d662f46fd2781fc5a3b73c2d244ac6dc2a343 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sat, 2 Jul 2011 17:50:05 +0200 Subject: [PATCH 02/24] Add find-package mode, which does nothing yet -add command line argument --find-package and handle it, i.e. call an empty function cmake::FindPackage() -add basic help Alex --- Source/cmMakefile.cxx | 4 +++- Source/cmake.cxx | 25 +++++++++++++++++++++++++ Source/cmake.h | 5 +++++ Source/cmakemain.cxx | 13 ++++++++++++- 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 63bf03bdd..163145eb7 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -384,7 +384,9 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, // Decide whether to invoke the command. if(pcmd->GetEnabled() && !cmSystemTools::GetFatalErrorOccured() && - (!this->GetCMakeInstance()->GetScriptMode() || pcmd->IsScriptable())) + (this->GetCMakeInstance()->GetFindPackageMode() + || !this->GetCMakeInstance()->GetScriptMode() || pcmd->IsScriptable())) + { // if trace is one, print out invoke information if(this->GetCMakeInstance()->GetTrace()) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 45927cb04..3d42c7fa4 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -181,6 +181,7 @@ cmake::cmake() this->ProgressCallback = 0; this->ProgressCallbackClientData = 0; this->ScriptMode = false; + this->FindPackageMode = false; #ifdef CMAKE_BUILD_WITH_CMAKE this->VariableWatch = new cmVariableWatch; @@ -353,6 +354,7 @@ void cmake::RemoveUnscriptableCommands() // Parse the args bool cmake::SetCacheArgs(const std::vector& args) { + bool findPackageMode = false; for(unsigned int i=1; i < args.size(); ++i) { std::string arg = args[i]; @@ -480,7 +482,17 @@ bool cmake::SetCacheArgs(const std::vector& args) } this->ReadListFile(args, path.c_str()); } + else if (arg.find("--find-package",0) == 0) + { + findPackageMode = true; + } } + + if (findPackageMode) + { + return this->FindPackage(args); + } + return true; } @@ -532,6 +544,14 @@ void cmake::ReadListFile(const std::vector& args, } } + +bool cmake::FindPackage(const std::vector& args) +{ + // create empty function for now, will be filled later + return true; +} + + // Parse the args void cmake::SetArgs(const std::vector& args, bool directoriesSetBefore) @@ -604,6 +624,11 @@ void cmake::SetArgs(const std::vector& args, // skip for now i++; } + else if(arg.find("--find-package",0) == 0) + { + // skip for now + i++; + } else if(arg.find("-Wno-dev",0) == 0) { // skip for now diff --git a/Source/cmake.h b/Source/cmake.h index fac86c18e..7335813bc 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -282,6 +282,9 @@ class cmake void SetScriptMode(bool mode) { this->ScriptMode = mode; } bool GetScriptMode() { return this->ScriptMode; } + void SetFindPackageMode(bool mode) {this->FindPackageMode = mode; } + bool GetFindPackageMode() {return this->FindPackageMode;} + ///! Debug the try compile stuff by not delelting the files bool GetDebugTryCompile(){return this->DebugTryCompile;} void DebugTryCompileOn(){this->DebugTryCompile = true;} @@ -407,6 +410,7 @@ protected: ///! read in a cmake list file to initialize the cache void ReadListFile(const std::vector& args, const char *path); + bool FindPackage(const std::vector& args); ///! Check if CMAKE_CACHEFILE_DIR is set. If it is not, delete the log file. /// If it is set, truncate it to 50kb @@ -461,6 +465,7 @@ private: bool Verbose; bool InTryCompile; bool ScriptMode; + bool FindPackageMode; bool DebugOutput; bool Trace; bool WarnUninitialized; diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 663ce8f07..ae4529a44 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -102,6 +102,9 @@ static const char * cmDocumentationOptions[][3] = "No configure or generate step is performed and the cache is not" " modified. If variables are defined using -D, this must be done " "before the -P argument."}, + {"--find-package", "Run in pkg-config like mode.", + "Search a package using find_package() and print the resulting flags " + "to stdout. "}, {"--graphviz=[file]", "Generate graphviz of dependencies.", "Generate a graphviz input file that will contain all the library and " "executable dependencies in the project."}, @@ -434,6 +437,7 @@ int do_cmake(int ac, char** av) bool list_help = false; bool view_only = false; bool script_mode = false; + bool find_package_mode = false; std::vector args; for(int i =0; i < ac; ++i) { @@ -487,6 +491,12 @@ int do_cmake(int ac, char** av) args.push_back(av[i]); } } + else if (!command && strncmp(av[i], "--find-package", + strlen("--find-package")) == 0) + { + find_package_mode = true; + args.push_back(av[i]); + } else { args.push_back(av[i]); @@ -511,7 +521,8 @@ int do_cmake(int ac, char** av) cmake cm; cmSystemTools::SetErrorCallback(cmakemainErrorCallback, (void *)&cm); cm.SetProgressCallback(cmakemainProgressCallback, (void *)&cm); - cm.SetScriptMode(script_mode); + cm.SetScriptMode(script_mode || find_package_mode); + cm.SetFindPackageMode(find_package_mode); int res = cm.Run(args, view_only); if ( list_cached || list_all_cached ) From e4f603b698a13857e79a5f6df18a7461b20d4bd4 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sat, 2 Jul 2011 23:14:28 +0200 Subject: [PATCH 03/24] Implement find-package mode of cmake In find-package mode, cmake executes Modules/CMakeFindPackage.cmake, which calls find_package(), and this is then evaluated in cmake.cxx, which prints an appropriate message to stdout, so it can be used e.g. in a normal Makefile: $ /opt/cmake-HEAD/bin/cmake --find-package -DNAME=JPEG -DCOMPILER_ID=GNU -DLANGUAGE=C -DMODE=EXIST JPEG found. $ /opt/cmake-HEAD/bin/cmake --find-package -DNAME=JPEG -DCOMPILER_ID=GNU -DLANGUAGE=C -DMODE=COMPILE $ /opt/cmake-HEAD/bin/cmake --find-package -DNAME=JPEG -DCOMPILER_ID=GNU -DLANGUAGE=C -DMODE=LINK -rdynamic -ljpeg Alex --- Modules/CMakeFindPackageMode.cmake | 125 +++++++++++++++++++++++++++++ Source/cmake.cxx | 100 ++++++++++++++++++++++- 2 files changed, 223 insertions(+), 2 deletions(-) create mode 100644 Modules/CMakeFindPackageMode.cmake diff --git a/Modules/CMakeFindPackageMode.cmake b/Modules/CMakeFindPackageMode.cmake new file mode 100644 index 000000000..5842c7aef --- /dev/null +++ b/Modules/CMakeFindPackageMode.cmake @@ -0,0 +1,125 @@ +# COMPILER_ID = GNU/Intel/etc. +# LANGUAGE = C/CXX/Fortan/ASM +# MODE = EXIST/COMPILE/LINK +# NAME = name of the package +# QUIET = if TRUE, don't print anything + +if(NOT NAME) + message(FATAL_ERROR "NAME argument not specified.") +endif() + +if(NOT COMPILER_ID) + message(FATAL_ERROR "COMPILER_ID argument not specified. In doubt, use GNU.") +endif() + +if(NOT LANGUAGE) + message(FATAL_ERROR "LANGUAGE argument not specified. Use C, CXX or Fortran.") +endif() + +if(NOT MODE) + message(FATAL_ERROR "MODE argument not specified. Use either EXIST, COMPILE or LINK.") +endif() + + +include(CMakeDetermineSystem) + +# 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) + +# this is ugly, and not enough for the multilib-stuff I guess +if(UNIX AND EXISTS /usr/lib64) + set(CMAKE_SIZEOF_VOID_P 8) +endif() + +set(CMAKE_${LANGUAGE}_COMPILER "dummy") +set(CMAKE_${LANGUAGE}_COMPILER_ID "${COMPILER_ID}") +include(CMake${LANGUAGE}Information) + + +function(print_compile_flags _packageName) + string(TOUPPER "${_packageName}" PACKAGE_NAME) + # Check the following variables: + # FOO_INCLUDE_DIRS + # Foo_INCLUDE_DIRS + # FOO_INCLUDES + # Foo_INCLUDES + # FOO_INCLUDE_DIR + # Foo_INCLUDE_DIR + set(includes) + if(DEFINED ${_packageName}_INCLUDE_DIRS) + set(includes ${_packageName}_INCLUDE_DIRS) + elseif(DEFINED ${PACKAGE_NAME}_INCLUDE_DIRS) + set(includes ${PACKAGE_NAME}_INCLUDE_DIRS) + elseif(DEFINED ${_packageName}_INCLUDES) + set(includes ${_packageName}_INCLUDES) + elseif(DEFINED ${PACKAGE_NAME}_INCLUDES) + set(includes ${PACKAGE_NAME}_INCLUDES) + elseif(DEFINED ${_packageName}_INCLUDE_DIR) + set(includes ${_packageName}_INCLUDE_DIR) + elseif(DEFINED ${PACKAGE_NAME}_INCLUDE_DIR) + set(includes ${PACKAGE_NAME}_INCLUDE_DIR) + endif() + + set(PACKAGE_INCLUDE_DIRS "${${includes}}" PARENT_SCOPE) + + # Check the following variables: + # FOO_DEFINITIONS + # Foo_DEFINITIONS + set(definitions) + if(DEFINED ${_packageName}_DEFINITIONS) + set(definitions ${_packageName}_DEFINITIONS) + elseif(DEFINED ${PACKAGE_NAME}_DEFINITIONS) + set(definitions ${PACKAGE_NAME}_DEFINITIONS) + endif() + + set(PACKAGE_DEFINITIONS "${${definitions}}" ) + +endfunction() + + +function(print_link_flags _packageName) + string(TOUPPER "${_packageName}" PACKAGE_NAME) + # Check the following variables: + # FOO_LIBRARIES + # Foo_LIBRARIES + # FOO_LIBS + # Foo_LIBS + set(libs) + if(DEFINED ${_packageName}_LIBRARIES) + set(libs ${_packageName}_LIBRARIES) + elseif(DEFINED ${PACKAGE_NAME}_LIBRARIES) + set(libs ${PACKAGE_NAME}_LIBRARIES) + elseif(DEFINED ${_packageName}_LIBS) + set(libs ${_packageName}_LIBS) + elseif(DEFINED ${PACKAGE_NAME}_LIBS) + set(libs ${PACKAGE_NAME}_LIBS) + endif() + + set(PACKAGE_LIBRARIES "${${libs}}" PARENT_SCOPE ) + +endfunction() + + +find_package("${NAME}" QUIET) + +set(PACKAGE_FOUND FALSE) + +string(TOUPPER "${NAME}" UPPERCASE_NAME) + +if(${NAME}_FOUND OR ${UPPERCASE_NAME}_FOUND) + set(PACKAGE_FOUND TRUE) + + if("${MODE}" STREQUAL "EXIST") + # do nothing + elseif("${MODE}" STREQUAL "COMPILE") + print_compile_flags(${NAME}) + elseif("${MODE}" STREQUAL "LINK") + print_link_flags(${NAME}) + else("${MODE}" STREQUAL "LINK") + message(FATAL_ERROR "Invalid mode argument ${MODE} given.") + endif() + +endif() + +set(PACKAGE_QUIET ${SILENT} ) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 3d42c7fa4..5b6286eec 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -547,8 +547,104 @@ void cmake::ReadListFile(const std::vector& args, bool cmake::FindPackage(const std::vector& args) { - // create empty function for now, will be filled later - return true; + // if a generator was not yet created, temporarily create one + cmGlobalGenerator *gg = new cmGlobalGenerator; + gg->SetCMakeInstance(this); + this->SetGlobalGenerator(gg); + + // read in the list file to fill the cache + std::auto_ptr lg(gg->CreateLocalGenerator()); + cmMakefile* mf = lg->GetMakefile(); + mf->SetHomeOutputDirectory + (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + mf->SetStartOutputDirectory + (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + mf->SetHomeDirectory + (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + mf->SetStartDirectory + (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + + mf->SetArgcArgv(args); + + std::string systemFile = mf->GetModulesFile("CMakeFindPackageMode.cmake"); + mf->ReadListFile(0, systemFile.c_str()); + + std::string language = mf->GetSafeDefinition("LANGUAGE"); + std::string mode = mf->GetSafeDefinition("MODE"); + std::string packageName = mf->GetSafeDefinition("NAME"); + bool packageFound = mf->IsOn("PACKAGE_FOUND"); + bool quiet = mf->IsOn("PACKAGE_QUIET"); + + if (!packageFound) + { + if (!quiet) + { + printf("%s not found.\n", packageName.c_str()); + } + } + else if (mode == "EXIST") + { + if (!quiet) + { + printf("%s found.\n", packageName.c_str()); + } + } + else if (mode == "COMPILE") + { + std::string includes = mf->GetSafeDefinition("PACKAGE_INCLUDE_DIRS"); + std::vector includeDirs; + cmSystemTools::ExpandListArgument(includes, includeDirs); + for(std::vector::const_iterator dirIt=includeDirs.begin(); + dirIt != includeDirs.end(); + ++dirIt) + { + mf->AddIncludeDirectory(dirIt->c_str(), false); + } + + std::string includeFlags = lg->GetIncludeFlags(language.c_str(), false); + std::string definitions = mf->GetSafeDefinition("PACKAGE_DEFINITIONS"); + printf("%s %s\n", includeFlags.c_str(), definitions.c_str()); + } + else if (mode == "LINK") + { + const char* targetName = "dummy"; + std::vector srcs; + cmTarget* tgt = mf->AddExecutable(targetName, srcs, true); + tgt->SetProperty("LINKER_LANGUAGE", language.c_str()); + + std::string libs = mf->GetSafeDefinition("PACKAGE_LIBRARIES"); + std::vector libList; + cmSystemTools::ExpandListArgument(libs, libList); + for(std::vector::const_iterator libIt=libList.begin(); + libIt != libList.end(); + ++libIt) + { + mf->AddLinkLibraryForTarget(targetName, libIt->c_str(), cmTarget::GENERAL); + } + + + std::string linkLibs; + std::string flags; + std::string linkFlags; + lg->GetTargetFlags(linkLibs, flags, linkFlags, *tgt); + + printf("%s\n", linkLibs.c_str() ); + +/* if ( use_win32 ) + { + tgt->SetProperty("WIN32_EXECUTABLE", "ON"); + } + if ( use_macbundle) + { + tgt->SetProperty("MACOSX_BUNDLE", "ON"); + }*/ + } + + // free generic one if generated +// this->SetGlobalGenerator(0); // setting 0-pointer is not possible +// delete gg; // this crashes inside the cmake instance + + return packageFound; } From 7690edffd9801c41dcfa4ef2a6213d4883e55c83 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 13 Jul 2011 18:59:51 +0200 Subject: [PATCH 04/24] Replace cmake::GetScriptMode() with GetWorkingMode() GetWorkingMode() returns a new enum WorkingMode, which is one of NORMAL_MODE, SCRIPT_MODE and FIND_PACKAGE_MODE. Alex --- Source/cmGlobalGenerator.cxx | 2 +- Source/cmMakefile.cxx | 8 ++++---- Source/cmake.cxx | 15 +++++++-------- Source/cmake.h | 34 ++++++++++++++++++++++------------ Source/cmakemain.cxx | 10 ++++------ 5 files changed, 38 insertions(+), 31 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 6c8938e5d..31035cd5c 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -782,7 +782,7 @@ void cmGlobalGenerator::Configure() // so create the map from project name to vector of local generators this->FillProjectMap(); - if ( !this->CMakeInstance->GetScriptMode() ) + if ( this->CMakeInstance->GetWorkingMode() == cmake::NORMAL_MODE) { const char* msg = "Configuring done"; if(cmSystemTools::GetErrorOccuredFlag()) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 163145eb7..3329a2c4b 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -384,8 +384,8 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, // Decide whether to invoke the command. if(pcmd->GetEnabled() && !cmSystemTools::GetFatalErrorOccured() && - (this->GetCMakeInstance()->GetFindPackageMode() - || !this->GetCMakeInstance()->GetScriptMode() || pcmd->IsScriptable())) + (this->GetCMakeInstance()->GetWorkingMode() != cmake::SCRIPT_MODE + || pcmd->IsScriptable())) { // if trace is one, print out invoke information @@ -413,7 +413,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, this->IssueMessage(cmake::FATAL_ERROR, pcmd->GetError()); } result = false; - if ( this->GetCMakeInstance()->GetScriptMode() ) + if ( this->GetCMakeInstance()->GetWorkingMode() != cmake::NORMAL_MODE) { cmSystemTools::SetFatalErrorOccured(); } @@ -424,7 +424,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, this->UsedCommands.push_back(pcmd.release()); } } - else if ( this->GetCMakeInstance()->GetScriptMode() + else if ( this->GetCMakeInstance()->GetWorkingMode() == cmake::SCRIPT_MODE && !pcmd->IsScriptable() ) { std::string error = "Command "; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 5b6286eec..8cadc4f75 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -180,8 +180,7 @@ cmake::cmake() this->GlobalGenerator = 0; this->ProgressCallback = 0; this->ProgressCallbackClientData = 0; - this->ScriptMode = false; - this->FindPackageMode = false; + this->CurrentWorkingMode = NORMAL_MODE; #ifdef CMAKE_BUILD_WITH_CMAKE this->VariableWatch = new cmVariableWatch; @@ -523,7 +522,7 @@ void cmake::ReadListFile(const std::vector& args, (cmSystemTools::GetCurrentWorkingDirectory().c_str()); lg->GetMakefile()->SetStartDirectory (cmSystemTools::GetCurrentWorkingDirectory().c_str()); - if (this->GetScriptMode()) + if (this->GetWorkingMode() != NORMAL_MODE) { std::string file(cmSystemTools::CollapseFullPath(path)); cmSystemTools::ConvertToUnixSlashes(file); @@ -2147,7 +2146,7 @@ int cmake::ActualConfigure() this->CleanupCommandsAndMacros(); int res = 0; - if ( !this->ScriptMode ) + if ( this->GetWorkingMode() == NORMAL_MODE ) { res = this->DoPreConfigureChecks(); } @@ -2335,7 +2334,7 @@ int cmake::ActualConfigure() this->CacheManager->RemoveCacheEntry("CMAKE_EXTRA_GENERATOR"); } // only save the cache if there were no fatal errors - if ( !this->ScriptMode ) + if ( this->GetWorkingMode() == NORMAL_MODE ) { this->CacheManager->SaveCache(this->GetHomeOutputDirectory()); } @@ -2401,7 +2400,7 @@ int cmake::Run(const std::vector& args, bool noconfigure) // set the cmake command this->CMakeCommand = args[0]; - if ( !this->ScriptMode ) + if ( this->GetWorkingMode() == NORMAL_MODE ) { // load the cache if(this->LoadCache() < 0) @@ -2422,7 +2421,7 @@ int cmake::Run(const std::vector& args, bool noconfigure) } // In script mode we terminate after running the script. - if(this->ScriptMode) + if(this->GetWorkingMode() != NORMAL_MODE) { if(cmSystemTools::GetErrorOccuredFlag()) { @@ -2468,7 +2467,7 @@ int cmake::Run(const std::vector& args, bool noconfigure) this->SetStartDirectory(this->GetHomeDirectory()); this->SetStartOutputDirectory(this->GetHomeOutputDirectory()); int ret = this->Configure(); - if (ret || this->ScriptMode) + if (ret || this->GetWorkingMode() != NORMAL_MODE) { #if defined(CMAKE_HAVE_VS_GENERATORS) if(!this->VSSolutionFile.empty() && this->GlobalGenerator) diff --git a/Source/cmake.h b/Source/cmake.h index 7335813bc..46d375eac 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -64,6 +64,25 @@ class cmake WARNING, LOG }; + + + /** Describes the working modes of cmake. + * NORMAL_MODE: cmake runs to create project files + * SCRIPT_MODE: in script mode there is no generator and no cache. Also, + * language are not enabled, so add_executable and things do + * not do anything. Started by using -P + * FIND_PACKAGE_MODE: cmake runs in pkg-config like mode, i.e. it just + * searches for a package and prints the results to stdout. + * This is similar to SCRIPT_MODE, but commands like + * add_library() work too, since they may be used e.g. in + * exported target files. Started via --find-package + */ + enum WorkingMode + { + NORMAL_MODE, + SCRIPT_MODE, + FIND_PACKAGE_MODE + }; typedef std::map RegisteredCommandsMap; ///! construct an instance of cmake @@ -274,16 +293,8 @@ class cmake ///! Do all the checks before running configure int DoPreConfigureChecks(); - /** - * Set and get the script mode option. In script mode there is no - * generator and no cache. Also, language are not enabled, so - * add_executable and things do not do anything. - */ - void SetScriptMode(bool mode) { this->ScriptMode = mode; } - bool GetScriptMode() { return this->ScriptMode; } - - void SetFindPackageMode(bool mode) {this->FindPackageMode = mode; } - bool GetFindPackageMode() {return this->FindPackageMode;} + void SetWorkingMode(WorkingMode mode) { this->CurrentWorkingMode = mode; } + WorkingMode GetWorkingMode() { return this->CurrentWorkingMode; } ///! Debug the try compile stuff by not delelting the files bool GetDebugTryCompile(){return this->DebugTryCompile;} @@ -464,8 +475,7 @@ private: void* ProgressCallbackClientData; bool Verbose; bool InTryCompile; - bool ScriptMode; - bool FindPackageMode; + WorkingMode CurrentWorkingMode; bool DebugOutput; bool Trace; bool WarnUninitialized; diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index ae4529a44..c744dcd1b 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -436,8 +436,7 @@ int do_cmake(int ac, char** av) bool list_all_cached = false; bool list_help = false; bool view_only = false; - bool script_mode = false; - bool find_package_mode = false; + cmake::WorkingMode workingMode = cmake::NORMAL_MODE; std::vector args; for(int i =0; i < ac; ++i) { @@ -485,7 +484,7 @@ int do_cmake(int ac, char** av) } else { - script_mode = true; + workingMode = cmake::SCRIPT_MODE; args.push_back(av[i]); i++; args.push_back(av[i]); @@ -494,7 +493,7 @@ int do_cmake(int ac, char** av) else if (!command && strncmp(av[i], "--find-package", strlen("--find-package")) == 0) { - find_package_mode = true; + workingMode = cmake::FIND_PACKAGE_MODE; args.push_back(av[i]); } else @@ -521,8 +520,7 @@ int do_cmake(int ac, char** av) cmake cm; cmSystemTools::SetErrorCallback(cmakemainErrorCallback, (void *)&cm); cm.SetProgressCallback(cmakemainProgressCallback, (void *)&cm); - cm.SetScriptMode(script_mode || find_package_mode); - cm.SetFindPackageMode(find_package_mode); + cm.SetWorkingMode(workingMode); int res = cm.Run(args, view_only); if ( list_cached || list_all_cached ) From b8fdaa1d662b01a167c94f2a9a9efec9dd0ea2d0 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 13 Jul 2011 19:02:08 +0200 Subject: [PATCH 05/24] Fix copyright notice in new CMakeFindPackageMode.cmake Alex --- Modules/CMakeFindPackageMode.cmake | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Modules/CMakeFindPackageMode.cmake b/Modules/CMakeFindPackageMode.cmake index 5842c7aef..7e954633b 100644 --- a/Modules/CMakeFindPackageMode.cmake +++ b/Modules/CMakeFindPackageMode.cmake @@ -4,6 +4,19 @@ # NAME = name of the package # QUIET = if TRUE, don't print anything +#============================================================================= +# Copyright 2006-2011 Alexander Neundorf, +# +# 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.) + if(NOT NAME) message(FATAL_ERROR "NAME argument not specified.") endif() From 53edfb206b549f0dd5a014aac054ca82d865bbcd Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Thu, 14 Jul 2011 23:53:01 +0200 Subject: [PATCH 06/24] Better support for lib64 and Debian multiarch If CMAKE_SIZEOF_VOID_P is not set from the outside, it checks for the existance of /usr/lib64, and if it exists, SIZEOF_VOID_P is set to 8. For multiarch, if this is debian and CMAKE_${LANGUAGE}_LANGUAGE_ARCHITECTURE has not been set, it globs for the files in /lib, and uses the first one which matches CMAKE_LIBRARY_ARCHITECTURE_REGEX. Alex --- Modules/CMakeFindPackageMode.cmake | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/Modules/CMakeFindPackageMode.cmake b/Modules/CMakeFindPackageMode.cmake index 7e954633b..bebf3ab0d 100644 --- a/Modules/CMakeFindPackageMode.cmake +++ b/Modules/CMakeFindPackageMode.cmake @@ -40,9 +40,32 @@ include(CMakeDetermineSystem) # This makes the FIND_XXX() calls work much better include(CMakeSystemSpecificInformation) -# this is ugly, and not enough for the multilib-stuff I guess -if(UNIX AND EXISTS /usr/lib64) - set(CMAKE_SIZEOF_VOID_P 8) +if(UNIX) + + # try to guess whether we have a 64bit system, if it has not been set + # from the outside + if(NOT CMAKE_SIZEOF_VOID_P) + if(EXISTS /usr/lib64) + set(CMAKE_SIZEOF_VOID_P 8) + else() + set(CMAKE_SIZEOF_VOID_P 4) + endif() + endif() + + # guess Debian multiarch if it has not been set: + if(EXISTS /etc/debian_version) + if(NOT CMAKE_${LANGUAGE}_LANGUAGE_ARCHITECTURE ) + file(GLOB filesInLib RELATIVE /lib /lib/*-linux-gnu* ) + list(APPEND filesInLib i386-linux-gnu) + foreach(file ${filesInLib}) + if("${file}" MATCHES "${CMAKE_LIBRARY_ARCHITECTURE_REGEX}") + set(CMAKE_${LANGUAGE}_LANGUAGE_ARCHITECTURE ${file}) + break() + endif() + endforeach() + endif() + endif() + endif() set(CMAKE_${LANGUAGE}_COMPILER "dummy") From b0e357824c0ddf1a57db7742da3d5f3f90af97d2 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Mon, 18 Jul 2011 21:40:45 +0200 Subject: [PATCH 07/24] Use the file-utility to test for 64bit if there is no /usr/lib64 Alex --- Modules/CMakeFindPackageMode.cmake | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Modules/CMakeFindPackageMode.cmake b/Modules/CMakeFindPackageMode.cmake index bebf3ab0d..3e5cb49a6 100644 --- a/Modules/CMakeFindPackageMode.cmake +++ b/Modules/CMakeFindPackageMode.cmake @@ -45,10 +45,18 @@ if(UNIX) # try to guess whether we have a 64bit system, if it has not been set # from the outside if(NOT CMAKE_SIZEOF_VOID_P) + set(CMAKE_SIZEOF_VOID_P 4) if(EXISTS /usr/lib64) set(CMAKE_SIZEOF_VOID_P 8) else() - set(CMAKE_SIZEOF_VOID_P 4) + # use the file utility to check whether itself is 64 bit: + find_program(FILE_EXECUTABLE file) + if(FILE_EXECUTABLE) + execute_process(COMMAND "${FILE_EXECUTABLE}" "${FILE_EXECUTABLE}" OUTPUT_VARIABLE fileOutput ERROR_QUIET) + if("${fileOutput}" MATCHES "64-bit") + set(CMAKE_SIZEOF_VOID_P 8) + endif() + endif() endif() endif() @@ -56,7 +64,6 @@ if(UNIX) if(EXISTS /etc/debian_version) if(NOT CMAKE_${LANGUAGE}_LANGUAGE_ARCHITECTURE ) file(GLOB filesInLib RELATIVE /lib /lib/*-linux-gnu* ) - list(APPEND filesInLib i386-linux-gnu) foreach(file ${filesInLib}) if("${file}" MATCHES "${CMAKE_LIBRARY_ARCHITECTURE_REGEX}") set(CMAKE_${LANGUAGE}_LANGUAGE_ARCHITECTURE ${file}) From bf0737526419936915a9f2c14f06bff556d1fcd4 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 10 Aug 2011 01:51:38 +0200 Subject: [PATCH 08/24] Add a cmake.m4 for using cmake in autoconf projects instead of pkgconfig This file has been written today from scratch by Matthias Kretz and it BSD-licensed. Alex --- Modules/CMakeFindPackageMode.cmake | 2 +- Utilities/CMakeLists.txt | 1 + Utilities/cmake.m4 | 53 ++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 Utilities/cmake.m4 diff --git a/Modules/CMakeFindPackageMode.cmake b/Modules/CMakeFindPackageMode.cmake index 3e5cb49a6..3e7376c8a 100644 --- a/Modules/CMakeFindPackageMode.cmake +++ b/Modules/CMakeFindPackageMode.cmake @@ -1,4 +1,4 @@ -# COMPILER_ID = GNU/Intel/etc. +# COMPILER_ID = GNU/Intel/Clang/MSVC, etc. # LANGUAGE = C/CXX/Fortan/ASM # MODE = EXIST/COMPILE/LINK # NAME = name of the package diff --git a/Utilities/CMakeLists.txt b/Utilities/CMakeLists.txt index 8b3e7f658..85db3679e 100644 --- a/Utilities/CMakeLists.txt +++ b/Utilities/CMakeLists.txt @@ -126,6 +126,7 @@ ADD_CUSTOM_COMMAND( INSTALL_FILES(${CMAKE_MAN_DIR}/man1 FILES ${MAN_FILES}) INSTALL_FILES(${CMAKE_DOC_DIR} FILES ${HTML_FILES} ${TEXT_FILES}) +INSTALL_FILES(share/aclocal FILES cmake.m4) # Drive documentation generation. ADD_CUSTOM_TARGET(documentation ALL DEPENDS ${DOC_FILES} ${CMake_BINARY_DIR}/Docs/cmake.txt ) diff --git a/Utilities/cmake.m4 b/Utilities/cmake.m4 new file mode 100644 index 000000000..a374a3bfb --- /dev/null +++ b/Utilities/cmake.m4 @@ -0,0 +1,53 @@ +dnl ============================================================================ +dnl CMake - Cross Platform Makefile Generator +dnl Copyright 2011 Matthias Kretz, kretz@kde.org +dnl +dnl Distributed under the OSI-approved BSD License (the "License"); +dnl see accompanying file Copyright.txt for details. +dnl +dnl This software is distributed WITHOUT ANY WARRANTY; without even the +dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +dnl See the License for more information. +dnl ============================================================================ + +AC_DEFUN([CMAKE_FIND_BINARY], +[AC_ARG_VAR([CMAKE_BINARY], [path to the cmake binary])dnl + +if test "x$ac_cv_env_CMAKE_BINARY_set" != "xset"; then + AC_PATH_TOOL([CMAKE_BINARY], [cmake])dnl +fi +])dnl + +# $1: package name +# $2: language (e.g. C/CXX/Fortran) +# $3: The compiler ID, defaults to GNU. +# Possible values are: GNU, Intel, Clang, SunPro, HP, XL, VisualAge, PGI, +# PathScale, Cray, SCO, MIPSpro, MSVC +# $4: optional extra arguments to cmake, e.g. "-DCMAKE_SIZEOF_VOID_P=8" +# $5: optional path to cmake binary +AC_DEFUN([CMAKE_FIND_PACKAGE], [ +AC_REQUIRE([CMAKE_FIND_BINARY])dnl + +AC_ARG_VAR([$1][_][$2][FLAGS], [$2 compiler flags for $1. This overrides the cmake output])dnl +AC_ARG_VAR([$1][_LIBS], [linker flags for $1. This overrides the cmake output])dnl + +failed=false +AC_MSG_CHECKING([for $1]) +if test -n "$1[]_$2[]FLAGS"; then + $1[]_$2[]FLAGS=`$CMAKE_BINARY --find-package "-DNAME=$1" "-DCOMPILER_ID=m4_default([$3], [GNU])" "-DLANGUAGE=$2" -DMODE=COMPILE $4` || failed=true +fi +if test -n "$1[]_LIBS"; then + $1[]_LIBS=`$CMAKE_BINARY --find-package "-DNAME=$1" "-DCOMPILER_ID=m4_default([$3], [GNU])" "-DLANGUAGE=$2" -DMODE=LINK $4` || failed=true +fi + +if $failed; then + unset $1[]_$2[]FLAGS + unset $1[]_LIBS + + AC_MSG_RESULT([no]) + $6 +else + AC_MSG_RESULT([yes]) + $5 +fi[]dnl +]) From d3ae0fff7dea00775f8c6e8bed59a494f102999c Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 10 Aug 2011 02:05:33 +0200 Subject: [PATCH 09/24] Improve documentation for --find-package mode Alex --- Modules/CMakeFindPackageMode.cmake | 16 ++++++++++------ Source/cmakemain.cxx | 4 +++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Modules/CMakeFindPackageMode.cmake b/Modules/CMakeFindPackageMode.cmake index 3e7376c8a..2ce4fe61e 100644 --- a/Modules/CMakeFindPackageMode.cmake +++ b/Modules/CMakeFindPackageMode.cmake @@ -1,8 +1,12 @@ -# COMPILER_ID = GNU/Intel/Clang/MSVC, etc. -# LANGUAGE = C/CXX/Fortan/ASM -# MODE = EXIST/COMPILE/LINK -# NAME = name of the package -# QUIET = if TRUE, don't print anything +# This file is executed by cmake when invoked with --find-package. +# It expects that the following variables are set using -D: +# NAME = name of the package +# COMPILER_ID = the CMake compiler ID for which the result is, i.e. GNU/Intel/Clang/MSVC, etc. +# LANGUAGE = language for which the result will be used, i.e. C/CXX/Fortan/ASM +# MODE = EXIST : only check for existance of the given package +# COMPILE : print the flags needed for compiling an object file which uses the given package +# LINK : print the flags needed for linking when using the given package +# QUIET = if TRUE, don't print anything #============================================================================= # Copyright 2006-2011 Alexander Neundorf, @@ -18,7 +22,7 @@ # License text for the above reference.) if(NOT NAME) - message(FATAL_ERROR "NAME argument not specified.") + message(FATAL_ERROR "Name of the package to be searched not specified. Set the CMake variable NAME, e.g. -DNAME=JPEG .") endif() if(NOT COMPILER_ID) diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index c744dcd1b..828d2aaa2 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -104,7 +104,9 @@ static const char * cmDocumentationOptions[][3] = "before the -P argument."}, {"--find-package", "Run in pkg-config like mode.", "Search a package using find_package() and print the resulting flags " - "to stdout. "}, + "to stdout. This can be used to use cmake instead of pkg-config to find " + "installed libraries in plain Makefile-based projects or in " + "autoconf-based projects (via share/aclocal/cmake.m4)."}, {"--graphviz=[file]", "Generate graphviz of dependencies.", "Generate a graphviz input file that will contain all the library and " "executable dependencies in the project."}, From 9fc87c6343a5d448f04d7a9397beb95e3b85178e Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Thu, 11 Aug 2011 23:27:19 +0200 Subject: [PATCH 10/24] Add a test for the new --find-package mode Alex --- Tests/CMakeLists.txt | 2 ++ .../CMakeLists.txt | 22 +++++++++++++++++++ Tests/FindPackageModeMakefileTest/Makefile.in | 8 +++++++ Tests/FindPackageModeMakefileTest/main.cpp | 8 +++++++ 4 files changed, 40 insertions(+) create mode 100644 Tests/FindPackageModeMakefileTest/CMakeLists.txt create mode 100644 Tests/FindPackageModeMakefileTest/Makefile.in create mode 100644 Tests/FindPackageModeMakefileTest/main.cpp diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 2ad9a7759..a75b3df8f 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -46,6 +46,8 @@ IF(BUILD_TESTING) ADD_SUBDIRECTORY(CMakeLib) + ADD_SUBDIRECTORY(FindPackageModeMakefileTest) + # Collect a list of all test build directories. SET(TEST_BUILD_DIRS) diff --git a/Tests/FindPackageModeMakefileTest/CMakeLists.txt b/Tests/FindPackageModeMakefileTest/CMakeLists.txt new file mode 100644 index 000000000..0be3783dc --- /dev/null +++ b/Tests/FindPackageModeMakefileTest/CMakeLists.txt @@ -0,0 +1,22 @@ + +if("${CMAKE_CXX_COMPILER_ID}" MATCHES GNU + OR "${CMAKE_CXX_COMPILER_ID}" MATCHES Intel + OR "${CMAKE_CXX_COMPILER_ID}" MATCHES Clang + OR "${CMAKE_CXX_COMPILER_ID}" MATCHES XL + OR "${CMAKE_CXX_COMPILER_ID}" MATCHES SunPro) + + find_package(PNG) + + # the test program links against the png lib, so test first whether it exists + if(PNG_FOUND) + + get_target_property(cmakeExecutable cmake LOCATION) + + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Makefile.in ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile @ONLY) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ${CMAKE_CURRENT_BINARY_DIR}/main.cpp COPYONLY) + + add_test(FindPackageModeMakefileTest ${CMAKE_MAKE_PROGRAM} -f ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile -C ${CMAKE_CURRENT_BINARY_DIR} ) + + endif() + +endif() diff --git a/Tests/FindPackageModeMakefileTest/Makefile.in b/Tests/FindPackageModeMakefileTest/Makefile.in new file mode 100644 index 000000000..5105d9949 --- /dev/null +++ b/Tests/FindPackageModeMakefileTest/Makefile.in @@ -0,0 +1,8 @@ +all: clean pngtest + +pngtest: main.o + "@CMAKE_CXX_COMPILER@" -c `"@cmakeExecutable@" --find-package -DNAME=PNG -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=COMPILE` main.cpp + "@CMAKE_CXX_COMPILER@" -o pngtest main.o `"@cmakeExecutable@" --find-package -DNAME=PNG -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=LINK` + +clean: + rm -f *.o pngtest diff --git a/Tests/FindPackageModeMakefileTest/main.cpp b/Tests/FindPackageModeMakefileTest/main.cpp new file mode 100644 index 000000000..b78542700 --- /dev/null +++ b/Tests/FindPackageModeMakefileTest/main.cpp @@ -0,0 +1,8 @@ +#include +#include + +int main() +{ + printf("PNG copyright: %s\n", png_get_copyright(NULL)); + return 0; +} From fd15b5e1c425b0e2cb418e87a115215b0aa7501a Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Thu, 11 Aug 2011 23:32:30 +0200 Subject: [PATCH 11/24] Only run the test if we are using a makefile generator under UNIX Alex --- Tests/FindPackageModeMakefileTest/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/FindPackageModeMakefileTest/CMakeLists.txt b/Tests/FindPackageModeMakefileTest/CMakeLists.txt index 0be3783dc..f0faab93d 100644 --- a/Tests/FindPackageModeMakefileTest/CMakeLists.txt +++ b/Tests/FindPackageModeMakefileTest/CMakeLists.txt @@ -8,7 +8,7 @@ if("${CMAKE_CXX_COMPILER_ID}" MATCHES GNU find_package(PNG) # the test program links against the png lib, so test first whether it exists - if(PNG_FOUND) + if(PNG_FOUND AND UNIX AND "${CMAKE_GENERATOR}" MATCHES "Makefile") get_target_property(cmakeExecutable cmake LOCATION) From 6bb4ca3802d2fc83f1072adfde6f1075aa2992c4 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sun, 14 Aug 2011 15:38:24 +0200 Subject: [PATCH 12/24] The makefile for the test was kindof wrong Alex --- Tests/FindPackageModeMakefileTest/Makefile.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Tests/FindPackageModeMakefileTest/Makefile.in b/Tests/FindPackageModeMakefileTest/Makefile.in index 5105d9949..5e42305b8 100644 --- a/Tests/FindPackageModeMakefileTest/Makefile.in +++ b/Tests/FindPackageModeMakefileTest/Makefile.in @@ -1,7 +1,9 @@ all: clean pngtest -pngtest: main.o +main.o: main.cpp "@CMAKE_CXX_COMPILER@" -c `"@cmakeExecutable@" --find-package -DNAME=PNG -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=COMPILE` main.cpp + +pngtest: main.o "@CMAKE_CXX_COMPILER@" -o pngtest main.o `"@cmakeExecutable@" --find-package -DNAME=PNG -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=LINK` clean: From aecfc1fd1045fef4af58a16782c2272dd5825aa5 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Tue, 16 Aug 2011 00:08:43 +0200 Subject: [PATCH 13/24] Fix test on OpenBSD with BSD make BSD make doesn't seem to support -C, so do not use it, According to the documentation the working directory is set to CMAKE_CURRENT_BINARY_DIR anyway, so it should work just the same. Alex --- Tests/FindPackageModeMakefileTest/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/FindPackageModeMakefileTest/CMakeLists.txt b/Tests/FindPackageModeMakefileTest/CMakeLists.txt index f0faab93d..d2c6be9c9 100644 --- a/Tests/FindPackageModeMakefileTest/CMakeLists.txt +++ b/Tests/FindPackageModeMakefileTest/CMakeLists.txt @@ -15,7 +15,7 @@ if("${CMAKE_CXX_COMPILER_ID}" MATCHES GNU configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Makefile.in ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile @ONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ${CMAKE_CURRENT_BINARY_DIR}/main.cpp COPYONLY) - add_test(FindPackageModeMakefileTest ${CMAKE_MAKE_PROGRAM} -f ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile -C ${CMAKE_CURRENT_BINARY_DIR} ) + add_test(FindPackageModeMakefileTest ${CMAKE_MAKE_PROGRAM} -f ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile ) endif() From e589589ab18daabc863061fac515adc2b1ae8d55 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Tue, 16 Aug 2011 00:22:17 +0200 Subject: [PATCH 14/24] Rename helper macros print_compile_flags() to set_compile_flags_var() The same for print_link_flags(), it is now set_link_flags_var(). Both macros don't print anything anymore, this was only in the beginning. Alex --- Modules/CMakeFindPackageMode.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/CMakeFindPackageMode.cmake b/Modules/CMakeFindPackageMode.cmake index 2ce4fe61e..e4d085dd5 100644 --- a/Modules/CMakeFindPackageMode.cmake +++ b/Modules/CMakeFindPackageMode.cmake @@ -84,7 +84,7 @@ set(CMAKE_${LANGUAGE}_COMPILER_ID "${COMPILER_ID}") include(CMake${LANGUAGE}Information) -function(print_compile_flags _packageName) +function(set_compile_flags_var _packageName) string(TOUPPER "${_packageName}" PACKAGE_NAME) # Check the following variables: # FOO_INCLUDE_DIRS @@ -125,7 +125,7 @@ function(print_compile_flags _packageName) endfunction() -function(print_link_flags _packageName) +function(set_link_flags_var _packageName) string(TOUPPER "${_packageName}" PACKAGE_NAME) # Check the following variables: # FOO_LIBRARIES @@ -160,9 +160,9 @@ if(${NAME}_FOUND OR ${UPPERCASE_NAME}_FOUND) if("${MODE}" STREQUAL "EXIST") # do nothing elseif("${MODE}" STREQUAL "COMPILE") - print_compile_flags(${NAME}) + set_compile_flags_var(${NAME}) elseif("${MODE}" STREQUAL "LINK") - print_link_flags(${NAME}) + set_link_flags_var(${NAME}) else("${MODE}" STREQUAL "LINK") message(FATAL_ERROR "Invalid mode argument ${MODE} given.") endif() From e552ae7cfd8d6b3dce51f61258ce4854db7c7fbc Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Tue, 16 Aug 2011 00:30:07 +0200 Subject: [PATCH 15/24] Dont check for -isysroot and -mmacosx-version on OSX in --find-package mode Alex --- Modules/CMakeFindPackageMode.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Modules/CMakeFindPackageMode.cmake b/Modules/CMakeFindPackageMode.cmake index e4d085dd5..a8674aad3 100644 --- a/Modules/CMakeFindPackageMode.cmake +++ b/Modules/CMakeFindPackageMode.cmake @@ -40,6 +40,12 @@ endif() include(CMakeDetermineSystem) +# short-cut some tests on Darwin, see Darwin-GNU.cmake: +if("${CMAKE_SYSTEM_NAME}" MATCHES Darwin AND "${COMPILER_ID}" MATCHES GNU) + set(${CMAKE_${LANGUAGE}_HAS_ISYSROOT} 0 ) + set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "") +endif() + # 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 ec6982dc8cad04c72a6ab78b7f115ece65e812bd Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Tue, 16 Aug 2011 00:40:59 +0200 Subject: [PATCH 16/24] Disable any STATUS output in --find-package mode Any STATUS output will be fed directly to the compiler, which will not understand any status messages. Error messages are fine, since they are errors and it is ok if the compiler fails in such cases. Alex --- Source/cmMakefile.cxx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 3329a2c4b..b94db48d6 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3022,8 +3022,15 @@ cmCacheManager *cmMakefile::GetCacheManager() const void cmMakefile::DisplayStatus(const char* message, float s) { - this->GetLocalGenerator()->GetGlobalGenerator() - ->GetCMakeInstance()->UpdateProgress(message, s); + cmake* cm = this->GetLocalGenerator()->GetGlobalGenerator() + ->GetCMakeInstance(); + if (cm->GetWorkingMode() == cmake::FIND_PACKAGE_MODE) + { + // don't output any STATUS message in FIND_PACKAGE_MODE, since they will + // directly be fed to the compiler, which will be confused. + return; + } + cm->UpdateProgress(message, s); } std::string cmMakefile::GetModulesFile(const char* filename) From 626fc717c6a6fb880053e645b3f12805f60c102a Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Tue, 16 Aug 2011 22:31:26 +0200 Subject: [PATCH 17/24] Much improved test, should now be executed on all UNIXes Instead of relying on that some development package is installed on the system, now a tiny library is built, which is the searched and used during the test. Alex --- .../CMakeLists.txt | 24 +++++++++---------- .../FindFoo.cmake.in | 8 +++++++ Tests/FindPackageModeMakefileTest/Makefile.in | 4 ++-- Tests/FindPackageModeMakefileTest/foo.cpp | 4 ++++ Tests/FindPackageModeMakefileTest/foo.h | 6 +++++ Tests/FindPackageModeMakefileTest/main.cpp | 4 ++-- 6 files changed, 33 insertions(+), 17 deletions(-) create mode 100644 Tests/FindPackageModeMakefileTest/FindFoo.cmake.in create mode 100644 Tests/FindPackageModeMakefileTest/foo.cpp create mode 100644 Tests/FindPackageModeMakefileTest/foo.h diff --git a/Tests/FindPackageModeMakefileTest/CMakeLists.txt b/Tests/FindPackageModeMakefileTest/CMakeLists.txt index d2c6be9c9..17f02b4d3 100644 --- a/Tests/FindPackageModeMakefileTest/CMakeLists.txt +++ b/Tests/FindPackageModeMakefileTest/CMakeLists.txt @@ -1,22 +1,20 @@ -if("${CMAKE_CXX_COMPILER_ID}" MATCHES GNU - OR "${CMAKE_CXX_COMPILER_ID}" MATCHES Intel - OR "${CMAKE_CXX_COMPILER_ID}" MATCHES Clang - OR "${CMAKE_CXX_COMPILER_ID}" MATCHES XL - OR "${CMAKE_CXX_COMPILER_ID}" MATCHES SunPro) - find_package(PNG) +# the test program links against the png lib, so test first whether it exists +if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Makefile") - # the test program links against the png lib, so test first whether it exists - if(PNG_FOUND AND UNIX AND "${CMAKE_GENERATOR}" MATCHES "Makefile") + # build a library which we can search during the test + add_library(foo STATIC foo.cpp) - get_target_property(cmakeExecutable cmake LOCATION) + # configure a FindFoo.cmake so it knows where the library can be found + configure_file(FindFoo.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FindFoo.cmake @ONLY) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Makefile.in ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile @ONLY) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ${CMAKE_CURRENT_BINARY_DIR}/main.cpp COPYONLY) + # now set up the test: + get_target_property(cmakeExecutable cmake LOCATION) - add_test(FindPackageModeMakefileTest ${CMAKE_MAKE_PROGRAM} -f ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile ) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Makefile.in ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile @ONLY) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ${CMAKE_CURRENT_BINARY_DIR}/main.cpp COPYONLY) - endif() + add_test(FindPackageModeMakefileTest ${CMAKE_MAKE_PROGRAM} -f ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile ) endif() diff --git a/Tests/FindPackageModeMakefileTest/FindFoo.cmake.in b/Tests/FindPackageModeMakefileTest/FindFoo.cmake.in new file mode 100644 index 000000000..c6230abb8 --- /dev/null +++ b/Tests/FindPackageModeMakefileTest/FindFoo.cmake.in @@ -0,0 +1,8 @@ + +find_library(FOO_LIBRARY NAMES foo HINTS "@CMAKE_CURRENT_BINARY_DIR@" ) +find_path(FOO_INCLUDE_DIR NAMES foo.h HINTS "@CMAKE_CURRENT_SOURCE_DIR@" ) + +set(FOO_LIBRARIES ${FOO_LIBRARY}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Foo DEFAULT_MSG FOO_LIBRARY FOO_INCLUDE_DIR ) diff --git a/Tests/FindPackageModeMakefileTest/Makefile.in b/Tests/FindPackageModeMakefileTest/Makefile.in index 5e42305b8..6bcd9b695 100644 --- a/Tests/FindPackageModeMakefileTest/Makefile.in +++ b/Tests/FindPackageModeMakefileTest/Makefile.in @@ -1,10 +1,10 @@ all: clean pngtest main.o: main.cpp - "@CMAKE_CXX_COMPILER@" -c `"@cmakeExecutable@" --find-package -DNAME=PNG -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=COMPILE` main.cpp + "@CMAKE_CXX_COMPILER@" -c `"@cmakeExecutable@" --find-package -DCMAKE_MODULE_PATH="@CMAKE_CURRENT_BINARY_DIR@" -DNAME=Foo -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=COMPILE` main.cpp pngtest: main.o - "@CMAKE_CXX_COMPILER@" -o pngtest main.o `"@cmakeExecutable@" --find-package -DNAME=PNG -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=LINK` + "@CMAKE_CXX_COMPILER@" -o pngtest main.o `"@cmakeExecutable@" --find-package -DCMAKE_MODULE_PATH="@CMAKE_CURRENT_BINARY_DIR@" -DNAME=Foo -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=LINK` clean: rm -f *.o pngtest diff --git a/Tests/FindPackageModeMakefileTest/foo.cpp b/Tests/FindPackageModeMakefileTest/foo.cpp new file mode 100644 index 000000000..6aea22629 --- /dev/null +++ b/Tests/FindPackageModeMakefileTest/foo.cpp @@ -0,0 +1,4 @@ +int foo() +{ + return 1477; +} diff --git a/Tests/FindPackageModeMakefileTest/foo.h b/Tests/FindPackageModeMakefileTest/foo.h new file mode 100644 index 000000000..4ec598ad5 --- /dev/null +++ b/Tests/FindPackageModeMakefileTest/foo.h @@ -0,0 +1,6 @@ +#ifndef FOO_H +#define FOO_H + +int foo(); + +#endif diff --git a/Tests/FindPackageModeMakefileTest/main.cpp b/Tests/FindPackageModeMakefileTest/main.cpp index b78542700..e5f9134ce 100644 --- a/Tests/FindPackageModeMakefileTest/main.cpp +++ b/Tests/FindPackageModeMakefileTest/main.cpp @@ -1,8 +1,8 @@ #include -#include +#include int main() { - printf("PNG copyright: %s\n", png_get_copyright(NULL)); + printf("foo is: %d\n", foo()); return 0; } From ab57ff6156a725664fce995a9460de839018405c Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 17 Aug 2011 22:51:57 +0200 Subject: [PATCH 18/24] Make the --find-package test harder Now it is guaranteed that the include paths always contain a space. This should make the cont. build fail. Alex --- Tests/FindPackageModeMakefileTest/Makefile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/FindPackageModeMakefileTest/Makefile.in b/Tests/FindPackageModeMakefileTest/Makefile.in index 6bcd9b695..2d4301a3d 100644 --- a/Tests/FindPackageModeMakefileTest/Makefile.in +++ b/Tests/FindPackageModeMakefileTest/Makefile.in @@ -1,10 +1,10 @@ all: clean pngtest main.o: main.cpp - "@CMAKE_CXX_COMPILER@" -c `"@cmakeExecutable@" --find-package -DCMAKE_MODULE_PATH="@CMAKE_CURRENT_BINARY_DIR@" -DNAME=Foo -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=COMPILE` main.cpp + "@CMAKE_CXX_COMPILER@" -c $(shell "@cmakeExecutable@" --find-package -DCMAKE_MODULE_PATH="@CMAKE_CURRENT_BINARY_DIR@" -DNAME=Foo -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=COMPILE) main.cpp pngtest: main.o - "@CMAKE_CXX_COMPILER@" -o pngtest main.o `"@cmakeExecutable@" --find-package -DCMAKE_MODULE_PATH="@CMAKE_CURRENT_BINARY_DIR@" -DNAME=Foo -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=LINK` + "@CMAKE_CXX_COMPILER@" -o pngtest main.o $(shell "@cmakeExecutable@" --find-package -DCMAKE_MODULE_PATH="@CMAKE_CURRENT_BINARY_DIR@" -DNAME=Foo -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=LINK) clean: rm -f *.o pngtest From 301114994773e62b82965f3082fef6dd23532e60 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 17 Aug 2011 22:53:35 +0200 Subject: [PATCH 19/24] Make the test harder by always having a space in the include dirs The commit message for the previous commit was wrong, it should have been: fix the test by using $(shell ...) syntax instead of backticks in the Makefile. With backticks I couldn't get the quoting right. Printing -I"/some/path with space" did not work, the compiler complained that there is not file "with". Also backslashes in different numbers did not make it work. Alex --- Tests/FindPackageModeMakefileTest/FindFoo.cmake.in | 1 + 1 file changed, 1 insertion(+) diff --git a/Tests/FindPackageModeMakefileTest/FindFoo.cmake.in b/Tests/FindPackageModeMakefileTest/FindFoo.cmake.in index c6230abb8..dc62bac41 100644 --- a/Tests/FindPackageModeMakefileTest/FindFoo.cmake.in +++ b/Tests/FindPackageModeMakefileTest/FindFoo.cmake.in @@ -3,6 +3,7 @@ find_library(FOO_LIBRARY NAMES foo HINTS "@CMAKE_CURRENT_BINARY_DIR@" ) find_path(FOO_INCLUDE_DIR NAMES foo.h HINTS "@CMAKE_CURRENT_SOURCE_DIR@" ) set(FOO_LIBRARIES ${FOO_LIBRARY}) +set(FOO_INCLUDE_DIRS "${FOO_INCLUDE_DIR}" "/some/path/with a space/include" ) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Foo DEFAULT_MSG FOO_LIBRARY FOO_INCLUDE_DIR ) From 7d693108faa0df924944eb2b5ced210d735d75b1 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 17 Aug 2011 23:44:34 +0200 Subject: [PATCH 20/24] Only enable the test when using GNU make The makefile used in the test uses $(shell ...), which is AFAIK a GNU extension, and will probably not work e.g. with OpenBSD make. According to the FreeBSD make manpage their make has a != assignment, which seems to do something similar, but I don't have such a system around for testing. Also, the point of this test is not to write a portable makefile, but to check whether cmake --find-package prints a correct string. Alex --- .../CMakeLists.txt | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/Tests/FindPackageModeMakefileTest/CMakeLists.txt b/Tests/FindPackageModeMakefileTest/CMakeLists.txt index 17f02b4d3..def8d63ec 100644 --- a/Tests/FindPackageModeMakefileTest/CMakeLists.txt +++ b/Tests/FindPackageModeMakefileTest/CMakeLists.txt @@ -1,20 +1,30 @@ -# the test program links against the png lib, so test first whether it exists if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Makefile") - # build a library which we can search during the test - add_library(foo STATIC foo.cpp) + # Test whether the make is GNU make, and only add the test in this case, + # since the configured makefile in this test uses $(shell ...), which + # is AFAIK a GNU make extension. Alex + execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} -v + OUTPUT_VARIABLE makeVersionOutput + TIMEOUT 10) + string(TOUPPER "${makeVersionOutput}" MAKE_VERSION_OUTPUT) + if("${MAKE_VERSION_OUTPUT}" MATCHES ".*GNU MAKE.*") - # configure a FindFoo.cmake so it knows where the library can be found - configure_file(FindFoo.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FindFoo.cmake @ONLY) + # build a library which we can search during the test + add_library(foo STATIC foo.cpp) - # now set up the test: - get_target_property(cmakeExecutable cmake LOCATION) + # configure a FindFoo.cmake so it knows where the library can be found + configure_file(FindFoo.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FindFoo.cmake @ONLY) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Makefile.in ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile @ONLY) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ${CMAKE_CURRENT_BINARY_DIR}/main.cpp COPYONLY) + # now set up the test: + get_target_property(cmakeExecutable cmake LOCATION) - add_test(FindPackageModeMakefileTest ${CMAKE_MAKE_PROGRAM} -f ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile ) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Makefile.in ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile @ONLY) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ${CMAKE_CURRENT_BINARY_DIR}/main.cpp COPYONLY) + + add_test(FindPackageModeMakefileTest ${CMAKE_MAKE_PROGRAM} -f ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile ) + + endif() endif() From 43869188af1648218d506555b2e6ac7e4a92494c Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Thu, 18 Aug 2011 18:39:05 +0200 Subject: [PATCH 21/24] Fix line length Alex --- Source/cmake.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 8cadc4f75..cc9dd8f2d 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -618,7 +618,8 @@ bool cmake::FindPackage(const std::vector& args) libIt != libList.end(); ++libIt) { - mf->AddLinkLibraryForTarget(targetName, libIt->c_str(), cmTarget::GENERAL); + mf->AddLinkLibraryForTarget(targetName, libIt->c_str(), + cmTarget::GENERAL); } From a6ccf3cb6552f8f2b7b6adaf419a278efd085ac3 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Thu, 18 Aug 2011 18:43:33 +0200 Subject: [PATCH 22/24] Use $(CXXFLAGS) and $(LDFLAGS) in the --find-package test Makefile This should make the test succeed in the coverage builds, where CXXFLAGS and LDFLAGS are set accordingly. Alex --- Tests/FindPackageModeMakefileTest/Makefile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/FindPackageModeMakefileTest/Makefile.in b/Tests/FindPackageModeMakefileTest/Makefile.in index 2d4301a3d..073d82ec7 100644 --- a/Tests/FindPackageModeMakefileTest/Makefile.in +++ b/Tests/FindPackageModeMakefileTest/Makefile.in @@ -1,10 +1,10 @@ all: clean pngtest main.o: main.cpp - "@CMAKE_CXX_COMPILER@" -c $(shell "@cmakeExecutable@" --find-package -DCMAKE_MODULE_PATH="@CMAKE_CURRENT_BINARY_DIR@" -DNAME=Foo -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=COMPILE) main.cpp + "@CMAKE_CXX_COMPILER@" $(CXXFLAGS) -c $(shell "@cmakeExecutable@" --find-package -DCMAKE_MODULE_PATH="@CMAKE_CURRENT_BINARY_DIR@" -DNAME=Foo -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=COMPILE) main.cpp pngtest: main.o - "@CMAKE_CXX_COMPILER@" -o pngtest main.o $(shell "@cmakeExecutable@" --find-package -DCMAKE_MODULE_PATH="@CMAKE_CURRENT_BINARY_DIR@" -DNAME=Foo -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=LINK) + "@CMAKE_CXX_COMPILER@" $(LDFLAGS) -o pngtest main.o $(shell "@cmakeExecutable@" --find-package -DCMAKE_MODULE_PATH="@CMAKE_CURRENT_BINARY_DIR@" -DNAME=Foo -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=LINK) clean: rm -f *.o pngtest From 98472e45c86d0b8592e0a6361d392bfab921b3a0 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Mon, 22 Aug 2011 21:23:55 +0200 Subject: [PATCH 23/24] Require the current cmake version in --find-package mode This fixes the problem that otherwise Platforms/CYGWIN.cmake doesn't know whether it should set WIN32 or not. Now it uses always the current behaviour. Alex --- Modules/CMakeFindPackageMode.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Modules/CMakeFindPackageMode.cmake b/Modules/CMakeFindPackageMode.cmake index a8674aad3..e0b588537 100644 --- a/Modules/CMakeFindPackageMode.cmake +++ b/Modules/CMakeFindPackageMode.cmake @@ -37,6 +37,9 @@ if(NOT MODE) message(FATAL_ERROR "MODE argument not specified. Use either EXIST, COMPILE or LINK.") endif() +# require the current version. If we don't do this, Platforms/CYGWIN.cmake complains because +# it doesn't know whether it should set WIN32 or not: +cmake_minimum_required(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} ) include(CMakeDetermineSystem) From 59238dc2deb80f3f3d101de9a3945f890981a2c0 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Mon, 22 Aug 2011 21:53:22 +0200 Subject: [PATCH 24/24] Fix --find-package mode on Cygwin, where enable_language(RC) is called In --find-package mode we can't enable a language, since a lot of stuff has not been set up, e.g. which make tool to use. So disable enable_language() in this mode. Alex --- Modules/CMakeFindPackageMode.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Modules/CMakeFindPackageMode.cmake b/Modules/CMakeFindPackageMode.cmake index e0b588537..42965773a 100644 --- a/Modules/CMakeFindPackageMode.cmake +++ b/Modules/CMakeFindPackageMode.cmake @@ -41,6 +41,12 @@ endif() # it doesn't know whether it should set WIN32 or not: cmake_minimum_required(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} ) +macro(ENABLE_LANGUAGE) + # disable the enable_language() command, otherwise --find-package breaks on Windows. + # On Windows, enable_language(RC) is called in the platform files unconditionally. + # But in --find-package mode, we don't want (and can't) enable any language. +endmacro() + include(CMakeDetermineSystem) # short-cut some tests on Darwin, see Darwin-GNU.cmake: