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 (!?).
This commit is contained in:
Roland Kaufmann 2013-03-13 01:18:00 +01:00
parent 54c89146d7
commit 38bcff4e12

View File

@ -23,9 +23,15 @@ if (CMAKE_GENERATOR MATCHES "Unix Makefiles")
endif (CMAKE_GENERATOR MATCHES "Unix Makefiles") endif (CMAKE_GENERATOR MATCHES "Unix Makefiles")
# dunecontrol refuses to use a build tree as module directory unless # dunecontrol refuses to use a build tree as module directory unless
# there is a dune.module in it # there is a dune.module in it. however, if we are in a sub-dir. of
if (NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR) # 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 execute_process (COMMAND
${CMAKE_COMMAND} -E copy_if_different ${PROJECT_SOURCE_DIR}/dune.module ${PROJECT_BINARY_DIR}/dune.module ${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}")