I'm making a library that needs to be packaged in a fancy way, and as part of that, I have a script that contains these lines:
#only install the lib component, nd put in the a special directory
ADD_CUSTOM_TARGET(o_destdir_install
COMMAND DESTDIR=${CMAKE_BINARY_DIR}/o_package ${CMAKE_COMMAND} -DCOMPONENT=lib -P cmake_install.cmake
DEPENDS ${CMAKE_BINARY_DIR}/cmake_install.cmake
COMMENT "Building o_package directory with DESTDIR"
)
ADD_DEPENDENCIES(o_destdir_install all preinstall)
I've found this code from the old UseDebian.cmake dpkg builder, however it does NOT build all and preinstall before it runs the install. Making my target depend on a non-built-in target seems to work, but I can't depend on any built-in targets it seems. How can I get this to work?
Also it would be nice if I could depend on a single component install preferably without the hacking calling of cmake, but I'm fine either way
Instead of hacking together your own install target, you should just piggy-back on the existing one using the
install(CODE)
form:You can depend on 'all' target using
ALL
keyword. See documentation.