Run target in POST_BUILD step
In cmake I'm building a Makefiles to build a few static libraries which are my final product. A few of them needs to be produced in two versions - one without any undefined reference (lets call it lib_free
) and one without linking external dependencies (lets call it lib
).
After invoking cmake --build -t lib
I need to have both lib
and lib_free
build fired. I don't want to any of them be build by default (keyward ALL). Solutions is quite simple except that it leads to cycle dependency:
macro(LinkStaticLibs target extra_libs)
add_library(${target}_free STATIC $<TARGET_OBJECTS:${target}>)
target_link_libraries(${target}_free PRIVATE ${extra_libs})
# add_dependencies(${target} ${target}_free) # cycle dependency
endmacro()
To solve cycle, POST_BUILD
step looks like a good solution. Is it possible to fire lib_free
target build after each lib
build?
Edited by Brad King