CPack: Introduce CPACK_INSTALL_SCRIPTS variable
The singular name `CPACK_INSTALL_SCRIPT` has existed but was not linked from the CPack documentation. Also, it supported multiple values and should have had a plural name. Add a plural-named alternative now. If both `CPACK_INSTALL_SCRIPTS` and `CPACK_INSTALL_SCRIPT` are set then ignore the latter with a warning. Signed-off-by: Alex Turbov <i.zaufi@gmail.com>
This commit is contained in:
parent
f374ffb14b
commit
5f96601675
@ -607,7 +607,6 @@ Variables for CPack
|
||||
/variable/CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION
|
||||
/variable/CPACK_INCLUDE_TOPLEVEL_DIRECTORY
|
||||
/variable/CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
|
||||
/variable/CPACK_INSTALL_SCRIPT
|
||||
/variable/CPACK_PACKAGING_INSTALL_PREFIX
|
||||
/variable/CPACK_SET_DESTDIR
|
||||
/variable/CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION
|
||||
|
5
Help/release/dev/cpack-install-scripts.rst
Normal file
5
Help/release/dev/cpack-install-scripts.rst
Normal file
@ -0,0 +1,5 @@
|
||||
cpack-install-scripts
|
||||
---------------------
|
||||
|
||||
* The ``CPACK_INSTALL_SCRIPT`` variable has been deprecated in favor of the
|
||||
new, more accurately named :variable:`CPACK_INSTALL_SCRIPTS` variable.
|
@ -1,8 +0,0 @@
|
||||
CPACK_INSTALL_SCRIPT
|
||||
--------------------
|
||||
|
||||
Extra CMake script provided by the user.
|
||||
|
||||
If set this CMake script will be executed by CPack during its local
|
||||
[CPack-private] installation which is done right before packaging the
|
||||
files. The script is not called by e.g.: ``make install``.
|
@ -325,7 +325,21 @@ The following variables are for advanced uses of CPack:
|
||||
|
||||
.. variable:: CPACK_INSTALL_COMMANDS
|
||||
|
||||
Extra commands to install components.
|
||||
Extra commands to install components. The environment variable
|
||||
``CMAKE_INSTALL_PREFIX`` is set to the temporary install directory
|
||||
during execution.
|
||||
|
||||
.. variable:: CPACK_INSTALL_SCRIPTS
|
||||
|
||||
Extra CMake scripts executed by CPack during its local staging
|
||||
installation, which is done right before packaging the files.
|
||||
The scripts are not called by a standalone install (e.g.: ``make install``).
|
||||
For every script, the following variables will be set:
|
||||
:variable:`CMAKE_CURRENT_SOURCE_DIR`, :variable:`CMAKE_CURRENT_BINARY_DIR`
|
||||
and :variable:`CMAKE_INSTALL_PREFIX` (which is set to the staging install
|
||||
directory). The singular form ``CMAKE_INSTALL_SCRIPT`` is supported as
|
||||
an alternative variable for historical reasons, but its value is ignored if
|
||||
``CMAKE_INSTALL_SCRIPTS`` is set and a warning will be issued.
|
||||
|
||||
.. variable:: CPACK_INSTALLED_DIRECTORIES
|
||||
|
||||
|
@ -235,7 +235,7 @@ int cmCPackGenerator::InstallProject()
|
||||
return 0;
|
||||
}
|
||||
|
||||
// If the CPackConfig file sets CPACK_INSTALL_SCRIPT then run them
|
||||
// If the CPackConfig file sets CPACK_INSTALL_SCRIPT(S) then run them
|
||||
// as listed
|
||||
if (!this->InstallProjectViaInstallScript(setDestDir,
|
||||
tempInstallDirectory)) {
|
||||
@ -448,7 +448,19 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
|
||||
int cmCPackGenerator::InstallProjectViaInstallScript(
|
||||
bool setDestDir, const std::string& tempInstallDirectory)
|
||||
{
|
||||
const char* cmakeScripts = this->GetOption("CPACK_INSTALL_SCRIPT");
|
||||
const char* cmakeScripts = this->GetOption("CPACK_INSTALL_SCRIPTS");
|
||||
{
|
||||
const char* const cmakeScript = this->GetOption("CPACK_INSTALL_SCRIPT");
|
||||
if (cmakeScript && cmakeScripts) {
|
||||
cmCPackLogger(
|
||||
cmCPackLog::LOG_WARNING,
|
||||
"Both CPACK_INSTALL_SCRIPTS and CPACK_INSTALL_SCRIPT are set, "
|
||||
"the latter will be ignored."
|
||||
<< std::endl);
|
||||
} else if (cmakeScript && !cmakeScripts) {
|
||||
cmakeScripts = cmakeScript;
|
||||
}
|
||||
}
|
||||
if (cmakeScripts && *cmakeScripts) {
|
||||
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
|
||||
"- Install scripts: " << cmakeScripts << std::endl);
|
||||
|
@ -33,6 +33,6 @@ run_cpack_test(TIMESTAMPS "DEB.TIMESTAMPS;TGZ" false "COMPONENT")
|
||||
unset(ENVIRONMENT)
|
||||
run_cpack_test(USER_FILELIST "RPM.USER_FILELIST" false "MONOLITHIC")
|
||||
run_cpack_test(MD5SUMS "DEB.MD5SUMS" false "MONOLITHIC;COMPONENT")
|
||||
run_cpack_test(CPACK_INSTALL_SCRIPT "ZIP" false "MONOLITHIC")
|
||||
run_cpack_test_subtests(CPACK_INSTALL_SCRIPTS "singular;plural;both" "ZIP" false "MONOLITHIC")
|
||||
run_cpack_test(DEB_PACKAGE_VERSION_BACK_COMPATIBILITY "DEB.DEB_PACKAGE_VERSION_BACK_COMPATIBILITY" 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")
|
||||
|
@ -1,11 +0,0 @@
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/abc.txt" "test content")
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/user-script.cmake"
|
||||
"file(INSTALL DESTINATION \"\${CMAKE_INSTALL_PREFIX}/foo\"
|
||||
TYPE FILE FILES \"${CMAKE_CURRENT_BINARY_DIR}/abc.txt\")")
|
||||
set(CPACK_INSTALL_SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/user-script.cmake")
|
||||
|
||||
function(run_after_include_cpack)
|
||||
file(READ "${CPACK_OUTPUT_CONFIG_FILE}" conf_file_)
|
||||
string(REGEX REPLACE "SET\\(CPACK_INSTALL_CMAKE_PROJECTS [^)]*\\)" "" conf_file_ "${conf_file_}")
|
||||
file(WRITE "${CPACK_OUTPUT_CONFIG_FILE}" "${conf_file_}")
|
||||
endfunction()
|
@ -0,0 +1 @@
|
||||
CPack Warning: Both CPACK_INSTALL_SCRIPTS and CPACK_INSTALL_SCRIPT are set, the latter will be ignored.
|
26
Tests/RunCMake/CPack/tests/CPACK_INSTALL_SCRIPTS/test.cmake
Normal file
26
Tests/RunCMake/CPack/tests/CPACK_INSTALL_SCRIPTS/test.cmake
Normal file
@ -0,0 +1,26 @@
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/abc.txt" "test content")
|
||||
set(user_script_ "${CMAKE_CURRENT_BINARY_DIR}/user-script.cmake")
|
||||
file(WRITE "${user_script_}"
|
||||
"file(INSTALL DESTINATION \"\${CMAKE_INSTALL_PREFIX}/foo\"
|
||||
TYPE FILE FILES \"${CMAKE_CURRENT_BINARY_DIR}/abc.txt\")")
|
||||
|
||||
if(RunCMake_SUBTEST_SUFFIX STREQUAL "both")
|
||||
set(CPACK_INSTALL_SCRIPT "${user_script_}")
|
||||
set(CPACK_INSTALL_SCRIPTS "${CPACK_INSTALL_SCRIPT}")
|
||||
|
||||
elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "singular")
|
||||
set(CPACK_INSTALL_SCRIPT "${user_script_}")
|
||||
|
||||
elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "plural")
|
||||
set(CPACK_INSTALL_SCRIPTS "${user_script_}")
|
||||
|
||||
else()
|
||||
message(FATAL_ERROR "Unexpected subtest name: ${RunCMake_SUBTEST_SUFFIX}")
|
||||
|
||||
endif()
|
||||
|
||||
function(run_after_include_cpack)
|
||||
file(READ "${CPACK_OUTPUT_CONFIG_FILE}" conf_file_)
|
||||
string(REGEX REPLACE "SET\\(CPACK_INSTALL_CMAKE_PROJECTS [^)]*\\)" "" conf_file_ "${conf_file_}")
|
||||
file(WRITE "${CPACK_OUTPUT_CONFIG_FILE}" "${conf_file_}")
|
||||
endfunction()
|
Loading…
Reference in New Issue
Block a user