[CMake] Generated files and subdirectories

Micha Renner Micha.Renner at t-online.de
Fri Nov 6 11:03:44 EST 2009


Am Freitag, den 06.11.2009, 07:09 -0800 schrieb Tyler Roscoe:
> On Fri, Nov 06, 2009 at 09:10:13AM +0100, Micha Renner wrote:
> > Unfortunatelly this generates the make error message:
> > "There is no rule to generate the target: Name of the generated
> > file" (Here tm18.c see below)
> > 
> > ------------------------------------------
> > The CMakeLists.txt files
> > 
> > In mainDirectory I have the following CMakeLists.txt file
> > 
> > PROJECT(MainProj)
> > 
> > ADD_SUBDIRECTORY(src2)
> > ADD_SUBDIRECTORY(src)
> 
> > In src2 the CMakeLists.txt file looks like this:
> >
> > ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/tm18.c
> > 		COMMAND ${CMAKE_BINARY_DIR}/generator tm18
> > 		DEPENDS ${CMAKE_SOURCE_DIR}/src/tm
> > 		COMMENT "...run")
> > ADD_CUSTOM_TARGET(targetAdd ALL DEPENDS ${CMAKE_BINARY_DIR}/tm18.c)
> > 
> > and in src2 I have the following CMakeLists.txt file
> > 
> > SET(_src CTest.c ${CMAKE_BINARY_DIR}/tm18.c)
> > 
> > ADD_EXECUTABLE(${_targetname} ${_src})
> > 
> > SET_SOURCE_FILES_PROPERTIES(${CMAKE_BINARY_DIR}/tm18.c PROPERTIES
> > GENERATED 1)
> 
> I think the problem is that the custom_command in src2 is in a different
> "context" than the add_executable() where you reference tm18.c. I think
> there is a bug and/or a discussion from a few months ago about this
> topic but I don't remember any specifics unfortunately.
Aha, bad.
> 
> Try moving your custom_command into the CMakeLists for src and see if
> that works. 
Yes this works.
> If it does, you can try reorganizing things. If it doesn't,
> you can hope someone smarter than me has an answer :).
No, it is okay. Thank you

Micha


> 
> tyler
> 
> 




More information about the CMake mailing list