From ec497c7a233d4196e227110604267b922da292b4 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 22 Feb 2005 14:52:55 -0500 Subject: [PATCH] ENH: LOAD_COMMAND command will now set a variable called CMAKE_LOADED_COMMAND_ to the full path of the loaded module if loading was successful. Otherwise the variable is not set (will evaluate to empty string). This is useful both in testing whether loading worked and for installing loaded command modules. --- Source/cmLoadCommandCommand.cxx | 13 +++++++++++-- Source/cmLoadCommandCommand.h | 6 +++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx index 60edd56ab..fcdc045be 100644 --- a/Source/cmLoadCommandCommand.cxx +++ b/Source/cmLoadCommandCommand.cxx @@ -226,7 +226,13 @@ bool cmLoadCommandCommand::InitialPass(std::vector const& args) { return true; } - + + // Construct a variable to report what file was loaded, if any. + // Start by removing the definition in case of failure. + std::string reportVar = "CMAKE_LOADED_COMMAND_"; + reportVar += args[0]; + m_Makefile->RemoveDefinition(reportVar.c_str()); + // the file must exist std::string fullPath = cmDynamicLoader::LibPrefix(); fullPath += "cm" + args[0] + cmDynamicLoader::LibExtension(); @@ -269,7 +275,10 @@ bool cmLoadCommandCommand::InitialPass(std::vector const& args) this->SetError(err.c_str()); return false; } - + + // Report what file was loaded for this command. + m_Makefile->AddDefinition(reportVar.c_str(), fullPath.c_str()); + // find the init function std::string initFuncName = args[0] + "Init"; CM_INIT_FUNCTION initFunction diff --git a/Source/cmLoadCommandCommand.h b/Source/cmLoadCommandCommand.h index 8737da236..aae034214 100644 --- a/Source/cmLoadCommandCommand.h +++ b/Source/cmLoadCommandCommand.h @@ -70,7 +70,11 @@ public: "The given locations are searched for a library whose name is " "cmCOMMAND_NAME. If found, it is loaded as a module and the command " "is added to the set of available CMake commands. Usually, TRY_COMPILE " - "is used before this command to compile the module."; + "is used before this command to compile the module. If the command " + "is successfully loaded a variable named\n" + " CMAKE_LOADED_COMMAND_\n" + "will be set to the full path of the module that was loaded. " + "Otherwise the variable will not be set."; } cmTypeMacro(cmLoadCommandCommand, cmCommand);