mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-16 20:24:48 -06:00
Merge pull request #1276 from blattms/cmakify-sibling-search
Cmakify sibling search
This commit is contained in:
commit
cdb8220c9b
@ -14,46 +14,43 @@
|
||||
# #
|
||||
###########################################################################
|
||||
|
||||
# Mandatory call to project
|
||||
project(opm-simulators CXX)
|
||||
|
||||
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)
|
||||
set( USE_OPENMP_DEFAULT OFF ) # Use of OpenMP is considered experimental
|
||||
|
||||
if(NOT OPM_COMMON_ROOT)
|
||||
find_package(opm-common QUIET)
|
||||
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)
|
||||
#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})
|
||||
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()
|
||||
endif()
|
||||
if(opm-common_DIR AND NOT IS_DIRECTORY ${opm-common_DIR})
|
||||
message(WARNING "Value ${opm-common_DIR} passed to variable"
|
||||
" opm-common_DIR is not a directory")
|
||||
endif()
|
||||
|
||||
if (opm-common_FOUND)
|
||||
include(OpmInit)
|
||||
else()
|
||||
unset(opm-common_FOUND)
|
||||
find_package(opm-common REQUIRED)
|
||||
|
||||
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()
|
||||
include(OpmInit)
|
||||
|
||||
|
||||
# not the same location as most of the other projects? this hook overrides
|
||||
|
Loading…
Reference in New Issue
Block a user