Search code examples
cmakecpack

cmake: print messages from internal .cmake


I'm trying to debug a problem I got during a make package:

CMake Error at /usr/local/Cellar/cmake/3.4.3/share/cmake/Modules/BundleUtilities.cmake:861 (message):
    error: fixup_bundle: not a valid bundle

I've seen that there are some message(STATUS ....) inside but they do not get printed.

as example, at the beginning the funcion fixup_bundle contained in that file (/usr/local/Cellar/cmake/3.4.3/share/cmake/Modules/BundleUtilities.cmake) there are these lines:

message(STATUS "fixup_bundle")
message(STATUS "  app='${app}'")
message(STATUS "  libs='${libs}'")
message(STATUS "  dirs='${dirs}'")

but when I run cmake I don't get those printed even with make package VERBOSE=1.

but if I remove the STATUS those get printed so I was wondering how to "actvate" the STATUS messages


Solution

  • I could reproduce your problem and you won't get the status messages if CPack's source code is not changed. The behavior you're experiencing is how CPack is currently implemented.

    If you look into your CMake generated package makefile rule you will find something like:

    # Special rule for the target package
    package: preinstall
        @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Run CPack packaging tool..."
        [your path here]/cpack.exe --config ./CPackConfig.cmake
    .PHONY : package
    

    So you're calling cpack.exe when doing make package. To reproduce your problem I just appended the following line to CPackConfig.cmake:

    message(STATUS "+++ Test +++")
    

    As you have already tested, only if I remove the STATUS keyword I see the message. So I've tested to directly call from the command line:

    > cpack.exe --verbose --debug --config ./CPackConfig.cmake
    

    But still didn't get the message. When debugging cpack.exe I could see that STATUS messages do finally call cmake::UpdateProgress() and there is simply no ProgressCallback set in CPack.

    I think a fix is very simple, but I'm not sure if you're willing to change CMake's source code or e.g. if you want to raise a ticket in CMake's bug tracker.

    Edit: I've successfully tested the following code extensions for cpack.cxx with STATUS messages:

    void cpackProgress(const char *msg, float prog, void* ptr)
    {
        (void)prog;
        cmCPackLog* log = static_cast<cmCPackLog*>(ptr);
        cmCPack_Log(log, cmCPackLog::LOG_OUTPUT, msg << std::endl);
    }
    

    and then

    int main (int argc, char const* const* argv)
    {
        [...]
        cmake cminst;
        cminst.SetProgressCallback(cpackProgress, &log);
        [...]
    }