[CMake] Custom compile command?

Bill Hoffman bill.hoffman at kitware.com
Sat Jun 6 08:43:21 EDT 2009


Bob Tanner wrote:
> 
> On Jun 5, 2009, at 11:00 PM, Bill Hoffman wrote:
> 
>>> Works fine on osx+cmake version 2.6-patch 4 BUT fails on 
>>> ubuntu+hardy+cmake version 2.4-patch 7
> 
>>>
>> No, should work for both.   How does it fail on 2.4?
> 
> 
> Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp 
> .hxx .in .txx
> CMake Error: Cannot find source file 
> "/tmp/osx-branch/Vanilla/robots/commands_puck.c" for target "puck"
> 
> ### Whack-a-do for making ntserv/commands.c into robots/commands_puck.o
> set(COMMANDS_TYPE PUCK)
> configure_file(
>         ${CMAKE_CURRENT_SOURCE_DIR}/commands.c.cmake
>         ${CMAKE_CURRENT_BINARY_DIR}/commands_puck.c
> )
> 
> ### Equivalent to PUCK_OBJS in Makefile.in
> SET (puck_SOURCES
>         puck.c
>         puckmove.c
>         commands_puck.c
>         roboshar.c
> )
> 
> $ cat commands.c.cmake
> #define ${COMMANDS_TYPE}
> #include "${CMAKE_CURRENT_SOURCE_DIR}/../ntserv/commands.c"
> 
> As previously stated, works fine on osx+cmake version 2.6-patch 4
> 
> I'm pbuilder'n jaunty+cmake-2.6 to test there as well.
> 

You should use the full path to the files like this:

set(puck_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/commands_puck.c)

-Bill


More information about the CMake mailing list