[CMake] Libraries with custom build command

Mathias Gaunard mathias.gaunard at ens-lyon.org
Mon Nov 14 14:11:53 EST 2011


What is the recommended way to define libraries with custom build commands?

This trick seems to be the only way:

if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp)
   file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp)
endif()
add_library(foo dummy.cpp)
add_custom_command(TARGET foo POST_BUILD
                    COMMAND my command to replace the dummy libfoo
                   )

Is it normal that kind of thing is not possible with IMPORTED libraries?


More information about the CMake mailing list