diff options
author | Brad King <brad.king@kitware.com> | 2023-07-17 18:28:01 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-02-27 19:51:47 (GMT) |
commit | cc3c603061ccef897e6f2a82585d011fb4f0e5f9 (patch) | |
tree | 357d36d5bde29492b13af7d0c2664a40c5707ca4 /Source/CPack | |
parent | a9ad70de76b3d37a0686b4d6ee24cf365bd1f278 (diff) | |
download | CMake-cc3c603061ccef897e6f2a82585d011fb4f0e5f9.zip CMake-cc3c603061ccef897e6f2a82585d011fb4f0e5f9.tar.gz CMake-cc3c603061ccef897e6f2a82585d011fb4f0e5f9.tar.bz2 |
cpack: Simplify package directory selection logic
Diffstat (limited to 'Source/CPack')
-rw-r--r-- | Source/CPack/cpack.cxx | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 00c8fa2..25c001f 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -475,32 +475,26 @@ int main(int argc, char const* const* argv) if (!cpackProjectVendor.empty()) { globalMF.AddDefinition("CPACK_PACKAGE_VENDOR", cpackProjectVendor); } - // if this is not empty it has been set on the command line - // go for it. Command line override values set in config file. if (!cpackProjectDirectory.empty()) { - globalMF.AddDefinition("CPACK_PACKAGE_DIRECTORY", cpackProjectDirectory); - } - // The value has not been set on the command line - else { - // get a default value (current working directory) - cpackProjectDirectory = cmSystemTools::GetCurrentWorkingDirectory(); - // use default value if no value has been provided by the config file - if (!globalMF.IsSet("CPACK_PACKAGE_DIRECTORY")) { - globalMF.AddDefinition("CPACK_PACKAGE_DIRECTORY", - cpackProjectDirectory); + // The value has been set on the command line. Ensure it is absolute. + cpackProjectDirectory = + cmSystemTools::CollapseFullPath(cpackProjectDirectory); + } else { + // The value has not been set on the command line. Check config file. + if (cmValue pd = globalMF.GetDefinition("CPACK_PACKAGE_DIRECTORY")) { + // The value has been set in the config file. Ensure it is absolute. + cpackProjectDirectory = cmSystemTools::CollapseFullPath(*pd); + } else { + // Default to the current working directory. + cpackProjectDirectory = cmSystemTools::GetCurrentWorkingDirectory(); } } + globalMF.AddDefinition("CPACK_PACKAGE_DIRECTORY", cpackProjectDirectory); + for (auto const& cd : definitions) { globalMF.AddDefinition(cd.first, cd.second); } - // Force CPACK_PACKAGE_DIRECTORY as absolute path - cpackProjectDirectory = - globalMF.GetSafeDefinition("CPACK_PACKAGE_DIRECTORY"); - cpackProjectDirectory = - cmSystemTools::CollapseFullPath(cpackProjectDirectory); - globalMF.AddDefinition("CPACK_PACKAGE_DIRECTORY", cpackProjectDirectory); - cmValue cpackModulesPath = globalMF.GetDefinition("CPACK_MODULE_PATH"); if (cpackModulesPath) { globalMF.AddDefinition("CMAKE_MODULE_PATH", *cpackModulesPath); |