The target that creates version.h should be added as a dependency to the target that uses version.h:
add_dependencies(codeTarget versionHeaderTarget)
Are you sure that one of your source files is actually consuming "version.h" ??
This is all that I need to do to make sure version.h gets generated at the "right time"
CONFIGURE_FILE (
"${PROJECT_SOURCE_DIR}/version.h.in"
"${PROJECT_BINARY_DIR}/version.h"
)
INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}")
INSTALL(FILES ${PROJECT_BINARY_DIR}/version.h DESTINATION "include/SoDaRadio")
And then somewhere in the sources I have :
src/UI.cxx:#include "version.h"
what you need is dependency ordering to ensure the target that modifies version.h is run first
Yes, that's the sticky bit right now.
Why isn't the process that modifies version.h in an add_custom_target() block?
It is!
add_custom_target(svn_version ALL)
ADD_CUSTOM_COMMAND(TARGET svn_version
COMMAND pre-build.bat
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
I put a DEPENDS in there earlier, but it was just replicating what the '#include version.h' was doing.