[CMake] EXTERNAL_OBJECT
Yevgen Muntyan
ymuntyan at gmail.com
Fri Dec 26 15:25:21 EST 2008
Hello,
How to make cmake rebuild a program when give file changes, if there isn't
a corresponding C or C++ file? I am trying to compile a windows resource file
in, it works, but I just can't make it rebuild the executable when the
resource file
changes. I have the following code:
SET(GGAP_SOURCES main.cpp)
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ggap.res
COMMAND ${CMAKE_WINDRES} -i ${CMAKE_CURRENT_BINARY_DIR}/ggap.rc
--input-format=rc -o ${CMAKE_CURRENT_BINARY_DIR}/ggap.res -O coff
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ggap.rc
)
LIST(APPEND GGAP_SOURCES "${CMAKE_CURRENT_BINARY_DIR}/ggap.res")
SET_SOURCE_FILES_PROPERTIES("${CMAKE_CURRENT_BINARY_DIR}/ggap.res"
PROPERTIES EXTERNAL_OBJECT 1 GENERATED 1)
ADD_EXECUTABLE(ggap WIN32 ${GGAP_SOURCES})
SET_TARGET_PROPERTIES(ggap PROPERTIES LINK_FLAGS -Wl,ggap.res)
It does recreate ggap.res file whenever I change ggap.rc, but it won't
rebuild the
executable ggap.exe when that happens. Sometimes it actually will,
it's something
I can't understand at all (I suspect it happens because I change
CMakeLists.txt though,
not because of changed ggap.res).
Note, this is cross-comilation with mingw on linux, where simply
putting teh rc file into
sources doesn't work.
Thanks!
Yevgen
More information about the CMake
mailing list