thoni56
thoni56

Reputation: 3335

Prevent cmake to run cpack

I have a CMake project where I want to prevent make package to do anything more than print a message on some platforms.

I know how to add a message, even a fatal one, but that runs during cmake-generation, not during builds. Do I have to resort to some add_custom_command? And that won't give me what I want, since that creates a new build target...

How can I override the package target for some platforms to just show a message?

Upvotes: 1

Views: 630

Answers (2)

Maths noob
Maths noob

Reputation: 1802

As shu pointed out, you can do something like this:

if (! WIN32)
    include(cpack)
else()
    cmake_policy(SET CMP0037 OLD)
    add_custom_target(package
        #add dependencies on other targets here
        #[[DEPENDS install]]
        COMMAND ${CMAKE_COMMAND} -E echo "custom target for non windows platforms!"
)
endif()

Note that by default, you will not be allowed to override reserved targets like test and package. We are turning off that policy here to write our own package target.

Upvotes: 0

user6335789
user6335789

Reputation:

why include cpack in your cmake list at all?

In order for a cmake project to have a cpack controlled package target, your project should include a line like:

include(CPack)

and also setting up some cpack-related properties. If you don't want that, you can just take out that line.

Upvotes: 1

Related Questions