From 2be16e8e618c82990e710f4d0a385975a85f681e Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Wed, 20 Mar 2013 23:36:45 +0100 Subject: [PATCH] Search in build directories named similarly to ours Assume that a build that uses an out-of-source subdir, uses modules with the same last component as ours. --- cmake/Modules/OpmPackage.cmake | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/cmake/Modules/OpmPackage.cmake b/cmake/Modules/OpmPackage.cmake index 1c6b9ab3..1e4c991c 100644 --- a/cmake/Modules/OpmPackage.cmake +++ b/cmake/Modules/OpmPackage.cmake @@ -93,9 +93,24 @@ macro (find_opm_package module deps header lib defs prog conf) set (_guess_bin_only "../${module}-build" "../${_module_lower}-build" - "../../${module}/build-cmake" - "../../${_module_lower}/build-cmake" ) + # try to figure out whether we are in a subdir build tree, and attempt + # to put the same name as the appropriate build tree for the module + get_filename_component (_build_dir "${CMAKE_CURRENT_BINARY_DIR}" NAME) + + # don't bother if we are in a project specific directory already + # (assuming no-one wants to name the build dir after another module!) + if ("${_build_dir}" STREQUAL "${PROJECT_NAME}") + set (_build_dir "") + endif ("${_build_dir}" STREQUAL "${PROJECT_NAME}") + + # look in similar dirs for the other module + list (APPEND _guess_bin_only + "../../${module}/${_build_dir}" + "../../${_module_lower}/${_build_dir}" + ) + + # generate items that are in the build, not source dir set (_guess_bin) foreach (_item IN ITEMS ${_guess} ${_guess_bin_only}) list (APPEND _guess_bin "${PROJECT_BINARY_DIR}/${_item}")