From a26cec6a6c37e04c983fac987df24db3320f805f Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Fri, 15 Sep 2017 16:49:48 +0200 Subject: [PATCH] Allow arbitrary clone directories and build directories --- CMakeLists.txt | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 086271a60..e688d7053 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,15 +35,19 @@ if(NOT OPM_COMMON_ROOT) get_filename_component(_leaf_dir_name ${PROJECT_BINARY_DIR} NAME) get_filename_component(_parent_full_dir ${PROJECT_BINARY_DIR} DIRECTORY) get_filename_component(_parent_dir_name ${_parent_full_dir} NAME) - if(_parent_dir_name STREQUAL CMAKE_PROJECT_NAME) - #looks like / is used - get_filename_component(_modules_dir ${_parent_full_dir} DIRECTORY) - if(IS_DIRECTORY ${_modules_dir}/opm-common/${_leaf_dir_name}) - set(opm-common_DIR ${_modules_dir}/opm-common/${_leaf_dir_name}) - endif() - elseif(_leaf_dir_name STREQUAL CMAKE_PROJECT_NAME) - # we assume / - if(IS_DIRECTORY ${_parent_full_dir}/opm-common) + #Try if / is used + get_filename_component(_modules_dir ${_parent_full_dir} DIRECTORY) + if(IS_DIRECTORY ${_modules_dir}/opm-common/${_leaf_dir_name}) + set(opm-common_DIR ${_modules_dir}/opm-common/${_leaf_dir_name}) + else() + string(REPLACE ${PROJECT_NAME} opm-common _opm_common_leaf ${_leaf_dir_name}) + message("_opm_common_leaf=${_opm_common_leaf}") + if(NOT _leaf_dir_name STREQUAL _opm_common_leaf + AND IS_DIRECTORY ${_parent_full_dir}/${_opm_common_leaf}) + # We are using build directories named + set(opm-common_DIR ${_parent_full_dir}/${_opm_common_leaf}) + elseif(IS_DIRECTORY ${_parent_full_dir}/opm-common) + # All modules are in a common build dir set(opm-common_DIR "${_parent_full_dir}/opm-common}") endif() endif()