Allow arbitrary clone directories and <prefix><module-name><postfix> build directories
This commit is contained in:
parent
b544bfe9cd
commit
9a278c32b1
@ -35,17 +35,21 @@ 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 <module-name>/<build-dir> 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 <build-dir>/<module-name>
|
||||
if(IS_DIRECTORY ${_parent_full_dir}/opm-common)
|
||||
set(opm-common_DIR "${_parent_full_dir}/opm-common}")
|
||||
endif()
|
||||
#Try if <module-name>/<build-dir> 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 <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}")
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
if(NOT IS_DIRECTORY ${opm-common_DIR})
|
||||
@ -53,6 +57,7 @@ if(NOT OPM_COMMON_ROOT)
|
||||
" opm-common_DIR is not a directory")
|
||||
endif()
|
||||
endif()
|
||||
message("opm-common_DIR=${opm-common_DIR}")
|
||||
find_package(opm-common REQUIRED)
|
||||
endif()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user