[CMake] Embedding up-to-date version info in built library
Kolja Waschk
cmuser09 at ixo.de
Fri Dec 11 10:45:08 EST 2009
> the list of sources. But another problem came up: Only the first single
> list item seems to be scanned for implicit dependencies. And I failed to
> come up with a list or command syntax that would allow me to have the
> other 99+ sources scanned as well.
I think I came up with a usable workaround for now. A semaphore file is
created for every source file which IMPLICIT_DEPENDS on that source
file, and my actual version.cc now depends on all the semaphore files.
Basically this:
foreach (srcfile ${SOURCEFILES})
string(REPLACE "/" "_" srcok ${srcfile})
set(semafile dep_${srcok})
add_custom_command(
OUTPUT ${semafile}
COMMAND touch ${semafile}
IMPLICIT_DEPENDS CXX ${PROJECT_SOURCE_DIR}/src/${srcfile}
COMMENT ""
)
set(VERSION_DEPFILES ${VERSION_SEMAFILES} ${semafile})
endforeach(srcfile)
add_custom_command(
OUTPUT version.cc
COMMAND create_version_cc.sh
DEPENDS ${VERSION_SEMAFILES}
)
I'm open for improvements and better ideas...
Kolja
More information about the CMake
mailing list