From 4d457ba1adda4b693eb24db0e6b39a441d245ff0 Mon Sep 17 00:00:00 2001 From: Eric Berberich Date: Thu, 21 Apr 2011 08:47:46 +0000 Subject: [PATCH] fix to build demos and example properly, and even out-of-source now --- Installation/demo/CMakeLists.txt | 14 +++++++++++--- Installation/examples/CMakeLists.txt | 12 ++++++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Installation/demo/CMakeLists.txt b/Installation/demo/CMakeLists.txt index b2a6b74883a..632b2745fb9 100644 --- a/Installation/demo/CMakeLists.txt +++ b/Installation/demo/CMakeLists.txt @@ -17,9 +17,17 @@ foreach( entry ${list} ) if ( IS_DIRECTORY ${entry} ) if ( EXISTS ${entry}/CMakeLists.txt ) - message( STATUS "Configuring ${entry} demo" ) - add_subdirectory( ${entry} ) - endif() + + message( STATUS "Configuring demo in ${entry}" ) + + if( NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") # out-of-source + string( REGEX REPLACE "${CMAKE_SOURCE_DIR}/.*/demo/" "" DEMO_DIR "${entry}" ) + make_directory(${CMAKE_BINARY_DIR}/demo/${DEMO_DIR}) + endif() + + add_subdirectory( ${entry} ${CMAKE_BINARY_DIR}/demo/${DEMO_DIR} ) + + Endif() endif() diff --git a/Installation/examples/CMakeLists.txt b/Installation/examples/CMakeLists.txt index f4587908a0c..26df99018a4 100644 --- a/Installation/examples/CMakeLists.txt +++ b/Installation/examples/CMakeLists.txt @@ -17,8 +17,16 @@ foreach( entry ${list} ) if ( IS_DIRECTORY ${entry} ) if ( EXISTS ${entry}/CMakeLists.txt ) - message( STATUS "Configuring ${entry} example" ) - add_subdirectory( ${entry} ) + + message( STATUS "Configuring examples in ${entry}" ) + + if( NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") # out-of-source + string( REGEX REPLACE "${CMAKE_SOURCE_DIR}/.*/examples/" "" DEMO_DIR "${entry}" ) + make_directory(${CMAKE_BINARY_DIR}/demo/${DEMO_DIR}) + endif() + + add_subdirectory( ${entry} ${CMAKE_BINARY_DIR}/examples/${DEMO_DIR} ) + endif() endif()