c++ - Trigger build when non-source files change -


using cmake added custom command top copy lua files source directory output directory when changed. command fired when visual studio decided build project (even though used pre_build custom command). visual studio decides build when source file (c++ in case) changes when change lua files not added output directory.

now in visual studio can change 'item type' in property pages of lua files 'does not participate in build' 'text'. in case visual studio trigger build when lua files change. how make sure cmake assigns correct item type lua files? (or there other solutions?)

the relevant parts of cmakelists.txt

set(lua_sources   "lua/initialization.lua")  source_group("lua" files ${lua_sources})  add_library(engine    ${lua_sources})  foreach(luafile ${lua_sources})   add_custom_command(     target engine     pre_build     command ${cmake_command}     args    -e        copy_if_different ${cmake_current_source_dir}/${luafile} ${executable_output_path}/debug/${luafile}) endforeach() 

===========================

for reference solution, closely inspired angew was

set(lua_sources   "lua/initialization.lua")  source_group("lua" files ${lua_sources})  set(lua_outputs "") foreach(luafile ${lua_sources})   list(append lua_outputs ${executable_output_path}/debug/${luafile})    endforeach()  add_custom_target(   lua   depends ${lua_outputs}   comment "copying lua files"   verbatim )  foreach(luafile ${lua_sources})   add_custom_command(     target lua     command ${cmake_command}     args    -e        copy_if_different ${cmake_current_source_dir}/${luafile}  endforeach() 

i had switch things around bit because else files not copied if newer. because of output directive in add_custom_command instead of target directive use now.

if cmakelist excerpt complete , engine target supposed serve placeholder copy lua sources, you're approaching problem wrong way. should use custom command + custom target combination instead, this:

set(lua_sources   "lua/initialization.lua")  source_group("lua" files ${lua_sources})  set(lua_outputs "") foreach(luafile ${lua_sources})   add_custom_command(     output ${executable_output_path}/debug/${luafile}     command ${cmake_command}     args -e copy_if_different       ${cmake_current_source_dir}/${luafile}       ${executable_output_path}/debug/${luafile}   )   list(append lua_outputs ${executable_output_path}/debug/${luafile}) endforeach()  add_custom_target(   engine   depends ${lua_outputs}   comment "copying lua files"   verbatim ) 

this cmakelist creates custom command copy each lua file, , custom target drive custom commands depending on outputs. dependency tracking work fine.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -