CMake: How to run a add_custom_command before everything else

You should use add_custom_target instead and add_dependencies to make your normal target depend on it:

add_custom_target(
    myCustomTarget
    COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/mk_config_h.py ${CMAKE_CURRENT_BINARY_DIR}/config.h
)
add_dependencies(myTarget myCustomTarget)

This should ensure that the command is run before compiling the sources of myTarget.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)