Reputation: 2843
We have legacy project, which uses proprietary build system. We want to port it to CMake. Before build step we have script, which generates code based on comments inside of source files.
I tried to embed it using add_custom_target
,add_custom_command
, but it fails, because
Currently my setup is as follows.
add_library(${PROJECT_NAME} INTERFACE)
....
target_link_libraries(${PROJECT_NAME} ${MANY_SMALL_LIBRARIES})
I can't add PRE_BUILD
step for interface library.
Upvotes: 0
Views: 626
Reputation: 2843
I solved it roughly like this.
add_custom_command(
OUTPUT a_done
COMMAND touch a_done
COMMAND ${CMAKE_SOURCE_DIR}/a.sh
COMMENT "Doing a.sh"
)
add_custom_command(
OUTPUT b_done
COMMAND touch b_done
COMMAND ${CMAKE_SOURCE_DIR}/b.sh
COMMENT "Doing b.sh"
)
# Execute our custom scripts in following order (in case of sequential build)
add_custom_target(SCRIPTS ALL DEPENDS
a_done
b_done
)
add_dependencies(target_1 SCRIPTS)
...
add_dependencies(target_N SCRIPTS)
Upvotes: 1