Christoph Cullmann wrote:
Am Mittwoch 14 Mai 2008 16:57:22 schrieben Sie:
Would it work to use ctest in a custom comand to build the generated
source files?
I'm thinking something similar to how the VTK Examples directory is
built as a separate project.
Hmm, is it then possible that other targets depend on the result objects or
libs build by ctest? And how are flags passed over and all that?
See attached CMakeLists.txt file (modified from VTK examples) that shows
how to do that (dependencies, passing flags, etc..)
It would give you the chance to do a glob (or whatever you had in mind)
at build time to gather up the source files to compile into a library.
It doesn't include your custom command for generating the sources.
Clint
SET(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin)
SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin)
IF(CMAKE_CONFIGURATION_TYPES)
SET(sub_CONFIG_TYPE -C "${CMAKE_CFG_INTDIR}")
ELSE(CMAKE_CONFIGURATION_TYPES)
SET(sub_CONFIG_TYPE)
ENDIF(CMAKE_CONFIGURATION_TYPES)
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sub-fake
COMMAND ${CMAKE_CTEST_COMMAND}
ARGS ${sub_CONFIG_TYPE}
--build-and-test
${CMAKE_CURRENT_SOURCE_DIR}/sub # dir containing
CMakeLists.txt file
# which could
probably do
# a glob to find
sources
${CMAKE_CURRENT_BINARY_DIR}/sub-build # where to
build it
--build-noclean
--build-two-config
--build-project sub # name of library from
sub/CMakeLists.txt
--build-generator ${CMAKE_GENERATOR}
--build-makeprogram ${CMAKE_MAKE_PROGRAM}
--build-options
# put compiled library where we want it
-DLIBRARY_OUTPUT_PATH:PATH=${LIBRARY_OUTPUT_PATH}
# can/should add other options such as compilers,
# build type, compile flags, etc ...
)
ADD_CUSTOM_TARGET(sub-target ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/sub-fake)
INCLUDE_DIRECTORIES(sub)
ADD_EXECUTABLE(main main.cpp)
TARGET_LINK_LIBRARIES(main ${LIBRARY_OUTPUT_PATH}/libsub.a) # full path for
dependencies
ADD_DEPENDENCIES(main sub-target) # make sure sub is built before building
executable
_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake