[Cmake] out of source builds

Doug Henry doug_henry at xontech.com
Tue, 06 Jan 2004 14:43:42 -0500


I am trying to use the out of source build capability.  I have a main
source tree and then a few others with different build options.  I have
some auto-generated code using the cmake script below.  Basically,
gentypes is built and then it is used to generate a header file
(Types.h).  gentypes is built correctly, but when it tries to create the
header, it tries running gentypes from the main source tree and not from
the current source folder.  Is this a bug?

INCLUDE_DIRECTORIES(${CMAKE_HOME_DIRECTORY}/libdsw/include
$(TOOLS_DIR)/local/include/fox-1.1)
ADD_EXECUTABLE(gentypes gentypes.cpp)
TARGET_LINK_LIBRARIES(gentypes dsw FOX-1.1 xmlwrapp xslt xml2 iconv z)

ADD_CUSTOM_COMMAND (
	OUTPUT ${CMAKE_HOME_DIRECTORY}/libcommon/include/Types.h
	DEPENDS gentypes
	COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/gentypes
	ARGS ${CMAKE_HOME_DIRECTORY}/libcommon/include/Types.h
${CMAKE_HOME_DIRECTORY}/data/types.xml
)

ADD_CUSTOM_TARGET(header ALL DEPENDS
${CMAKE_HOME_DIRECTORY}/libcommon/include/Types.h)