Hi,

I have a generator which is given a data file "data.txt" and then generates an 
include file "gen.h".
"gen.h" is told to CMake to be a generated file.
"gen.h" is added to the library.

I thought CMake would find the custom command and generate the file "gen.h"
Instead an error occurs, this is the output:

-- Configuring done
CMake Error in libfoo.so/CMakeLists.txt:
  Cannot find source file "gen.h".  Tried extensions .c .C .c++ .cc
  .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp .hxx .in .txx

Why doesn't CMake generate the file?


Example code:
------------------
# Set variable containing all source files
SET( SRCS
  foo1.c
)

# Tell CMake that "gen.h" is a generated file
SET_SOURCE_FILE_PROPERTIES( gen.h PROPERTIES GENERATED 1 )

# Define custom command to generate "gen.h"
ADD_CUSTOM_COMMAND(
  OUTPUT  gen.h
  COMMAND echo "this command would generate 'gen.h' from data.txt"
  DEPENDS data.txt
)

# Define to build a target shared object library named "libfoo.so" from the 
source files "${SRCS}".
# The file "foo1.c" depends on the generated include file "gen.h"
ADD_LIBRARY( foo SHARED ${SRCS} gen.h )
------------------

PS: I'm using CMake V2.6, if this might be useful to know.

Best Regards,
Joerg

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to