mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-11-29 04:23:48 -06:00
Added sibling search mechanism using ${PROJECT_BINARY_DIR} for opm-common
If sibling search is activated and opm-common_DIR is not set, then we try to determine the build directory layout from ${PROJECT_BINARY_DIR}. The following two possibilities are supported: + <modules-build-dir>/<project-name> + <project-name>/<build-dir> where <project-name> is the case sensitive module name (in this case opm-common). This results in the following search precedence: 1. User set opm-common_DIR 2. sibling directories search (if the directories exist) 3. Default (system) CMake search path
This commit is contained in:
parent
da86d1c0bd
commit
149d531c68
@ -24,6 +24,24 @@ option(SIBLING_SEARCH "Search for other modules in sibling directories?" ON)
|
||||
set( USE_OPENMP_DEFAULT OFF ) # Use of OpenMP is considered experimental
|
||||
|
||||
if(NOT OPM_COMMON_ROOT)
|
||||
if(SIBLING_SEARCH AND NOT opm-common_DIR)
|
||||
# guess the sibling dir
|
||||
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()
|
||||
endif()
|
||||
endif()
|
||||
find_package(opm-common QUIET)
|
||||
endif()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user