[CMake] Still problems with add_custom_command
Martin Kupke
martin.kupke at novero.com
Thu Oct 6 11:40:59 EDT 2011
Hi,
in my CMake project I have the need for a custom command that should be
processed in case a file is touched...that is the file the custom
command depends on. I already use the add_custom_command and
add_custom_target CMake instructions in my project, but always for
CMakeLists.txt files in subfolders where a static library will be build.
I think I have a real simple requirement, but I don't get it work up to now.
In my main project I have a subfolder with an own CMakeLists.txt file,
this subfolder is added to the main project by instruction
add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/subfolder" ).
Within the CMakeLists.txt in the subfolder I want to call a custom
command, so I added the following lines:
message( "My Tool started by custom command / target" )
add_custom_command( OUTPUT Out.txt
COMMAND tool.exe ${ToolConfig}
DEPENDS ${ToolConfig} )
add_custom_target( TOOL_CFG_OUT
DEPENDS Out.txt )
In my main project I added the custom target as dependency in the way:
add_dependencies( ${PROJECT_NAME} TOOL_CFG_OUT )
If I start the CMake process generating the Makefile I see the output of
my message "My Tool started by custom command / target", but the custom
command is never called.
I would like to have a build configuration that every time the dependend
file which is declared in the variable ${ToolConfig} is touched, the
command tool.exe is started.
What am I doing wrong? Do you have a sample for me how to start a custom
command every time a file is touched. I don't get it work.
Thanks in advance,
Martin...
More information about the CMake
mailing list