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()