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?
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.