mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Drop support for OPM_COMMON_ROOT.
Users should either rely in sibling search, use opm-common_DIR, or set CMAKE_PREFIX_PATH correctly to find opm-common.
This commit is contained in:
@@ -19,83 +19,40 @@ project(opm-simulators CXX)
|
|||||||
|
|
||||||
cmake_minimum_required (VERSION 2.8)
|
cmake_minimum_required (VERSION 2.8)
|
||||||
|
|
||||||
set( OPM_COMMON_ROOT "" CACHE PATH "Root directory containing OPM related cmake modules")
|
|
||||||
option(SIBLING_SEARCH "Search for other modules in sibling directories?" ON)
|
option(SIBLING_SEARCH "Search for other modules in sibling directories?" ON)
|
||||||
set( USE_OPENMP_DEFAULT OFF ) # Use of OpenMP is considered experimental
|
set( USE_OPENMP_DEFAULT OFF ) # Use of OpenMP is considered experimental
|
||||||
|
|
||||||
if(OPM_COMMON_ROOT AND opm-common_DIR)
|
if(SIBLING_SEARCH AND NOT opm-common_DIR)
|
||||||
message(WARNING "Both the variables OPM_COMMON_ROOT and opm-common_DIR are set. "
|
# guess the sibling dir
|
||||||
"Will use opm-common_DIR")
|
get_filename_component(_leaf_dir_name ${PROJECT_BINARY_DIR} NAME)
|
||||||
set(OPM_COMMON_ROOT "OPM_COMMON_ROOT-NOTFOUND")
|
get_filename_component(_parent_full_dir ${PROJECT_BINARY_DIR} DIRECTORY)
|
||||||
endif()
|
get_filename_component(_parent_dir_name ${_parent_full_dir} NAME)
|
||||||
|
#Try if <module-name>/<build-dir> is used
|
||||||
if(NOT OPM_COMMON_ROOT)
|
get_filename_component(_modules_dir ${_parent_full_dir} DIRECTORY)
|
||||||
if(SIBLING_SEARCH AND NOT opm-common_DIR)
|
if(IS_DIRECTORY ${_modules_dir}/opm-common/${_leaf_dir_name})
|
||||||
# guess the sibling dir
|
set(opm-common_DIR ${_modules_dir}/opm-common/${_leaf_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_dir_name ${_parent_full_dir} NAME)
|
|
||||||
#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()
|
else()
|
||||||
if(NOT IS_DIRECTORY ${opm-common_DIR})
|
string(REPLACE ${PROJECT_NAME} opm-common _opm_common_leaf ${_leaf_dir_name})
|
||||||
message(WARNING "Value ${opm-common_DIR} passed to variable"
|
if(NOT _leaf_dir_name STREQUAL _opm_common_leaf
|
||||||
" opm-common_DIR is not a directory")
|
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()
|
||||||
endif()
|
endif()
|
||||||
find_package(opm-common REQUIRED)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (opm-common_FOUND)
|
|
||||||
include(OpmInit)
|
|
||||||
else()
|
else()
|
||||||
if(OPM_COMMON_ROOT)
|
if(NOT IS_DIRECTORY ${opm-common_DIR})
|
||||||
message(WARNING "Setting OPM_COMMON_ROOT is deprecated. Please either "
|
message(WARNING "Value ${opm-common_DIR} passed to variable"
|
||||||
"set opm-common_DIR instead or rely on sibling build")
|
" opm-common_DIR is not a directory")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
unset(opm-common_FOUND)
|
|
||||||
|
|
||||||
if (NOT OPM_COMMON_ROOT AND SIBLING_SEARCH)
|
|
||||||
set(OPM_COMMON_ROOT ${PROJECT_SOURCE_DIR}/../opm-common)
|
|
||||||
endif()
|
|
||||||
if (OPM_COMMON_ROOT)
|
|
||||||
list( APPEND CMAKE_MODULE_PATH "${OPM_COMMON_ROOT}/cmake/Modules")
|
|
||||||
include (OpmInit OPTIONAL RESULT_VARIABLE OPM_INIT)
|
|
||||||
set( OPM_MACROS_ROOT ${OPM_COMMON_ROOT} )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (NOT OPM_INIT)
|
|
||||||
message( "" )
|
|
||||||
message( " /---------------------------------------------------------------------------------\\")
|
|
||||||
message( " | Could not locate the opm build macros. The opm build macros |")
|
|
||||||
message( " | are in a separate repository - instructions to proceed: |")
|
|
||||||
message( " | |")
|
|
||||||
message( " | 1. Clone the repository: git clone git@github.com:OPM/opm-common.git |")
|
|
||||||
message( " | |")
|
|
||||||
message( " | 2. Run cmake in the current project with -DOPM_COMMON_ROOT=<path>/opm-common |")
|
|
||||||
message( " | |")
|
|
||||||
message( " \\---------------------------------------------------------------------------------/")
|
|
||||||
message( "" )
|
|
||||||
message( FATAL_ERROR "Could not find OPM Macros")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
find_package(opm-common REQUIRED)
|
||||||
|
|
||||||
|
include(OpmInit)
|
||||||
|
|
||||||
|
|
||||||
# not the same location as most of the other projects? this hook overrides
|
# not the same location as most of the other projects? this hook overrides
|
||||||
macro (dir_hook)
|
macro (dir_hook)
|
||||||
|
|||||||
Reference in New Issue
Block a user