Allow arbitrary clone directories and <prefix><module-name><postfix> build directories

This commit is contained in:
Markus Blatt 2017-09-15 16:49:48 +02:00
parent 0b83f68cdc
commit a26cec6a6c

View File

@ -35,15 +35,19 @@ if(NOT OPM_COMMON_ROOT)
get_filename_component(_leaf_dir_name ${PROJECT_BINARY_DIR} NAME) get_filename_component(_leaf_dir_name ${PROJECT_BINARY_DIR} NAME)
get_filename_component(_parent_full_dir ${PROJECT_BINARY_DIR} DIRECTORY) get_filename_component(_parent_full_dir ${PROJECT_BINARY_DIR} DIRECTORY)
get_filename_component(_parent_dir_name ${_parent_full_dir} NAME) get_filename_component(_parent_dir_name ${_parent_full_dir} NAME)
if(_parent_dir_name STREQUAL CMAKE_PROJECT_NAME) #Try if <module-name>/<build-dir> is used
#looks like <module-name>/<build-dir> is used get_filename_component(_modules_dir ${_parent_full_dir} DIRECTORY)
get_filename_component(_modules_dir ${_parent_full_dir} DIRECTORY) if(IS_DIRECTORY ${_modules_dir}/opm-common/${_leaf_dir_name})
if(IS_DIRECTORY ${_modules_dir}/opm-common/${_leaf_dir_name}) set(opm-common_DIR ${_modules_dir}/opm-common/${_leaf_dir_name})
set(opm-common_DIR ${_modules_dir}/opm-common/${_leaf_dir_name}) else()
endif() string(REPLACE ${PROJECT_NAME} opm-common _opm_common_leaf ${_leaf_dir_name})
elseif(_leaf_dir_name STREQUAL CMAKE_PROJECT_NAME) message("_opm_common_leaf=${_opm_common_leaf}")
# we assume <build-dir>/<module-name> if(NOT _leaf_dir_name STREQUAL _opm_common_leaf
if(IS_DIRECTORY ${_parent_full_dir}/opm-common) AND IS_DIRECTORY ${_parent_full_dir}/${_opm_common_leaf})
# We are using build directories named <prefix><module-name><postfix>
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}") set(opm-common_DIR "${_parent_full_dir}/opm-common}")
endif() endif()
endif() endif()