I have something like this in my project:
add_custom_command(OUTPUT somefile)
add_custom_target(tgt ALL DEPENDS somefile)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/somefile DESTINATION somedir)
This works OK, but my command is being run during make
because of ALL
keyword in add_custom_target(). What i want is to make CMake to run this command only when make install
is issued, not during build.
If i remove ALL keyword, whole target is not being built by default, so somefile is not produced and make install
fails.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…