[CMake] Xcode generator

Tobias Rudolph tobias.rudolph at artorg.unibe.ch
Wed Apr 1 05:53:53 EDT 2009


Hi All,

I have a problem with compiled CUDA source code and the Xcode  
generator. The behavior can be demonstrated using this simple example:

I have a file called "main.template":
----
#include <iostream>

int main()
{
     std::cout << "Hello world!\n";
     return 0;
}
----

my CMakeLists.txt looks like this:
----
project( XcodeTest )
cmake_minimum_required( VERSION 2.6 )

get_filename_component( TEMPLATE main.template ABSOLUTE )
add_custom_command( OUTPUT main.cpp
   COMMAND cp
   ARGS ${TEMPLATE} main.cpp
   DEPENDS main.template
)
set_source_files_properties( main.cpp PROPERTIES GENERATED TRUE )
add_executable( program main.cpp main.template )
----

As you can see, when a rebuild is done, the template gets copied to  
"main.cpp" which in turn is compiled and linked. This works great in  
Xcode. But, whenever I change the template, i.e. my CUDA sources, I  
have to run the build twice to make the changes appear in the test  
program. It looks like the custom command is executed during the first  
run and the generated file gets compiled in the second.

Has anyone ever seen this?


cheers,
Tobias


More information about the CMake mailing list