[CMake] add_custom_target doesn't create the rule
hurcan solter
hsolter at gmail.com
Thu Mar 24 20:31:04 EDT 2011
I have a custom command that generates some cpp files from definitions. It
goes like that;
set (TILE_INPUTS main dngn floor wall feat player gui icons)
foreach(tile_name ${TILE_INPUTS})
set(tile_txt "dc-${tile_name}.txt")
add_custom_command(
OUTPUT "tiledef-${tile_name}.cc"
COMMAND tilegen ${CMAKE_CURRENT_SOURCE_DIR}/rltiles/${tile_txt}
DEPENDS ${tile_txt}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/rltiles
)
list(APPEND TILEDEFINITONS "tiledef-${tile_name}.cc")
then I create the executable;
add_executable (crawl ${CRAWL_SOURCES} ${TILEDEFINITIONS})
This seems like the do the trick, problem is the generated files are in a
subdirectory
so at the compile phase it fails, I've gathered I need to add a custom
target to accomplish
that (From FAQ etc) so my CMakelists.txt look like
set (TILE_INPUTS main dngn floor wall feat player gui icons)
foreach(tile_name ${TILE_INPUTS})
set(tile_txt "dc-${tile_name}.txt")
add_custom_command(
OUTPUT "tiledef-${tile_name}.cc"
COMMAND tilegen ${CMAKE_CURRENT_SOURCE_DIR}/rltiles/${tile_txt}
DEPENDS ${tile_txt}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/rltiles
)
list(APPEND TILEDEFINITONS "tiledef-${tile_name}.cc")
endforeach()
add_custom_target(tile_target DEPENDS ${TILEDEFINITIONS})
add_executable (crawl ${CRAWL_SOURCES})
add_dependencies(crawl tile_target)
I can see tile_target generated when I load the project to my ide(MSVC)
but rule shows as empty, Do I need to add a custom target for every file
generated ? That sounds like very tedious. or Is it entirely different
problem...
Thanks in advance
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110325/3a7c260d/attachment.htm>
More information about the CMake
mailing list