CMake depend on “all” target from custom target
问题 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