From 4a3ae1710ecefedef8c345cd00599b335bc164d2 Mon Sep 17 00:00:00 2001 From: Nils Gladitz Date: Sat, 1 Dec 2018 09:15:17 +0100 Subject: CPack/External: Fix status messages of staging scripts Set progress callback on cmake instance used by CPack. The progress callback is used to output STATUS messages which are otherwise missing when issued from e.g. CPack External staging scripts. Fixes: #18567 --- Source/CPack/cpack.cxx | 10 ++++++++++ Tests/RunCMake/CPack/tests/EXTERNAL/create_package.cmake | 2 ++ .../RunCMake/CPack/tests/EXTERNAL/stage_and_package-stdout.txt | 1 + 3 files changed, 13 insertions(+) create mode 100644 Tests/RunCMake/CPack/tests/EXTERNAL/stage_and_package-stdout.txt diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index c083945..623cdcd 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -88,6 +88,15 @@ int cpackDefinitionArgument(const char* argument, const char* cValue, return 1; } +static void cpackProgressCallback(const char* message, float progress, + void* clientdata) +{ + (void)progress; + (void)clientdata; + + std::cout << "-- " << message << std::endl; +} + // this is CPack. int main(int argc, char const* const* argv) { @@ -201,6 +210,7 @@ int main(int argc, char const* const* argv) cmake cminst(cmake::RoleScript); cminst.SetHomeDirectory(""); cminst.SetHomeOutputDirectory(""); + cminst.SetProgressCallback(cpackProgressCallback, nullptr); cminst.GetCurrentSnapshot().SetDefaultDefinitions(); cmGlobalGenerator cmgg(&cminst); cmMakefile globalMF(&cmgg, cminst.GetCurrentSnapshot()); diff --git a/Tests/RunCMake/CPack/tests/EXTERNAL/create_package.cmake b/Tests/RunCMake/CPack/tests/EXTERNAL/create_package.cmake index e308ccb..2d7f993 100644 --- a/Tests/RunCMake/CPack/tests/EXTERNAL/create_package.cmake +++ b/Tests/RunCMake/CPack/tests/EXTERNAL/create_package.cmake @@ -22,3 +22,5 @@ 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) + +message(STATUS "This status message is expected to be visible") diff --git a/Tests/RunCMake/CPack/tests/EXTERNAL/stage_and_package-stdout.txt b/Tests/RunCMake/CPack/tests/EXTERNAL/stage_and_package-stdout.txt new file mode 100644 index 0000000..37d635f --- /dev/null +++ b/Tests/RunCMake/CPack/tests/EXTERNAL/stage_and_package-stdout.txt @@ -0,0 +1 @@ +-- This status message is expected to be visible -- cgit v0.12