Reputation: 11753
I asked a question How to add files to a non-executable or non-library target with CMake a few days ago, and the best solution to this problem is to use add_custom_target
command.
However, this solution may not work if the target is created by CMAKE itself. For example, the INSTALL target that is created automatically when running CMAKE. Suppose, I also put some additional files under the INSTALL project, what should I do? I have tried the following command, but failed:
add_custom_target( INSTALL
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/file_to_be_added.h
)
Upvotes: 0
Views: 471
Reputation: 65791
CMake's default INSTALL
target cannot be modified. You can however add a custom target, which does the same thing as the INSTALL
target and has additional files added, e.g.:
add_custom_target(myinstall
COMMAND "${CMAKE_COMMAND}" "-DBUILD_TYPE=$<CONFIGURATION>"
"-P" "${CMAKE_BINARY_DIR}/cmake_install.cmake"
SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/file_to_be_added.h"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")
Upvotes: 1