From 20d5e77a270639a124fea587bb68b2fb6a5356fc Mon Sep 17 00:00:00 2001 From: Craig Scott Date: Mon, 5 Nov 2018 15:58:24 +1100 Subject: CPack: Rename Ext generator to External Ext and External were used inconsistently in the code and the docs. This change converts all uses of Ext to External, including within variable names used by the generator. --- Help/cpack_gen/external.rst | 18 +- Modules/Internal/CPack/CPackExt.cmake | 53 ---- Modules/Internal/CPack/CPackExternal.cmake | 53 ++++ Source/CMakeLists.txt | 2 +- Source/CPack/cmCPackExtGenerator.cxx | 321 -------------------- Source/CPack/cmCPackExtGenerator.h | 88 ------ Source/CPack/cmCPackExternalGenerator.cxx | 322 +++++++++++++++++++++ Source/CPack/cmCPackExternalGenerator.h | 89 ++++++ Source/CPack/cmCPackGeneratorFactory.cxx | 8 +- Tests/RunCMake/CMakeLists.txt | 2 +- Tests/RunCMake/CPack/Ext/Helpers.cmake | 31 -- Tests/RunCMake/CPack/Ext/Prerequirements.cmake | 0 Tests/RunCMake/CPack/External/Helpers.cmake | 31 ++ .../RunCMake/CPack/External/Prerequirements.cmake | 0 Tests/RunCMake/CPack/RunCMakeTest.cmake | 6 +- Tests/RunCMake/CPack/tests/EXT/ExpectedFiles.cmake | 7 - Tests/RunCMake/CPack/tests/EXT/VerifyResult.cmake | 3 - .../RunCMake/CPack/tests/EXT/bad_major-stderr.txt | 6 - .../RunCMake/CPack/tests/EXT/bad_minor-stderr.txt | 6 - .../RunCMake/CPack/tests/EXT/create_package.cmake | 24 -- .../RunCMake/CPack/tests/EXT/expected-json-1.0.txt | 176 ----------- .../CPack/tests/EXT/invalid_bad-stderr.txt | 6 - .../CPack/tests/EXT/stage_and_package-stderr.txt | 1 - Tests/RunCMake/CPack/tests/EXT/test.cmake | 86 ------ .../CPack/tests/EXTERNAL/ExpectedFiles.cmake | 7 + .../CPack/tests/EXTERNAL/VerifyResult.cmake | 3 + .../CPack/tests/EXTERNAL/bad_major-stderr.txt | 6 + .../CPack/tests/EXTERNAL/bad_minor-stderr.txt | 6 + .../CPack/tests/EXTERNAL/create_package.cmake | 24 ++ .../CPack/tests/EXTERNAL/expected-json-1.0.txt | 176 +++++++++++ .../CPack/tests/EXTERNAL/invalid_bad-stderr.txt | 6 + .../tests/EXTERNAL/stage_and_package-stderr.txt | 1 + Tests/RunCMake/CPack/tests/EXTERNAL/test.cmake | 86 ++++++ 33 files changed, 828 insertions(+), 826 deletions(-) delete mode 100644 Modules/Internal/CPack/CPackExt.cmake create mode 100644 Modules/Internal/CPack/CPackExternal.cmake delete mode 100644 Source/CPack/cmCPackExtGenerator.cxx delete mode 100644 Source/CPack/cmCPackExtGenerator.h create mode 100644 Source/CPack/cmCPackExternalGenerator.cxx create mode 100644 Source/CPack/cmCPackExternalGenerator.h delete mode 100644 Tests/RunCMake/CPack/Ext/Helpers.cmake delete mode 100644 Tests/RunCMake/CPack/Ext/Prerequirements.cmake create mode 100644 Tests/RunCMake/CPack/External/Helpers.cmake create mode 100644 Tests/RunCMake/CPack/External/Prerequirements.cmake delete mode 100644 Tests/RunCMake/CPack/tests/EXT/ExpectedFiles.cmake delete mode 100644 Tests/RunCMake/CPack/tests/EXT/VerifyResult.cmake delete mode 100644 Tests/RunCMake/CPack/tests/EXT/bad_major-stderr.txt delete mode 100644 Tests/RunCMake/CPack/tests/EXT/bad_minor-stderr.txt delete mode 100644 Tests/RunCMake/CPack/tests/EXT/create_package.cmake delete mode 100644 Tests/RunCMake/CPack/tests/EXT/expected-json-1.0.txt delete mode 100644 Tests/RunCMake/CPack/tests/EXT/invalid_bad-stderr.txt delete mode 100644 Tests/RunCMake/CPack/tests/EXT/stage_and_package-stderr.txt delete mode 100644 Tests/RunCMake/CPack/tests/EXT/test.cmake create mode 100644 Tests/RunCMake/CPack/tests/EXTERNAL/ExpectedFiles.cmake create mode 100644 Tests/RunCMake/CPack/tests/EXTERNAL/VerifyResult.cmake create mode 100644 Tests/RunCMake/CPack/tests/EXTERNAL/bad_major-stderr.txt create mode 100644 Tests/RunCMake/CPack/tests/EXTERNAL/bad_minor-stderr.txt create mode 100644 Tests/RunCMake/CPack/tests/EXTERNAL/create_package.cmake create mode 100644 Tests/RunCMake/CPack/tests/EXTERNAL/expected-json-1.0.txt create mode 100644 Tests/RunCMake/CPack/tests/EXTERNAL/invalid_bad-stderr.txt create mode 100644 Tests/RunCMake/CPack/tests/EXTERNAL/stage_and_package-stderr.txt create mode 100644 Tests/RunCMake/CPack/tests/EXTERNAL/test.cmake diff --git a/Help/cpack_gen/external.rst b/Help/cpack_gen/external.rst index f98e1c9..e4912a4 100644 --- a/Help/cpack_gen/external.rst +++ b/Help/cpack_gen/external.rst @@ -21,11 +21,11 @@ install and package files as required. Alternatively CPack can invoke an external packaging software through an optional custom CMake script in -:variable:`CPACK_EXT_PACKAGE_SCRIPT` instead. +:variable:`CPACK_EXTERNAL_PACKAGE_SCRIPT` instead. Staging of installation files may also optionally be taken care of by the generator when enabled through the -:variable:`CPACK_EXT_ENABLE_STAGING` variable. +:variable:`CPACK_EXTERNAL_ENABLE_STAGING` variable. JSON Format ^^^^^^^^^^^ @@ -46,10 +46,10 @@ always of the format ``major.minor``. In other words, it always has exactly two parts, separated by a period. You can request one or more specific versions of the output format as described -below with :variable:`CPACK_EXT_REQUESTED_VERSIONS`. The output format will +below with :variable:`CPACK_EXTERNAL_REQUESTED_VERSIONS`. The output format will have a major version that exactly matches the requested major version, and a minor version that is greater than or equal to the requested minor version. If -no version is requested with :variable:`CPACK_EXT_REQUESTED_VERSIONS`, the +no version is requested with :variable:`CPACK_EXTERNAL_REQUESTED_VERSIONS`, the latest known major version is used by default. Currently, the only supported format is 1.0, which is described below. @@ -234,7 +234,7 @@ following fields in the root: Variables specific to CPack External generator ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. variable:: CPACK_EXT_REQUESTED_VERSIONS +.. variable:: CPACK_EXTERNAL_REQUESTED_VERSIONS This variable is used to request a specific version of the CPack External generator. It is a list of ``major.minor`` values, separated by semicolons. @@ -248,7 +248,7 @@ Variables specific to CPack External generator The generator knows how to generate the version if it has a versioned generator whose major version exactly matches the requested major version, and whose minor version is greater than or equal to the requested minor - version. For example, if ``CPACK_EXT_REQUESTED_VERSIONS`` contains 1.0, and + version. For example, if ``CPACK_EXTERNAL_REQUESTED_VERSIONS`` contains 1.0, and the CPack External generator knows how to generate 1.1, it will generate 1.1. If the generator doesn't know how to generate a version in the list, it skips the version and looks at the next one. If it doesn't know how to generate any @@ -257,11 +257,11 @@ Variables specific to CPack External generator If this variable is not set, or is empty, the CPack External generator will generate the highest major and minor version that it knows how to generate. - If an invalid version is encountered in ``CPACK_EXT_REQUESTED_VERSIONS`` (one + If an invalid version is encountered in ``CPACK_EXTERNAL_REQUESTED_VERSIONS`` (one that doesn't match ``major.minor``, where ``major`` and ``minor`` are integers), it is ignored. -.. variable:: CPACK_EXT_ENABLE_STAGING +.. variable:: CPACK_EXTERNAL_ENABLE_STAGING This variable can be set to true to enable optional installation into a temporary staging area which can then be picked up @@ -274,7 +274,7 @@ Variables specific to CPack External generator It also contains the staging area ``CPACK_TEMPORARY_DIRECTORY`` into which CPack performs the installation when staging is enabled. -.. variable:: CPACK_EXT_PACKAGE_SCRIPT +.. variable:: CPACK_EXTERNAL_PACKAGE_SCRIPT This variable can optionally specify the full path to a CMake script file to be run as part of the CPack invocation. diff --git a/Modules/Internal/CPack/CPackExt.cmake b/Modules/Internal/CPack/CPackExt.cmake deleted file mode 100644 index e52d978..0000000 --- a/Modules/Internal/CPack/CPackExt.cmake +++ /dev/null @@ -1,53 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -if(NOT "${CPACK_EXT_REQUESTED_VERSIONS}" STREQUAL "") - unset(_found_major) - - foreach(_req_version IN LISTS CPACK_EXT_REQUESTED_VERSIONS) - if(_req_version MATCHES "^([0-9]+)\\.([0-9]+)$") - set(_req_major "${CMAKE_MATCH_1}") - set(_req_minor "${CMAKE_MATCH_2}") - - foreach(_known_version IN LISTS CPACK_EXT_KNOWN_VERSIONS) - string(REGEX MATCH - "^([0-9]+)\\.([0-9]+)$" - _known_version_dummy - "${_known_version}" - ) - - set(_known_major "${CMAKE_MATCH_1}") - set(_known_minor "${CMAKE_MATCH_2}") - - if(_req_major EQUAL _known_major AND NOT _known_minor LESS _req_minor) - set(_found_major "${_known_major}") - set(_found_minor "${_known_minor}") - break() - endif() - endforeach() - - if(DEFINED _found_major) - break() - endif() - endif() - endforeach() - - if(DEFINED _found_major) - set(CPACK_EXT_SELECTED_MAJOR "${_found_major}") - set(CPACK_EXT_SELECTED_MINOR "${_found_minor}") - set(CPACK_EXT_SELECTED_VERSION "${_found_major}.${_found_minor}") - else() - message(FATAL_ERROR - "Could not find a suitable version in CPACK_EXT_REQUESTED_VERSIONS" - ) - endif() -else() - list(GET CPACK_EXT_KNOWN_VERSIONS 0 CPACK_EXT_SELECTED_VERSION) - string(REGEX MATCH - "^([0-9]+)\\.([0-9]+)$" - _dummy - "${CPACK_EXT_SELECTED_VERSION}" - ) - set(CPACK_EXT_SELECTED_MAJOR "${CMAKE_MATCH_1}") - set(CPACK_EXT_SELECTED_MINOR "${CMAKE_MATCH_2}") -endif() diff --git a/Modules/Internal/CPack/CPackExternal.cmake b/Modules/Internal/CPack/CPackExternal.cmake new file mode 100644 index 0000000..e4d055a --- /dev/null +++ b/Modules/Internal/CPack/CPackExternal.cmake @@ -0,0 +1,53 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +if(NOT "${CPACK_EXTERNAL_REQUESTED_VERSIONS}" STREQUAL "") + unset(_found_major) + + foreach(_req_version IN LISTS CPACK_EXTERNAL_REQUESTED_VERSIONS) + if(_req_version MATCHES "^([0-9]+)\\.([0-9]+)$") + set(_req_major "${CMAKE_MATCH_1}") + set(_req_minor "${CMAKE_MATCH_2}") + + foreach(_known_version IN LISTS CPACK_EXTERNAL_KNOWN_VERSIONS) + string(REGEX MATCH + "^([0-9]+)\\.([0-9]+)$" + _known_version_dummy + "${_known_version}" + ) + + set(_known_major "${CMAKE_MATCH_1}") + set(_known_minor "${CMAKE_MATCH_2}") + + if(_req_major EQUAL _known_major AND NOT _known_minor LESS _req_minor) + set(_found_major "${_known_major}") + set(_found_minor "${_known_minor}") + break() + endif() + endforeach() + + if(DEFINED _found_major) + break() + endif() + endif() + endforeach() + + if(DEFINED _found_major) + set(CPACK_EXTERNAL_SELECTED_MAJOR "${_found_major}") + set(CPACK_EXTERNAL_SELECTED_MINOR "${_found_minor}") + set(CPACK_EXTERNAL_SELECTED_VERSION "${_found_major}.${_found_minor}") + else() + message(FATAL_ERROR + "Could not find a suitable version in CPACK_EXTERNAL_REQUESTED_VERSIONS" + ) + endif() +else() + list(GET CPACK_EXTERNAL_KNOWN_VERSIONS 0 CPACK_EXTERNAL_SELECTED_VERSION) + string(REGEX MATCH + "^([0-9]+)\\.([0-9]+)$" + _dummy + "${CPACK_EXTERNAL_SELECTED_VERSION}" + ) + set(CPACK_EXTERNAL_SELECTED_MAJOR "${CMAKE_MATCH_1}") + set(CPACK_EXTERNAL_SELECTED_MINOR "${CMAKE_MATCH_2}") +endif() diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 3cf6c8f..311f3f4 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -890,7 +890,7 @@ set(CPACK_SRCS CPack/cmCPackArchiveGenerator.cxx CPack/cmCPackComponentGroup.cxx CPack/cmCPackDebGenerator.cxx - CPack/cmCPackExtGenerator.cxx + CPack/cmCPackExternalGenerator.cxx CPack/cmCPackGeneratorFactory.cxx CPack/cmCPackGenerator.cxx CPack/cmCPackLog.cxx diff --git a/Source/CPack/cmCPackExtGenerator.cxx b/Source/CPack/cmCPackExtGenerator.cxx deleted file mode 100644 index 4c560b9..0000000 --- a/Source/CPack/cmCPackExtGenerator.cxx +++ /dev/null @@ -1,321 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmCPackExtGenerator.h" - -#include "cmAlgorithms.h" -#include "cmCPackComponentGroup.h" -#include "cmCPackLog.h" -#include "cmMakefile.h" -#include "cmSystemTools.h" - -#include "cm_jsoncpp_value.h" -#include "cm_jsoncpp_writer.h" - -#include "cmsys/FStream.hxx" - -#include -#include - -int cmCPackExtGenerator::InitializeInternal() -{ - this->SetOption("CPACK_EXT_KNOWN_VERSIONS", "1.0"); - - if (!this->ReadListFile("Internal/CPack/CPackExt.cmake")) { - cmCPackLogger(cmCPackLog::LOG_ERROR, - "Error while executing CPackExt.cmake" << std::endl); - return 0; - } - - std::string major = this->GetOption("CPACK_EXT_SELECTED_MAJOR"); - if (major == "1") { - this->Generator = cm::make_unique(this); - } - - return this->Superclass::InitializeInternal(); -} - -int cmCPackExtGenerator::PackageFiles() -{ - Json::StreamWriterBuilder builder; - builder["indentation"] = " "; - - std::string filename = "package.json"; - if (!this->packageFileNames.empty()) { - filename = this->packageFileNames[0]; - } - - cmsys::ofstream fout(filename.c_str()); - std::unique_ptr jout(builder.newStreamWriter()); - - Json::Value root(Json::objectValue); - - if (!this->Generator->WriteToJSON(root)) { - return 0; - } - - if (jout->write(root, &fout)) { - return 0; - } - - const char* packageScript = this->GetOption("CPACK_EXT_PACKAGE_SCRIPT"); - if (packageScript && *packageScript) { - if (!cmSystemTools::FileIsFullPath(packageScript)) { - cmCPackLogger( - cmCPackLog::LOG_ERROR, - "CPACK_EXT_PACKAGE_SCRIPT does not contain a full file path" - << std::endl); - return 0; - } - - int res = this->MakefileMap->ReadListFile(packageScript); - - if (cmSystemTools::GetErrorOccuredFlag() || !res) { - return 0; - } - } - - return 1; -} - -bool cmCPackExtGenerator::SupportsComponentInstallation() const -{ - return true; -} - -int cmCPackExtGenerator::InstallProjectViaInstallCommands( - bool setDestDir, const std::string& tempInstallDirectory) -{ - if (this->StagingEnabled()) { - return cmCPackGenerator::InstallProjectViaInstallCommands( - setDestDir, tempInstallDirectory); - } - - return 1; -} - -int cmCPackExtGenerator::InstallProjectViaInstallScript( - bool setDestDir, const std::string& tempInstallDirectory) -{ - if (this->StagingEnabled()) { - return cmCPackGenerator::InstallProjectViaInstallScript( - setDestDir, tempInstallDirectory); - } - - return 1; -} - -int cmCPackExtGenerator::InstallProjectViaInstalledDirectories( - bool setDestDir, const std::string& tempInstallDirectory, - const mode_t* default_dir_mode) -{ - if (this->StagingEnabled()) { - return cmCPackGenerator::InstallProjectViaInstalledDirectories( - setDestDir, tempInstallDirectory, default_dir_mode); - } - - return 1; -} - -int cmCPackExtGenerator::RunPreinstallTarget( - const std::string& installProjectName, const std::string& installDirectory, - cmGlobalGenerator* globalGenerator, const std::string& buildConfig) -{ - if (this->StagingEnabled()) { - return cmCPackGenerator::RunPreinstallTarget( - installProjectName, installDirectory, globalGenerator, buildConfig); - } - - return 1; -} - -int cmCPackExtGenerator::InstallCMakeProject( - bool setDestDir, const std::string& installDirectory, - const std::string& baseTempInstallDirectory, const mode_t* default_dir_mode, - const std::string& component, bool componentInstall, - const std::string& installSubDirectory, const std::string& buildConfig, - std::string& absoluteDestFiles) -{ - if (this->StagingEnabled()) { - return cmCPackGenerator::InstallCMakeProject( - setDestDir, installDirectory, baseTempInstallDirectory, default_dir_mode, - component, componentInstall, installSubDirectory, buildConfig, - absoluteDestFiles); - } - - return 1; -} - -bool cmCPackExtGenerator::StagingEnabled() const -{ - return !cmSystemTools::IsOff(this->GetOption("CPACK_EXT_ENABLE_STAGING")); -} - -cmCPackExtGenerator::cmCPackExtVersionGenerator::cmCPackExtVersionGenerator( - cmCPackExtGenerator* parent) - : Parent(parent) -{ -} - -int cmCPackExtGenerator::cmCPackExtVersionGenerator::WriteVersion( - Json::Value& root) -{ - root["formatVersionMajor"] = this->GetVersionMajor(); - root["formatVersionMinor"] = this->GetVersionMinor(); - - return 1; -} - -int cmCPackExtGenerator::cmCPackExtVersionGenerator::WriteToJSON( - Json::Value& root) -{ - if (!this->WriteVersion(root)) { - return 0; - } - - const char* packageName = this->Parent->GetOption("CPACK_PACKAGE_NAME"); - if (packageName) { - root["packageName"] = packageName; - } - - const char* packageVersion = - this->Parent->GetOption("CPACK_PACKAGE_VERSION"); - if (packageVersion) { - root["packageVersion"] = packageVersion; - } - - const char* packageDescriptionFile = - this->Parent->GetOption("CPACK_PACKAGE_DESCRIPTION_FILE"); - if (packageDescriptionFile) { - root["packageDescriptionFile"] = packageDescriptionFile; - } - - const char* packageDescriptionSummary = - this->Parent->GetOption("CPACK_PACKAGE_DESCRIPTION_SUMMARY"); - if (packageDescriptionSummary) { - root["packageDescriptionSummary"] = packageDescriptionSummary; - } - - const char* buildConfigCstr = this->Parent->GetOption("CPACK_BUILD_CONFIG"); - if (buildConfigCstr) { - root["buildConfig"] = buildConfigCstr; - } - - const char* defaultDirectoryPermissions = - this->Parent->GetOption("CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS"); - if (defaultDirectoryPermissions && *defaultDirectoryPermissions) { - root["defaultDirectoryPermissions"] = defaultDirectoryPermissions; - } - if (cmSystemTools::IsInternallyOn( - this->Parent->GetOption("CPACK_SET_DESTDIR"))) { - root["setDestdir"] = true; - root["packagingInstallPrefix"] = - this->Parent->GetOption("CPACK_PACKAGING_INSTALL_PREFIX"); - } else { - root["setDestdir"] = false; - } - - root["stripFiles"] = - !cmSystemTools::IsOff(this->Parent->GetOption("CPACK_STRIP_FILES")); - root["warnOnAbsoluteInstallDestination"] = - this->Parent->IsOn("CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION"); - root["errorOnAbsoluteInstallDestination"] = - this->Parent->IsOn("CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION"); - - Json::Value& projects = root["projects"] = Json::Value(Json::arrayValue); - for (auto& project : this->Parent->CMakeProjects) { - Json::Value jsonProject(Json::objectValue); - - jsonProject["projectName"] = project.ProjectName; - jsonProject["component"] = project.Component; - jsonProject["directory"] = project.Directory; - jsonProject["subDirectory"] = project.SubDirectory; - - Json::Value& installationTypes = jsonProject["installationTypes"] = - Json::Value(Json::arrayValue); - for (auto& installationType : project.InstallationTypes) { - installationTypes.append(installationType->Name); - } - - Json::Value& components = jsonProject["components"] = - Json::Value(Json::arrayValue); - for (auto& component : project.Components) { - components.append(component->Name); - } - - projects.append(jsonProject); - } - - Json::Value& installationTypes = root["installationTypes"] = - Json::Value(Json::objectValue); - for (auto& installationType : this->Parent->InstallationTypes) { - Json::Value& jsonInstallationType = - installationTypes[installationType.first] = - Json::Value(Json::objectValue); - - jsonInstallationType["name"] = installationType.second.Name; - jsonInstallationType["displayName"] = installationType.second.DisplayName; - jsonInstallationType["index"] = installationType.second.Index; - } - - Json::Value& components = root["components"] = - Json::Value(Json::objectValue); - for (auto& component : this->Parent->Components) { - Json::Value& jsonComponent = components[component.first] = - Json::Value(Json::objectValue); - - jsonComponent["name"] = component.second.Name; - jsonComponent["displayName"] = component.second.DisplayName; - if (component.second.Group) { - jsonComponent["group"] = component.second.Group->Name; - } - jsonComponent["isRequired"] = component.second.IsRequired; - jsonComponent["isHidden"] = component.second.IsHidden; - jsonComponent["isDisabledByDefault"] = - component.second.IsDisabledByDefault; - jsonComponent["isDownloaded"] = component.second.IsDownloaded; - jsonComponent["description"] = component.second.Description; - jsonComponent["archiveFile"] = component.second.ArchiveFile; - - Json::Value& cmpInstallationTypes = jsonComponent["installationTypes"] = - Json::Value(Json::arrayValue); - for (auto& installationType : component.second.InstallationTypes) { - cmpInstallationTypes.append(installationType->Name); - } - - Json::Value& dependencies = jsonComponent["dependencies"] = - Json::Value(Json::arrayValue); - for (auto& dep : component.second.Dependencies) { - dependencies.append(dep->Name); - } - } - - Json::Value& groups = root["componentGroups"] = - Json::Value(Json::objectValue); - for (auto& group : this->Parent->ComponentGroups) { - Json::Value& jsonGroup = groups[group.first] = - Json::Value(Json::objectValue); - - jsonGroup["name"] = group.second.Name; - jsonGroup["displayName"] = group.second.DisplayName; - jsonGroup["description"] = group.second.Description; - jsonGroup["isBold"] = group.second.IsBold; - jsonGroup["isExpandedByDefault"] = group.second.IsExpandedByDefault; - if (group.second.ParentGroup) { - jsonGroup["parentGroup"] = group.second.ParentGroup->Name; - } - - Json::Value& subgroups = jsonGroup["subgroups"] = - Json::Value(Json::arrayValue); - for (auto& subgroup : group.second.Subgroups) { - subgroups.append(subgroup->Name); - } - - Json::Value& groupComponents = jsonGroup["components"] = - Json::Value(Json::arrayValue); - for (auto& component : group.second.Components) { - groupComponents.append(component->Name); - } - } - - return 1; -} diff --git a/Source/CPack/cmCPackExtGenerator.h b/Source/CPack/cmCPackExtGenerator.h deleted file mode 100644 index 103e56d..0000000 --- a/Source/CPack/cmCPackExtGenerator.h +++ /dev/null @@ -1,88 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef cmCPackExtGenerator_h -#define cmCPackExtGenerator_h - -#include "cmCPackGenerator.h" -#include "cm_sys_stat.h" - -#include -#include - -class cmGlobalGenerator; -namespace Json { -class Value; -} - -/** \class cmCPackExtGenerator - * \brief A generator for CPack External packaging tools - */ -class cmCPackExtGenerator : public cmCPackGenerator -{ -public: - cmCPackTypeMacro(cmCPackExtGenerator, cmCPackGenerator); - - const char* GetOutputExtension() override { return ".json"; } - -protected: - int InitializeInternal() override; - - int PackageFiles() override; - - bool SupportsComponentInstallation() const override; - - int InstallProjectViaInstallCommands( - bool setDestDir, const std::string& tempInstallDirectory) override; - int InstallProjectViaInstallScript( - bool setDestDir, const std::string& tempInstallDirectory) override; - int InstallProjectViaInstalledDirectories( - bool setDestDir, const std::string& tempInstallDirectory, - const mode_t* default_dir_mode) override; - - int RunPreinstallTarget(const std::string& installProjectName, - const std::string& installDirectory, - cmGlobalGenerator* globalGenerator, - const std::string& buildConfig) override; - int InstallCMakeProject(bool setDestDir, const std::string& installDirectory, - const std::string& baseTempInstallDirectory, - const mode_t* default_dir_mode, - const std::string& component, bool componentInstall, - const std::string& installSubDirectory, - const std::string& buildConfig, - std::string& absoluteDestFiles) override; - -private: - bool StagingEnabled() const; - - class cmCPackExtVersionGenerator - { - public: - cmCPackExtVersionGenerator(cmCPackExtGenerator* parent); - - virtual ~cmCPackExtVersionGenerator() = default; - - virtual int WriteToJSON(Json::Value& root); - - protected: - virtual int GetVersionMajor() = 0; - virtual int GetVersionMinor() = 0; - - int WriteVersion(Json::Value& root); - - cmCPackExtGenerator* Parent; - }; - - class cmCPackExtVersion1Generator : public cmCPackExtVersionGenerator - { - public: - using cmCPackExtVersionGenerator::cmCPackExtVersionGenerator; - - protected: - int GetVersionMajor() override { return 1; } - int GetVersionMinor() override { return 0; } - }; - - std::unique_ptr Generator; -}; - -#endif diff --git a/Source/CPack/cmCPackExternalGenerator.cxx b/Source/CPack/cmCPackExternalGenerator.cxx new file mode 100644 index 0000000..9f7b236 --- /dev/null +++ b/Source/CPack/cmCPackExternalGenerator.cxx @@ -0,0 +1,322 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "cmCPackExternalGenerator.h" + +#include "cmAlgorithms.h" +#include "cmCPackComponentGroup.h" +#include "cmCPackLog.h" +#include "cmMakefile.h" +#include "cmSystemTools.h" + +#include "cm_jsoncpp_value.h" +#include "cm_jsoncpp_writer.h" + +#include "cmsys/FStream.hxx" + +#include +#include + +int cmCPackExternalGenerator::InitializeInternal() +{ + this->SetOption("CPACK_EXTERNAL_KNOWN_VERSIONS", "1.0"); + + if (!this->ReadListFile("Internal/CPack/CPackExternal.cmake")) { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error while executing CPackExternal.cmake" << std::endl); + return 0; + } + + std::string major = this->GetOption("CPACK_EXTERNAL_SELECTED_MAJOR"); + if (major == "1") { + this->Generator = cm::make_unique(this); + } + + return this->Superclass::InitializeInternal(); +} + +int cmCPackExternalGenerator::PackageFiles() +{ + Json::StreamWriterBuilder builder; + builder["indentation"] = " "; + + std::string filename = "package.json"; + if (!this->packageFileNames.empty()) { + filename = this->packageFileNames[0]; + } + + cmsys::ofstream fout(filename.c_str()); + std::unique_ptr jout(builder.newStreamWriter()); + + Json::Value root(Json::objectValue); + + if (!this->Generator->WriteToJSON(root)) { + return 0; + } + + if (jout->write(root, &fout)) { + return 0; + } + + const char* packageScript = this->GetOption("CPACK_EXTERNAL_PACKAGE_SCRIPT"); + if (packageScript && *packageScript) { + if (!cmSystemTools::FileIsFullPath(packageScript)) { + cmCPackLogger( + cmCPackLog::LOG_ERROR, + "CPACK_EXTERNAL_PACKAGE_SCRIPT does not contain a full file path" + << std::endl); + return 0; + } + + int res = this->MakefileMap->ReadListFile(packageScript); + + if (cmSystemTools::GetErrorOccuredFlag() || !res) { + return 0; + } + } + + return 1; +} + +bool cmCPackExternalGenerator::SupportsComponentInstallation() const +{ + return true; +} + +int cmCPackExternalGenerator::InstallProjectViaInstallCommands( + bool setDestDir, const std::string& tempInstallDirectory) +{ + if (this->StagingEnabled()) { + return cmCPackGenerator::InstallProjectViaInstallCommands( + setDestDir, tempInstallDirectory); + } + + return 1; +} + +int cmCPackExternalGenerator::InstallProjectViaInstallScript( + bool setDestDir, const std::string& tempInstallDirectory) +{ + if (this->StagingEnabled()) { + return cmCPackGenerator::InstallProjectViaInstallScript( + setDestDir, tempInstallDirectory); + } + + return 1; +} + +int cmCPackExternalGenerator::InstallProjectViaInstalledDirectories( + bool setDestDir, const std::string& tempInstallDirectory, + const mode_t* default_dir_mode) +{ + if (this->StagingEnabled()) { + return cmCPackGenerator::InstallProjectViaInstalledDirectories( + setDestDir, tempInstallDirectory, default_dir_mode); + } + + return 1; +} + +int cmCPackExternalGenerator::RunPreinstallTarget( + const std::string& installProjectName, const std::string& installDirectory, + cmGlobalGenerator* globalGenerator, const std::string& buildConfig) +{ + if (this->StagingEnabled()) { + return cmCPackGenerator::RunPreinstallTarget( + installProjectName, installDirectory, globalGenerator, buildConfig); + } + + return 1; +} + +int cmCPackExternalGenerator::InstallCMakeProject( + bool setDestDir, const std::string& installDirectory, + const std::string& baseTempInstallDirectory, const mode_t* default_dir_mode, + const std::string& component, bool componentInstall, + const std::string& installSubDirectory, const std::string& buildConfig, + std::string& absoluteDestFiles) +{ + if (this->StagingEnabled()) { + return cmCPackGenerator::InstallCMakeProject( + setDestDir, installDirectory, baseTempInstallDirectory, default_dir_mode, + component, componentInstall, installSubDirectory, buildConfig, + absoluteDestFiles); + } + + return 1; +} + +bool cmCPackExternalGenerator::StagingEnabled() const +{ + return !cmSystemTools::IsOff( + this->GetOption("CPACK_EXTERNAL_ENABLE_STAGING")); +} + +cmCPackExternalGenerator::cmCPackExternalVersionGenerator:: + cmCPackExternalVersionGenerator(cmCPackExternalGenerator* parent) + : Parent(parent) +{ +} + +int cmCPackExternalGenerator::cmCPackExternalVersionGenerator::WriteVersion( + Json::Value& root) +{ + root["formatVersionMajor"] = this->GetVersionMajor(); + root["formatVersionMinor"] = this->GetVersionMinor(); + + return 1; +} + +int cmCPackExternalGenerator::cmCPackExternalVersionGenerator::WriteToJSON( + Json::Value& root) +{ + if (!this->WriteVersion(root)) { + return 0; + } + + const char* packageName = this->Parent->GetOption("CPACK_PACKAGE_NAME"); + if (packageName) { + root["packageName"] = packageName; + } + + const char* packageVersion = + this->Parent->GetOption("CPACK_PACKAGE_VERSION"); + if (packageVersion) { + root["packageVersion"] = packageVersion; + } + + const char* packageDescriptionFile = + this->Parent->GetOption("CPACK_PACKAGE_DESCRIPTION_FILE"); + if (packageDescriptionFile) { + root["packageDescriptionFile"] = packageDescriptionFile; + } + + const char* packageDescriptionSummary = + this->Parent->GetOption("CPACK_PACKAGE_DESCRIPTION_SUMMARY"); + if (packageDescriptionSummary) { + root["packageDescriptionSummary"] = packageDescriptionSummary; + } + + const char* buildConfigCstr = this->Parent->GetOption("CPACK_BUILD_CONFIG"); + if (buildConfigCstr) { + root["buildConfig"] = buildConfigCstr; + } + + const char* defaultDirectoryPermissions = + this->Parent->GetOption("CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS"); + if (defaultDirectoryPermissions && *defaultDirectoryPermissions) { + root["defaultDirectoryPermissions"] = defaultDirectoryPermissions; + } + if (cmSystemTools::IsInternallyOn( + this->Parent->GetOption("CPACK_SET_DESTDIR"))) { + root["setDestdir"] = true; + root["packagingInstallPrefix"] = + this->Parent->GetOption("CPACK_PACKAGING_INSTALL_PREFIX"); + } else { + root["setDestdir"] = false; + } + + root["stripFiles"] = + !cmSystemTools::IsOff(this->Parent->GetOption("CPACK_STRIP_FILES")); + root["warnOnAbsoluteInstallDestination"] = + this->Parent->IsOn("CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION"); + root["errorOnAbsoluteInstallDestination"] = + this->Parent->IsOn("CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION"); + + Json::Value& projects = root["projects"] = Json::Value(Json::arrayValue); + for (auto& project : this->Parent->CMakeProjects) { + Json::Value jsonProject(Json::objectValue); + + jsonProject["projectName"] = project.ProjectName; + jsonProject["component"] = project.Component; + jsonProject["directory"] = project.Directory; + jsonProject["subDirectory"] = project.SubDirectory; + + Json::Value& installationTypes = jsonProject["installationTypes"] = + Json::Value(Json::arrayValue); + for (auto& installationType : project.InstallationTypes) { + installationTypes.append(installationType->Name); + } + + Json::Value& components = jsonProject["components"] = + Json::Value(Json::arrayValue); + for (auto& component : project.Components) { + components.append(component->Name); + } + + projects.append(jsonProject); + } + + Json::Value& installationTypes = root["installationTypes"] = + Json::Value(Json::objectValue); + for (auto& installationType : this->Parent->InstallationTypes) { + Json::Value& jsonInstallationType = + installationTypes[installationType.first] = + Json::Value(Json::objectValue); + + jsonInstallationType["name"] = installationType.second.Name; + jsonInstallationType["displayName"] = installationType.second.DisplayName; + jsonInstallationType["index"] = installationType.second.Index; + } + + Json::Value& components = root["components"] = + Json::Value(Json::objectValue); + for (auto& component : this->Parent->Components) { + Json::Value& jsonComponent = components[component.first] = + Json::Value(Json::objectValue); + + jsonComponent["name"] = component.second.Name; + jsonComponent["displayName"] = component.second.DisplayName; + if (component.second.Group) { + jsonComponent["group"] = component.second.Group->Name; + } + jsonComponent["isRequired"] = component.second.IsRequired; + jsonComponent["isHidden"] = component.second.IsHidden; + jsonComponent["isDisabledByDefault"] = + component.second.IsDisabledByDefault; + jsonComponent["isDownloaded"] = component.second.IsDownloaded; + jsonComponent["description"] = component.second.Description; + jsonComponent["archiveFile"] = component.second.ArchiveFile; + + Json::Value& cmpInstallationTypes = jsonComponent["installationTypes"] = + Json::Value(Json::arrayValue); + for (auto& installationType : component.second.InstallationTypes) { + cmpInstallationTypes.append(installationType->Name); + } + + Json::Value& dependencies = jsonComponent["dependencies"] = + Json::Value(Json::arrayValue); + for (auto& dep : component.second.Dependencies) { + dependencies.append(dep->Name); + } + } + + Json::Value& groups = root["componentGroups"] = + Json::Value(Json::objectValue); + for (auto& group : this->Parent->ComponentGroups) { + Json::Value& jsonGroup = groups[group.first] = + Json::Value(Json::objectValue); + + jsonGroup["name"] = group.second.Name; + jsonGroup["displayName"] = group.second.DisplayName; + jsonGroup["description"] = group.second.Description; + jsonGroup["isBold"] = group.second.IsBold; + jsonGroup["isExpandedByDefault"] = group.second.IsExpandedByDefault; + if (group.second.ParentGroup) { + jsonGroup["parentGroup"] = group.second.ParentGroup->Name; + } + + Json::Value& subgroups = jsonGroup["subgroups"] = + Json::Value(Json::arrayValue); + for (auto& subgroup : group.second.Subgroups) { + subgroups.append(subgroup->Name); + } + + Json::Value& groupComponents = jsonGroup["components"] = + Json::Value(Json::arrayValue); + for (auto& component : group.second.Components) { + groupComponents.append(component->Name); + } + } + + return 1; +} diff --git a/Source/CPack/cmCPackExternalGenerator.h b/Source/CPack/cmCPackExternalGenerator.h new file mode 100644 index 0000000..176d6a9 --- /dev/null +++ b/Source/CPack/cmCPackExternalGenerator.h @@ -0,0 +1,89 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#ifndef cmCPackExternalGenerator_h +#define cmCPackExternalGenerator_h + +#include "cmCPackGenerator.h" +#include "cm_sys_stat.h" + +#include +#include + +class cmGlobalGenerator; +namespace Json { +class Value; +} + +/** \class cmCPackExternalGenerator + * \brief A generator for CPack External packaging tools + */ +class cmCPackExternalGenerator : public cmCPackGenerator +{ +public: + cmCPackTypeMacro(cmCPackExternalGenerator, cmCPackGenerator); + + const char* GetOutputExtension() override { return ".json"; } + +protected: + int InitializeInternal() override; + + int PackageFiles() override; + + bool SupportsComponentInstallation() const override; + + int InstallProjectViaInstallCommands( + bool setDestDir, const std::string& tempInstallDirectory) override; + int InstallProjectViaInstallScript( + bool setDestDir, const std::string& tempInstallDirectory) override; + int InstallProjectViaInstalledDirectories( + bool setDestDir, const std::string& tempInstallDirectory, + const mode_t* default_dir_mode) override; + + int RunPreinstallTarget(const std::string& installProjectName, + const std::string& installDirectory, + cmGlobalGenerator* globalGenerator, + const std::string& buildConfig) override; + int InstallCMakeProject(bool setDestDir, const std::string& installDirectory, + const std::string& baseTempInstallDirectory, + const mode_t* default_dir_mode, + const std::string& component, bool componentInstall, + const std::string& installSubDirectory, + const std::string& buildConfig, + std::string& absoluteDestFiles) override; + +private: + bool StagingEnabled() const; + + class cmCPackExternalVersionGenerator + { + public: + cmCPackExternalVersionGenerator(cmCPackExternalGenerator* parent); + + virtual ~cmCPackExternalVersionGenerator() = default; + + virtual int WriteToJSON(Json::Value& root); + + protected: + virtual int GetVersionMajor() = 0; + virtual int GetVersionMinor() = 0; + + int WriteVersion(Json::Value& root); + + cmCPackExternalGenerator* Parent; + }; + + class cmCPackExternalVersion1Generator + : public cmCPackExternalVersionGenerator + { + public: + using cmCPackExternalVersionGenerator::cmCPackExternalVersionGenerator; + + protected: + int GetVersionMajor() override { return 1; } + int GetVersionMinor() override { return 0; } + }; + + std::unique_ptr Generator; +}; + +#endif diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx index 8ef24f7..2c5ab4d 100644 --- a/Source/CPack/cmCPackGeneratorFactory.cxx +++ b/Source/CPack/cmCPackGeneratorFactory.cxx @@ -12,7 +12,7 @@ # include "cmCPackFreeBSDGenerator.h" #endif #include "cmCPackDebGenerator.h" -#include "cmCPackExtGenerator.h" +#include "cmCPackExternalGenerator.h" #include "cmCPackGenerator.h" #include "cmCPackLog.h" #include "cmCPackNSISGenerator.h" @@ -111,9 +111,9 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory() this->RegisterGenerator("NuGet", "NuGet packages", cmCPackNuGetGenerator::CreateGenerator); } - if (cmCPackExtGenerator::CanGenerate()) { - this->RegisterGenerator("Ext", "CPack External packages", - cmCPackExtGenerator::CreateGenerator); + if (cmCPackExternalGenerator::CanGenerate()) { + this->RegisterGenerator("External", "CPack External packages", + cmCPackExternalGenerator::CreateGenerator); } #ifdef __APPLE__ if (cmCPackDragNDropGenerator::CanGenerate()) { diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 90681b9..13ec746 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -433,7 +433,7 @@ if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") add_RunCMake_test(ctest_labels_for_subprojects) endif() -add_RunCMake_test_group(CPack "DEB;RPM;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ;Ext") +add_RunCMake_test_group(CPack "DEB;RPM;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ;External") # add a test to make sure symbols are exported from a shared library # for MSVC compilers CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS property is used add_RunCMake_test(AutoExportDll) diff --git a/Tests/RunCMake/CPack/Ext/Helpers.cmake b/Tests/RunCMake/CPack/Ext/Helpers.cmake deleted file mode 100644 index 2c67e06..0000000 --- a/Tests/RunCMake/CPack/Ext/Helpers.cmake +++ /dev/null @@ -1,31 +0,0 @@ -function(getPackageNameGlobexpr NAME COMPONENT VERSION REVISION FILE_NO RESULT_VAR) - set(${RESULT_VAR} "${NAME}-${VERSION}-*.json" PARENT_SCOPE) -endfunction() - -function(getPackageContentList FILE RESULT_VAR) - set("${RESULT_VAR}" "" PARENT_SCOPE) -endfunction() - -function(toExpectedContentList FILE_NO CONTENT_VAR) - set("${CONTENT_VAR}" "" PARENT_SCOPE) -endfunction() - -set(ALL_FILES_GLOB "*.json") - -function(check_ext_json EXPECTED_FILE ACTUAL_FILE) - file(READ "${EXPECTED_FILE}" _expected_regex) - file(READ "${ACTUAL_FILE}" _actual_contents) - - string(REGEX REPLACE "\n+$" "" _expected_regex "${_expected_regex}") - string(REGEX REPLACE "\n+$" "" _actual_contents "${_actual_contents}") - - if(NOT "${_actual_contents}" MATCHES "${_expected_regex}") - message(FATAL_ERROR - "Output JSON does not match expected regex.\n" - "Expected regex:\n" - "${_expected_regex}\n" - "Actual output:\n" - "${_actual_contents}\n" - ) - endif() -endfunction() diff --git a/Tests/RunCMake/CPack/Ext/Prerequirements.cmake b/Tests/RunCMake/CPack/Ext/Prerequirements.cmake deleted file mode 100644 index e69de29..0000000 diff --git a/Tests/RunCMake/CPack/External/Helpers.cmake b/Tests/RunCMake/CPack/External/Helpers.cmake new file mode 100644 index 0000000..2c67e06 --- /dev/null +++ b/Tests/RunCMake/CPack/External/Helpers.cmake @@ -0,0 +1,31 @@ +function(getPackageNameGlobexpr NAME COMPONENT VERSION REVISION FILE_NO RESULT_VAR) + set(${RESULT_VAR} "${NAME}-${VERSION}-*.json" PARENT_SCOPE) +endfunction() + +function(getPackageContentList FILE RESULT_VAR) + set("${RESULT_VAR}" "" PARENT_SCOPE) +endfunction() + +function(toExpectedContentList FILE_NO CONTENT_VAR) + set("${CONTENT_VAR}" "" PARENT_SCOPE) +endfunction() + +set(ALL_FILES_GLOB "*.json") + +function(check_ext_json EXPECTED_FILE ACTUAL_FILE) + file(READ "${EXPECTED_FILE}" _expected_regex) + file(READ "${ACTUAL_FILE}" _actual_contents) + + string(REGEX REPLACE "\n+$" "" _expected_regex "${_expected_regex}") + string(REGEX REPLACE "\n+$" "" _actual_contents "${_actual_contents}") + + if(NOT "${_actual_contents}" MATCHES "${_expected_regex}") + message(FATAL_ERROR + "Output JSON does not match expected regex.\n" + "Expected regex:\n" + "${_expected_regex}\n" + "Actual output:\n" + "${_actual_contents}\n" + ) + endif() +endfunction() diff --git a/Tests/RunCMake/CPack/External/Prerequirements.cmake b/Tests/RunCMake/CPack/External/Prerequirements.cmake new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index 91d3cb7..33ddb72 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -18,8 +18,8 @@ run_cpack_test(GENERATE_SHLIBS_LDCONFIG "DEB" true "COMPONENT") run_cpack_test(INSTALL_SCRIPTS "RPM" false "COMPONENT") run_cpack_test(LONG_FILENAMES "DEB" false "MONOLITHIC") run_cpack_test_subtests(MAIN_COMPONENT "invalid;found" "RPM" false "COMPONENT") -run_cpack_test(MINIMAL "RPM;DEB;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ;Ext" false "MONOLITHIC;COMPONENT") -run_cpack_test_package_target(MINIMAL "RPM;DEB;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ;Ext" false "MONOLITHIC;COMPONENT") +run_cpack_test(MINIMAL "RPM;DEB;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ;External" false "MONOLITHIC;COMPONENT") +run_cpack_test_package_target(MINIMAL "RPM;DEB;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ;External" false "MONOLITHIC;COMPONENT") run_cpack_test_subtests(PACKAGE_CHECKSUM "invalid;MD5;SHA1;SHA224;SHA256;SHA384;SHA512" "TGZ" false "MONOLITHIC") run_cpack_test(PARTIALLY_RELOCATABLE_WARNING "RPM" false "COMPONENT") run_cpack_test(PER_COMPONENT_FIELDS "RPM;DEB" false "COMPONENT") @@ -35,4 +35,4 @@ run_cpack_test(USER_FILELIST "RPM" false "MONOLITHIC") run_cpack_test(MD5SUMS "DEB" false "MONOLITHIC;COMPONENT") run_cpack_test(CPACK_INSTALL_SCRIPT "ZIP" false "MONOLITHIC") run_cpack_test(DEB_PACKAGE_VERSION_BACK_COMPATIBILITY "DEB" false "MONOLITHIC;COMPONENT") -run_cpack_test_subtests(EXT "none;good;good_multi;bad_major;bad_minor;invalid_good;invalid_bad;stage_and_package" "Ext" false "MONOLITHIC;COMPONENT") +run_cpack_test_subtests(EXTERNAL "none;good;good_multi;bad_major;bad_minor;invalid_good;invalid_bad;stage_and_package" "External" false "MONOLITHIC;COMPONENT") diff --git a/Tests/RunCMake/CPack/tests/EXT/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/EXT/ExpectedFiles.cmake deleted file mode 100644 index 91608c9..0000000 --- a/Tests/RunCMake/CPack/tests/EXT/ExpectedFiles.cmake +++ /dev/null @@ -1,7 +0,0 @@ -if(RunCMake_SUBTEST_SUFFIX MATCHES "^(none|good(_multi)?|invalid_good)$" - OR RunCMake_SUBTEST_SUFFIX STREQUAL "stage_and_package") - set(EXPECTED_FILES_COUNT "1") - set(EXPECTED_FILE_CONTENT_1_LIST "/share;/share/cpack-test;/share/cpack-test/f1.txt;/share/cpack-test/f2.txt;/share/cpack-test/f3.txt;/share/cpack-test/f4.txt") -else() - set(EXPECTED_FILES_COUNT "0") -endif() diff --git a/Tests/RunCMake/CPack/tests/EXT/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/EXT/VerifyResult.cmake deleted file mode 100644 index 97b74f7..0000000 --- a/Tests/RunCMake/CPack/tests/EXT/VerifyResult.cmake +++ /dev/null @@ -1,3 +0,0 @@ -if(RunCMake_SUBTEST_SUFFIX MATCHES "^(none|good(_multi)?|invalid_good)") - check_ext_json("${src_dir}/tests/EXT/expected-json-1.0.txt" "${FOUND_FILE_1}") -endif() diff --git a/Tests/RunCMake/CPack/tests/EXT/bad_major-stderr.txt b/Tests/RunCMake/CPack/tests/EXT/bad_major-stderr.txt deleted file mode 100644 index 372c5e4..0000000 --- a/Tests/RunCMake/CPack/tests/EXT/bad_major-stderr.txt +++ /dev/null @@ -1,6 +0,0 @@ -CMake Error at .*/Modules/Internal/CPack/CPackExt\.cmake:[0-9]+ \(message\): - Could not find a suitable version in CPACK_EXT_REQUESTED_VERSIONS - - -CPack Error: Error while executing CPackExt\.cmake -CPack Error: Cannot initialize the generator Ext diff --git a/Tests/RunCMake/CPack/tests/EXT/bad_minor-stderr.txt b/Tests/RunCMake/CPack/tests/EXT/bad_minor-stderr.txt deleted file mode 100644 index 372c5e4..0000000 --- a/Tests/RunCMake/CPack/tests/EXT/bad_minor-stderr.txt +++ /dev/null @@ -1,6 +0,0 @@ -CMake Error at .*/Modules/Internal/CPack/CPackExt\.cmake:[0-9]+ \(message\): - Could not find a suitable version in CPACK_EXT_REQUESTED_VERSIONS - - -CPack Error: Error while executing CPackExt\.cmake -CPack Error: Cannot initialize the generator Ext diff --git a/Tests/RunCMake/CPack/tests/EXT/create_package.cmake b/Tests/RunCMake/CPack/tests/EXT/create_package.cmake deleted file mode 100644 index e308ccb..0000000 --- a/Tests/RunCMake/CPack/tests/EXT/create_package.cmake +++ /dev/null @@ -1,24 +0,0 @@ -message("This script could run an external packaging tool") - -function(expect_variable VAR) - if(NOT ${VAR}) - message(FATAL_ERROR "${VAR} is unexpectedly not set") - endif() -endfunction() - -function(expect_file FILE) - if(NOT EXISTS "${FILE}") - message(FATAL_ERROR "${FILE} is unexpectedly missing") - endif() -endfunction() - -expect_variable(CPACK_COMPONENTS_ALL) -expect_variable(CPACK_TOPLEVEL_DIRECTORY) -expect_variable(CPACK_TEMPORARY_DIRECTORY) -expect_variable(CPACK_PACKAGE_DIRECTORY) -expect_variable(CPACK_PACKAGE_FILE_NAME) - -expect_file(${CPACK_TEMPORARY_DIRECTORY}/f1/share/cpack-test/f1.txt) -expect_file(${CPACK_TEMPORARY_DIRECTORY}/f2/share/cpack-test/f2.txt) -expect_file(${CPACK_TEMPORARY_DIRECTORY}/f3/share/cpack-test/f3.txt) -expect_file(${CPACK_TEMPORARY_DIRECTORY}/f4/share/cpack-test/f4.txt) diff --git a/Tests/RunCMake/CPack/tests/EXT/expected-json-1.0.txt b/Tests/RunCMake/CPack/tests/EXT/expected-json-1.0.txt deleted file mode 100644 index b96cf0b..0000000 --- a/Tests/RunCMake/CPack/tests/EXT/expected-json-1.0.txt +++ /dev/null @@ -1,176 +0,0 @@ -^\{ - "componentGroups" :[ ] - \{ - "f12" :[ ] - \{ - "components" :[ ] - \[ - "f1", - "f2" - \], - "description" : "Component group for files 1 and 2", - "displayName" : "Files 1 and 2", - "isBold" : false, - "isExpandedByDefault" : false, - "name" : "f12", - "parentGroup" : "f1234", - "subgroups" : \[\] - \}, - "f1234" :[ ] - \{ - "components" : \[\], - "description" : "Component group for all files", - "displayName" : "Files 1-4", - "isBold" : false, - "isExpandedByDefault" : false, - "name" : "f1234", - "subgroups" :[ ] - \[ - "f12", - "f34" - \] - \}, - "f34" :[ ] - \{ - "components" :[ ] - \[ - "f3", - "f4" - \], - "description" : "Component group for files 3 and 4", - "displayName" : "Files 3 and 4", - "isBold" : false, - "isExpandedByDefault" : false, - "name" : "f34", - "parentGroup" : "f1234", - "subgroups" : \[\] - \} - \}, - "components" :[ ] - \{ - "f1" :[ ] - \{ - "archiveFile" : "", - "dependencies" : \[\], - "description" : "Component for file 1", - "displayName" : "File 1", - "group" : "f12", - "installationTypes" :[ ] - \[ - "full", - "f12" - \], - "isDisabledByDefault" : false, - "isDownloaded" : false, - "isHidden" : false, - "isRequired" : false, - "name" : "f1" - \}, - "f2" :[ ] - \{ - "archiveFile" : "", - "dependencies" :[ ] - \[ - "f1" - \], - "description" : "Component for file 2", - "displayName" : "File 2", - "group" : "f12", - "installationTypes" :[ ] - \[ - "full", - "f12" - \], - "isDisabledByDefault" : false, - "isDownloaded" : false, - "isHidden" : false, - "isRequired" : false, - "name" : "f2" - \}, - "f3" :[ ] - \{ - "archiveFile" : "", - "dependencies" :[ ] - \[ - "f1", - "f2" - \], - "description" : "Component for file 3", - "displayName" : "File 3", - "group" : "f34", - "installationTypes" :[ ] - \[ - "full" - \], - "isDisabledByDefault" : false, - "isDownloaded" : false, - "isHidden" : false, - "isRequired" : false, - "name" : "f3" - \}, - "f4" :[ ] - \{ - "archiveFile" : "", - "dependencies" :[ ] - \[ - "f2", - "f3", - "f1" - \], - "description" : "Component for file 4", - "displayName" : "File 4", - "group" : "f34", - "installationTypes" :[ ] - \[ - "full" - \], - "isDisabledByDefault" : false, - "isDownloaded" : false, - "isHidden" : false, - "isRequired" : false, - "name" : "f4" - \} - \}, - "errorOnAbsoluteInstallDestination" : false, - "formatVersionMajor" : 1, - "formatVersionMinor" : 0, - "installationTypes" :[ ] - \{ - "f12" :[ ] - \{ - "displayName" : "Only files 1 and 2", - "index" : 2, - "name" : "f12" - \}, - "full" :[ ] - \{ - "displayName" : "Full installation", - "index" : 1, - "name" : "full" - \} - \}, - "packageDescriptionFile" : ".*/Templates/CPack\.GenericDescription\.txt", - "packageDescriptionSummary" : "EXT-(none|good(_multi)?|invalid_good)-subtest-(MONOLITHIC|COMPONENT)-type built using CMake", - "packageName" : "ext", - "packageVersion" : "0\.1\.1", - "projects" :[ ] - \[ - \{ - "component" : "ALL", - "components" :[ ] - \[ - "f1", - "f2", - "f3", - "f4" - \], - "directory" : ".*/Tests/RunCMake/Ext/CPack/EXT-build-(none|good(_multi)?|invalid_good)-subtest", - "installationTypes" : \[\], - "projectName" : "EXT-(none|good(_multi)?|invalid_good)-subtest-(MONOLITHIC|COMPONENT)-type", - "subDirectory" : "/" - \} - \], - "setDestdir" : false, - "stripFiles" : false, - "warnOnAbsoluteInstallDestination" : false -\}$ diff --git a/Tests/RunCMake/CPack/tests/EXT/invalid_bad-stderr.txt b/Tests/RunCMake/CPack/tests/EXT/invalid_bad-stderr.txt deleted file mode 100644 index 372c5e4..0000000 --- a/Tests/RunCMake/CPack/tests/EXT/invalid_bad-stderr.txt +++ /dev/null @@ -1,6 +0,0 @@ -CMake Error at .*/Modules/Internal/CPack/CPackExt\.cmake:[0-9]+ \(message\): - Could not find a suitable version in CPACK_EXT_REQUESTED_VERSIONS - - -CPack Error: Error while executing CPackExt\.cmake -CPack Error: Cannot initialize the generator Ext diff --git a/Tests/RunCMake/CPack/tests/EXT/stage_and_package-stderr.txt b/Tests/RunCMake/CPack/tests/EXT/stage_and_package-stderr.txt deleted file mode 100644 index 40f2743..0000000 --- a/Tests/RunCMake/CPack/tests/EXT/stage_and_package-stderr.txt +++ /dev/null @@ -1 +0,0 @@ -^This script could run an external packaging tool$ diff --git a/Tests/RunCMake/CPack/tests/EXT/test.cmake b/Tests/RunCMake/CPack/tests/EXT/test.cmake deleted file mode 100644 index 976cb6a..0000000 --- a/Tests/RunCMake/CPack/tests/EXT/test.cmake +++ /dev/null @@ -1,86 +0,0 @@ -include(CPackComponent) - -if(RunCMake_SUBTEST_SUFFIX STREQUAL "none") - unset(CPACK_EXT_REQUESTED_VERSIONS) -elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "good") - set(CPACK_EXT_REQUESTED_VERSIONS "1.0") -elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "good_multi") - set(CPACK_EXT_REQUESTED_VERSIONS "1.0;2.0") -elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "bad_major") - set(CPACK_EXT_REQUESTED_VERSIONS "2.0") -elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "bad_minor") - set(CPACK_EXT_REQUESTED_VERSIONS "1.1") -elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "invalid_good") - set(CPACK_EXT_REQUESTED_VERSIONS "1;1.0") -elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "invalid_bad") - set(CPACK_EXT_REQUESTED_VERSIONS "1") -elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "stage_and_package") - set(CPACK_EXT_ENABLE_STAGING 1) - set(CPACK_EXT_PACKAGE_SCRIPT "${CMAKE_CURRENT_LIST_DIR}/create_package.cmake") -endif() - -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/f1.txt" test1) -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/f2.txt" test2) -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/f3.txt" test3) -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/f4.txt" test4) - -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/f1.txt" DESTINATION share/cpack-test COMPONENT f1) -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/f2.txt" DESTINATION share/cpack-test COMPONENT f2) -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/f3.txt" DESTINATION share/cpack-test COMPONENT f3) -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/f4.txt" DESTINATION share/cpack-test COMPONENT f4) - -cpack_add_component(f1 - DISPLAY_NAME "File 1" - DESCRIPTION "Component for file 1" - GROUP f12 - INSTALL_TYPES full f12 -) - -cpack_add_component(f2 - DISPLAY_NAME "File 2" - DESCRIPTION "Component for file 2" - GROUP f12 - DEPENDS f1 - INSTALL_TYPES full f12 -) - -cpack_add_component(f3 - DISPLAY_NAME "File 3" - DESCRIPTION "Component for file 3" - GROUP f34 - DEPENDS f1 f2 - INSTALL_TYPES full -) - -cpack_add_component(f4 - DISPLAY_NAME "File 4" - DESCRIPTION "Component for file 4" - GROUP f34 - DEPENDS f2 f3 f1 - INSTALL_TYPES full -) - -cpack_add_component_group(f12 - DISPLAY_NAME "Files 1 and 2" - DESCRIPTION "Component group for files 1 and 2" - PARENT_GROUP f1234 -) - -cpack_add_component_group(f34 - DISPLAY_NAME "Files 3 and 4" - DESCRIPTION "Component group for files 3 and 4" - PARENT_GROUP f1234 -) - -cpack_add_component_group(f1234 - DISPLAY_NAME "Files 1-4" - DESCRIPTION "Component group for all files" -) - -cpack_add_install_type(full - DISPLAY_NAME "Full installation" -) - -cpack_add_install_type(f12 - DISPLAY_NAME "Only files 1 and 2" -) diff --git a/Tests/RunCMake/CPack/tests/EXTERNAL/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/EXTERNAL/ExpectedFiles.cmake new file mode 100644 index 0000000..91608c9 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/EXTERNAL/ExpectedFiles.cmake @@ -0,0 +1,7 @@ +if(RunCMake_SUBTEST_SUFFIX MATCHES "^(none|good(_multi)?|invalid_good)$" + OR RunCMake_SUBTEST_SUFFIX STREQUAL "stage_and_package") + set(EXPECTED_FILES_COUNT "1") + set(EXPECTED_FILE_CONTENT_1_LIST "/share;/share/cpack-test;/share/cpack-test/f1.txt;/share/cpack-test/f2.txt;/share/cpack-test/f3.txt;/share/cpack-test/f4.txt") +else() + set(EXPECTED_FILES_COUNT "0") +endif() diff --git a/Tests/RunCMake/CPack/tests/EXTERNAL/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/EXTERNAL/VerifyResult.cmake new file mode 100644 index 0000000..bc19d7e --- /dev/null +++ b/Tests/RunCMake/CPack/tests/EXTERNAL/VerifyResult.cmake @@ -0,0 +1,3 @@ +if(RunCMake_SUBTEST_SUFFIX MATCHES "^(none|good(_multi)?|invalid_good)") + check_ext_json("${src_dir}/tests/EXTERNAL/expected-json-1.0.txt" "${FOUND_FILE_1}") +endif() diff --git a/Tests/RunCMake/CPack/tests/EXTERNAL/bad_major-stderr.txt b/Tests/RunCMake/CPack/tests/EXTERNAL/bad_major-stderr.txt new file mode 100644 index 0000000..f2e160e --- /dev/null +++ b/Tests/RunCMake/CPack/tests/EXTERNAL/bad_major-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at .*/Modules/Internal/CPack/CPackExternal\.cmake:[0-9]+ \(message\): + Could not find a suitable version in CPACK_EXTERNAL_REQUESTED_VERSIONS + + +CPack Error: Error while executing CPackExternal\.cmake +CPack Error: Cannot initialize the generator External diff --git a/Tests/RunCMake/CPack/tests/EXTERNAL/bad_minor-stderr.txt b/Tests/RunCMake/CPack/tests/EXTERNAL/bad_minor-stderr.txt new file mode 100644 index 0000000..f2e160e --- /dev/null +++ b/Tests/RunCMake/CPack/tests/EXTERNAL/bad_minor-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at .*/Modules/Internal/CPack/CPackExternal\.cmake:[0-9]+ \(message\): + Could not find a suitable version in CPACK_EXTERNAL_REQUESTED_VERSIONS + + +CPack Error: Error while executing CPackExternal\.cmake +CPack Error: Cannot initialize the generator External diff --git a/Tests/RunCMake/CPack/tests/EXTERNAL/create_package.cmake b/Tests/RunCMake/CPack/tests/EXTERNAL/create_package.cmake new file mode 100644 index 0000000..e308ccb --- /dev/null +++ b/Tests/RunCMake/CPack/tests/EXTERNAL/create_package.cmake @@ -0,0 +1,24 @@ +message("This script could run an external packaging tool") + +function(expect_variable VAR) + if(NOT ${VAR}) + message(FATAL_ERROR "${VAR} is unexpectedly not set") + endif() +endfunction() + +function(expect_file FILE) + if(NOT EXISTS "${FILE}") + message(FATAL_ERROR "${FILE} is unexpectedly missing") + endif() +endfunction() + +expect_variable(CPACK_COMPONENTS_ALL) +expect_variable(CPACK_TOPLEVEL_DIRECTORY) +expect_variable(CPACK_TEMPORARY_DIRECTORY) +expect_variable(CPACK_PACKAGE_DIRECTORY) +expect_variable(CPACK_PACKAGE_FILE_NAME) + +expect_file(${CPACK_TEMPORARY_DIRECTORY}/f1/share/cpack-test/f1.txt) +expect_file(${CPACK_TEMPORARY_DIRECTORY}/f2/share/cpack-test/f2.txt) +expect_file(${CPACK_TEMPORARY_DIRECTORY}/f3/share/cpack-test/f3.txt) +expect_file(${CPACK_TEMPORARY_DIRECTORY}/f4/share/cpack-test/f4.txt) diff --git a/Tests/RunCMake/CPack/tests/EXTERNAL/expected-json-1.0.txt b/Tests/RunCMake/CPack/tests/EXTERNAL/expected-json-1.0.txt new file mode 100644 index 0000000..18bf617 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/EXTERNAL/expected-json-1.0.txt @@ -0,0 +1,176 @@ +^\{ + "componentGroups" :[ ] + \{ + "f12" :[ ] + \{ + "components" :[ ] + \[ + "f1", + "f2" + \], + "description" : "Component group for files 1 and 2", + "displayName" : "Files 1 and 2", + "isBold" : false, + "isExpandedByDefault" : false, + "name" : "f12", + "parentGroup" : "f1234", + "subgroups" : \[\] + \}, + "f1234" :[ ] + \{ + "components" : \[\], + "description" : "Component group for all files", + "displayName" : "Files 1-4", + "isBold" : false, + "isExpandedByDefault" : false, + "name" : "f1234", + "subgroups" :[ ] + \[ + "f12", + "f34" + \] + \}, + "f34" :[ ] + \{ + "components" :[ ] + \[ + "f3", + "f4" + \], + "description" : "Component group for files 3 and 4", + "displayName" : "Files 3 and 4", + "isBold" : false, + "isExpandedByDefault" : false, + "name" : "f34", + "parentGroup" : "f1234", + "subgroups" : \[\] + \} + \}, + "components" :[ ] + \{ + "f1" :[ ] + \{ + "archiveFile" : "", + "dependencies" : \[\], + "description" : "Component for file 1", + "displayName" : "File 1", + "group" : "f12", + "installationTypes" :[ ] + \[ + "full", + "f12" + \], + "isDisabledByDefault" : false, + "isDownloaded" : false, + "isHidden" : false, + "isRequired" : false, + "name" : "f1" + \}, + "f2" :[ ] + \{ + "archiveFile" : "", + "dependencies" :[ ] + \[ + "f1" + \], + "description" : "Component for file 2", + "displayName" : "File 2", + "group" : "f12", + "installationTypes" :[ ] + \[ + "full", + "f12" + \], + "isDisabledByDefault" : false, + "isDownloaded" : false, + "isHidden" : false, + "isRequired" : false, + "name" : "f2" + \}, + "f3" :[ ] + \{ + "archiveFile" : "", + "dependencies" :[ ] + \[ + "f1", + "f2" + \], + "description" : "Component for file 3", + "displayName" : "File 3", + "group" : "f34", + "installationTypes" :[ ] + \[ + "full" + \], + "isDisabledByDefault" : false, + "isDownloaded" : false, + "isHidden" : false, + "isRequired" : false, + "name" : "f3" + \}, + "f4" :[ ] + \{ + "archiveFile" : "", + "dependencies" :[ ] + \[ + "f2", + "f3", + "f1" + \], + "description" : "Component for file 4", + "displayName" : "File 4", + "group" : "f34", + "installationTypes" :[ ] + \[ + "full" + \], + "isDisabledByDefault" : false, + "isDownloaded" : false, + "isHidden" : false, + "isRequired" : false, + "name" : "f4" + \} + \}, + "errorOnAbsoluteInstallDestination" : false, + "formatVersionMajor" : 1, + "formatVersionMinor" : 0, + "installationTypes" :[ ] + \{ + "f12" :[ ] + \{ + "displayName" : "Only files 1 and 2", + "index" : 2, + "name" : "f12" + \}, + "full" :[ ] + \{ + "displayName" : "Full installation", + "index" : 1, + "name" : "full" + \} + \}, + "packageDescriptionFile" : ".*/Templates/CPack\.GenericDescription\.txt", + "packageDescriptionSummary" : "EXTERNAL-(none|good(_multi)?|invalid_good)-subtest-(MONOLITHIC|COMPONENT)-type built using CMake", + "packageName" : "external", + "packageVersion" : "0\.1\.1", + "projects" :[ ] + \[ + \{ + "component" : "ALL", + "components" :[ ] + \[ + "f1", + "f2", + "f3", + "f4" + \], + "directory" : ".*/Tests/RunCMake/External/CPack/EXTERNAL-build-(none|good(_multi)?|invalid_good)-subtest", + "installationTypes" : \[\], + "projectName" : "EXTERNAL-(none|good(_multi)?|invalid_good)-subtest-(MONOLITHIC|COMPONENT)-type", + "subDirectory" : "/" + \} + \], + "setDestdir" : false, + "stripFiles" : false, + "warnOnAbsoluteInstallDestination" : false +\}$ diff --git a/Tests/RunCMake/CPack/tests/EXTERNAL/invalid_bad-stderr.txt b/Tests/RunCMake/CPack/tests/EXTERNAL/invalid_bad-stderr.txt new file mode 100644 index 0000000..f2e160e --- /dev/null +++ b/Tests/RunCMake/CPack/tests/EXTERNAL/invalid_bad-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at .*/Modules/Internal/CPack/CPackExternal\.cmake:[0-9]+ \(message\): + Could not find a suitable version in CPACK_EXTERNAL_REQUESTED_VERSIONS + + +CPack Error: Error while executing CPackExternal\.cmake +CPack Error: Cannot initialize the generator External diff --git a/Tests/RunCMake/CPack/tests/EXTERNAL/stage_and_package-stderr.txt b/Tests/RunCMake/CPack/tests/EXTERNAL/stage_and_package-stderr.txt new file mode 100644 index 0000000..40f2743 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/EXTERNAL/stage_and_package-stderr.txt @@ -0,0 +1 @@ +^This script could run an external packaging tool$ diff --git a/Tests/RunCMake/CPack/tests/EXTERNAL/test.cmake b/Tests/RunCMake/CPack/tests/EXTERNAL/test.cmake new file mode 100644 index 0000000..bc9766b --- /dev/null +++ b/Tests/RunCMake/CPack/tests/EXTERNAL/test.cmake @@ -0,0 +1,86 @@ +include(CPackComponent) + +if(RunCMake_SUBTEST_SUFFIX STREQUAL "none") + unset(CPACK_EXTERNAL_REQUESTED_VERSIONS) +elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "good") + set(CPACK_EXTERNAL_REQUESTED_VERSIONS "1.0") +elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "good_multi") + set(CPACK_EXTERNAL_REQUESTED_VERSIONS "1.0;2.0") +elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "bad_major") + set(CPACK_EXTERNAL_REQUESTED_VERSIONS "2.0") +elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "bad_minor") + set(CPACK_EXTERNAL_REQUESTED_VERSIONS "1.1") +elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "invalid_good") + set(CPACK_EXTERNAL_REQUESTED_VERSIONS "1;1.0") +elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "invalid_bad") + set(CPACK_EXTERNAL_REQUESTED_VERSIONS "1") +elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "stage_and_package") + set(CPACK_EXTERNAL_ENABLE_STAGING 1) + set(CPACK_EXTERNAL_PACKAGE_SCRIPT "${CMAKE_CURRENT_LIST_DIR}/create_package.cmake") +endif() + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/f1.txt" test1) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/f2.txt" test2) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/f3.txt" test3) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/f4.txt" test4) + +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/f1.txt" DESTINATION share/cpack-test COMPONENT f1) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/f2.txt" DESTINATION share/cpack-test COMPONENT f2) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/f3.txt" DESTINATION share/cpack-test COMPONENT f3) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/f4.txt" DESTINATION share/cpack-test COMPONENT f4) + +cpack_add_component(f1 + DISPLAY_NAME "File 1" + DESCRIPTION "Component for file 1" + GROUP f12 + INSTALL_TYPES full f12 +) + +cpack_add_component(f2 + DISPLAY_NAME "File 2" + DESCRIPTION "Component for file 2" + GROUP f12 + DEPENDS f1 + INSTALL_TYPES full f12 +) + +cpack_add_component(f3 + DISPLAY_NAME "File 3" + DESCRIPTION "Component for file 3" + GROUP f34 + DEPENDS f1 f2 + INSTALL_TYPES full +) + +cpack_add_component(f4 + DISPLAY_NAME "File 4" + DESCRIPTION "Component for file 4" + GROUP f34 + DEPENDS f2 f3 f1 + INSTALL_TYPES full +) + +cpack_add_component_group(f12 + DISPLAY_NAME "Files 1 and 2" + DESCRIPTION "Component group for files 1 and 2" + PARENT_GROUP f1234 +) + +cpack_add_component_group(f34 + DISPLAY_NAME "Files 3 and 4" + DESCRIPTION "Component group for files 3 and 4" + PARENT_GROUP f1234 +) + +cpack_add_component_group(f1234 + DISPLAY_NAME "Files 1-4" + DESCRIPTION "Component group for all files" +) + +cpack_add_install_type(full + DISPLAY_NAME "Full installation" +) + +cpack_add_install_type(f12 + DISPLAY_NAME "Only files 1 and 2" +) -- cgit v0.12