From 38bcff4e12a5983613dd5a33a55e37136028c981 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Wed, 13 Mar 2013 01:18:00 +0100 Subject: [PATCH] Allow subdir builds with dunecontrol dunecontrol will check for a dune.module file to regard the directory as containing the module. If we put this is a sub-dir of the source, it will get confused, so we shouldn't. There shouldn't be any conflicting use-cases, as one cannot have several modules in the sub- directory of one source (!?). --- cmake/Modules/DuneCompat.cmake | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cmake/Modules/DuneCompat.cmake b/cmake/Modules/DuneCompat.cmake index 1b16fbd8..a9cd6884 100644 --- a/cmake/Modules/DuneCompat.cmake +++ b/cmake/Modules/DuneCompat.cmake @@ -23,9 +23,15 @@ if (CMAKE_GENERATOR MATCHES "Unix Makefiles") endif (CMAKE_GENERATOR MATCHES "Unix Makefiles") # dunecontrol refuses to use a build tree as module directory unless -# there is a dune.module in it -if (NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR) +# there is a dune.module in it. however, if we are in a sub-dir. of +# the source, we are probably using dunecontrol with a --build-dir +# argument, and won't call dunecontrol from the parent (which is the +# source dir and most likely doesn't contain other projects) anyway, +# i.e. we only copy if we are truly out-of-source +string (LENGTH "${PROJECT_SOURCE_DIR}/" _src_dir_len) +string (SUBSTRING "${PROJECT_BINARY_DIR}/" 0 ${_src_dir_len} _proj_prefix) +if (NOT "${PROJECT_SOURCE_DIR}/" STREQUAL "${_proj_prefix}") execute_process (COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PROJECT_SOURCE_DIR}/dune.module ${PROJECT_BINARY_DIR}/dune.module ) -endif (NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR) +endif (NOT "${PROJECT_SOURCE_DIR}/" STREQUAL "${_proj_prefix}")