Merge pull request #215 from rolk/215_no_sys
Follow the principle of least surprise when locating modules
This commit is contained in:
commit
8c8295cae6
@ -20,6 +20,14 @@ else (FIND_QUIETLY)
|
||||
set (ERT_QUIET "")
|
||||
endif (FIND_QUIETLY)
|
||||
|
||||
# if a directory has been specified by the user, then don't go look
|
||||
# in the system directories as well
|
||||
if (ERT_ROOT)
|
||||
set (_no_default_path "NO_DEFAULT_PATH")
|
||||
else (ERT_ROOT)
|
||||
set (_no_default_path "")
|
||||
endif (ERT_ROOT)
|
||||
|
||||
# ERT doesn't have any config-mode file, so we need to specify the root
|
||||
# directory in its own variable
|
||||
find_path (ERT_ECL_INCLUDE_DIR
|
||||
@ -28,6 +36,7 @@ find_path (ERT_ECL_INCLUDE_DIR
|
||||
PATHS "../ert"
|
||||
PATH_SUFFIXES "devel/libecl/include/" "include"
|
||||
DOC "Path to ERT Eclipse library header files"
|
||||
${_no_default_path}
|
||||
)
|
||||
find_path (ERT_UTIL_INCLUDE_DIR
|
||||
NAMES "ert/util/stringlist.h"
|
||||
@ -35,6 +44,7 @@ find_path (ERT_UTIL_INCLUDE_DIR
|
||||
PATHS "../ert"
|
||||
PATH_SUFFIXES "devel/libert_util/include/" "include"
|
||||
DOC "Path to ERT Eclipse library header files"
|
||||
${_no_default_path}
|
||||
)
|
||||
find_path (ERT_GEN_INCLUDE_DIR
|
||||
NAMES "ert/util/int_vector.h"
|
||||
@ -43,6 +53,7 @@ find_path (ERT_GEN_INCLUDE_DIR
|
||||
"${PROJECT_BINARY_DIR}/../ert/devel"
|
||||
PATH_SUFFIXES "libert_util/include/" "include"
|
||||
DOC "Path to ERT generated library header files"
|
||||
${_no_default_path}
|
||||
)
|
||||
|
||||
# need all of these libraries
|
||||
@ -56,6 +67,7 @@ find_library (ERT_LIBRARY_ECL
|
||||
"${PROJECT_BINARY_DIR}/../ert/devel"
|
||||
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
||||
DOC "Path to ERT Eclipse library archive/shared object files"
|
||||
${_no_default_path}
|
||||
)
|
||||
find_library (ERT_LIBRARY_GEOMETRY
|
||||
NAMES "ert_geometry"
|
||||
@ -64,6 +76,7 @@ find_library (ERT_LIBRARY_GEOMETRY
|
||||
"${PROJECT_BINARY_DIR}/../ert/devel"
|
||||
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
||||
DOC "Path to ERT Geometry library archive/shared object files"
|
||||
${_no_default_path}
|
||||
)
|
||||
find_library (ERT_LIBRARY_UTIL
|
||||
NAMES "ert_util"
|
||||
@ -72,6 +85,7 @@ find_library (ERT_LIBRARY_UTIL
|
||||
"${PROJECT_BINARY_DIR}/../ert/devel"
|
||||
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
||||
DOC "Path to ERT Utilities library archive/shared object files"
|
||||
${_no_default_path}
|
||||
)
|
||||
# the "library" found here is actually a list of several files
|
||||
list (APPEND ERT_INCLUDE_DIR
|
||||
|
@ -77,22 +77,30 @@ set (SuiteSparse_EXTRA_LIBS ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} ${MATH_LIBRARY
|
||||
list (APPEND SuiteSparse_SEARCH_PATH "/usr") # Linux
|
||||
list (APPEND SuiteSparse_SEARCH_PATH "/opt/local") # MacOS X
|
||||
|
||||
# if we don't get any further clues about where to look, then start
|
||||
# roaming around the system
|
||||
set (_no_default_path "")
|
||||
|
||||
# pick up paths from the environment if specified there; these replace the
|
||||
# pre-defined paths so that we don't accidentially pick up old stuff
|
||||
if (NOT $ENV{SuiteSparse_DIR} STREQUAL "")
|
||||
set (SuiteSparse_SEARCH_PATH "$ENV{SuiteSparse_DIR}")
|
||||
set (_no_default_path "NO_DEFAULT_PATH")
|
||||
endif (NOT $ENV{SuiteSparse_DIR} STREQUAL "")
|
||||
if (${SuiteSparse_DIR})
|
||||
set (SuiteSparse_SEARCH_PATH "${SuiteSparse_DIR}")
|
||||
set (_no_default_path "NO_DEFAULT_PATH")
|
||||
endif (${SuiteSparse_DIR})
|
||||
# CMake uses _DIR suffix as default for config-mode files; it is unlikely
|
||||
# that we are building SuiteSparse ourselves; use _ROOT suffix to specify
|
||||
# location to pre-canned binaries
|
||||
if (NOT $ENV{SuiteSparse_ROOT} STREQUAL "")
|
||||
set (SuiteSparse_SEARCH_PATH "$ENV{SuiteSparse_ROOT}")
|
||||
set (_no_default_path "NO_DEFAULT_PATH")
|
||||
endif (NOT $ENV{SuiteSparse_ROOT} STREQUAL "")
|
||||
if (${SuiteSparse_ROOT})
|
||||
set (SuiteSparse_SEARCH_PATH "${SuiteSparse_ROOT}")
|
||||
set (_no_default_path "NO_DEFAULT_PATH")
|
||||
endif (${SuiteSparse_ROOT})
|
||||
|
||||
# transitive closure of dependencies; after this SuiteSparse_MODULES is the
|
||||
@ -135,6 +143,7 @@ find_library (config_LIBRARY
|
||||
NAMES suitesparseconfig
|
||||
PATHS ${SuiteSparse_SEARCH_PATH}
|
||||
PATH_SUFFIXES ".libs" "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}" "lib/ufsparse"
|
||||
${_no_default_path}
|
||||
)
|
||||
if (config_LIBRARY)
|
||||
list (APPEND SuiteSparse_EXTRA_LIBS ${config_LIBRARY})
|
||||
@ -153,11 +162,13 @@ foreach (module IN LISTS SuiteSparse_MODULES)
|
||||
NAMES ${module}.h
|
||||
PATHS ${SuiteSparse_SEARCH_PATH}
|
||||
PATH_SUFFIXES "include" "include/suitesparse" "include/ufsparse"
|
||||
${_no_default_path}
|
||||
)
|
||||
find_library (${MODULE}_LIBRARY
|
||||
NAMES ${module}
|
||||
PATHS ${SuiteSparse_SEARCH_PATH}
|
||||
PATH_SUFFIXES "lib/.libs" "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}" "lib/ufsparse"
|
||||
${_no_default_path}
|
||||
)
|
||||
# start out by including the module itself; other dependencies will be added later
|
||||
set (${MODULE}_INCLUDE_DIRS ${${MODULE}_INCLUDE_DIR})
|
||||
|
@ -35,18 +35,20 @@ if(NOT BLAS_FOUND)
|
||||
return()
|
||||
endif(NOT BLAS_FOUND)
|
||||
|
||||
# look for header files, only at positions given by the user
|
||||
# look for files only at the positions given by the user if
|
||||
# an explicit path is specified
|
||||
if (SUPERLU_PREFIX OR SUPERLU_ROOT)
|
||||
set (_no_default_path "NO_DEFAULT_PATH")
|
||||
else (SUPERLU_PREFIX OR SUPERLU_ROOT)
|
||||
set (_no_default_path "")
|
||||
endif (SUPERLU_PREFIX OR SUPERLU_ROOT)
|
||||
|
||||
# look for header files
|
||||
find_path(SUPERLU_INCLUDE_DIR
|
||||
NAMES supermatrix.h
|
||||
PATHS ${SUPERLU_PREFIX} ${SUPERLU_ROOT}
|
||||
PATH_SUFFIXES "superlu" "include/superlu" "include" "SRC"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
||||
# look for header files, including default paths
|
||||
find_path(SUPERLU_INCLUDE_DIR
|
||||
NAMES supermatrix.h
|
||||
PATH_SUFFIXES "superlu" "include/superlu" "include" "SRC"
|
||||
${_no_default_path}
|
||||
)
|
||||
|
||||
# only search in architecture-relevant directory
|
||||
@ -54,18 +56,12 @@ if (CMAKE_SIZEOF_VOID_P)
|
||||
math (EXPR _BITS "8 * ${CMAKE_SIZEOF_VOID_P}")
|
||||
endif (CMAKE_SIZEOF_VOID_P)
|
||||
|
||||
# look for library, only at positions given by the user
|
||||
# look for library
|
||||
find_library(SUPERLU_LIBRARY
|
||||
NAMES "superlu_4.3" "superlu_4.2" "superlu_4.1" "superlu_4.0" "superlu_3.1" "superlu_3.0" "superlu"
|
||||
PATHS ${SUPERLU_PREFIX} ${SUPERLU_ROOT}
|
||||
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
||||
# look for library files, including default paths
|
||||
find_library(SUPERLU_LIBRARY
|
||||
NAMES "superlu_4.3" "superlu_4.2" "superlu_4.1" "superlu_4.0" "superlu_3.1" "superlu_3.0" "superlu"
|
||||
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
||||
${_no_default_path}
|
||||
)
|
||||
|
||||
# check version specific macros
|
||||
@ -163,5 +159,5 @@ endif(SUPERLU_FOUND)
|
||||
if(SUPERLU_FOUND)
|
||||
set(HAVE_SUPERLU 1)
|
||||
else(SUPERLU_FOUND)
|
||||
set(HAVE_SUPERLU 0)
|
||||
set(HAVE_SUPERLU "")
|
||||
endif(SUPERLU_FOUND)
|
||||
|
@ -61,6 +61,14 @@ set (_opm_proj_exemptions
|
||||
|
||||
# insert this boilerplate whenever we are going to find a new package
|
||||
macro (find_and_append_package_to prefix name)
|
||||
# special handling for Boost to avoid inadvertedly picking up system
|
||||
# libraries when we want our own version. this is done here because
|
||||
# having a custom Boost is common, but the logic to search only there
|
||||
# does not follow any particular convention.
|
||||
if (BOOST_ROOT AND NOT DEFINED Boost_NO_SYSTEM_PATHS)
|
||||
set (Boost_NO_SYSTEM_PATHS TRUE)
|
||||
endif (BOOST_ROOT AND NOT DEFINED Boost_NO_SYSTEM_PATHS)
|
||||
|
||||
# if we have specified a directory, don't revert to searching the
|
||||
# system default paths afterwards
|
||||
string (TOUPPER "${name}" NAME)
|
||||
@ -85,13 +93,7 @@ macro (find_and_append_package_to prefix name)
|
||||
# something which is done in our find module
|
||||
list (FIND _opm_proj_exemptions "${name}" _${name}_exempted)
|
||||
if ((NOT (_${name}_exempted EQUAL -1)) AND (DEFINED ${name}_DIR))
|
||||
# most often we are given the name to the build directory and this
|
||||
# is a sub-directory of the source tree
|
||||
if (${name}_DIR MATCHES "build")
|
||||
get_filename_component (${name}_ROOT "${${name}_DIR}" PATH)
|
||||
else (${name}_DIR MATCHES "build")
|
||||
set (${name}_ROOT "${${name}_DIR}")
|
||||
endif (${name}_DIR MATCHES "build")
|
||||
set (${name}_ROOT "${${name}_DIR}")
|
||||
# store this for later, in case we reconfigure
|
||||
set (${name}_ROOT "${${name}_ROOT}" CACHE LOCATION "Path to ${name}")
|
||||
# clear this to not use config mode
|
||||
|
@ -39,6 +39,9 @@
|
||||
|
||||
include (OpmFind)
|
||||
|
||||
option (SIBLING_SEARCH "Search sibling directories before system paths" ON)
|
||||
mark_as_advanced (SIBLING_SEARCH)
|
||||
|
||||
# append all items from src into dst; both must be *names* of lists
|
||||
macro (append_found src dst)
|
||||
foreach (_item IN LISTS ${src})
|
||||
@ -97,16 +100,53 @@ macro (find_opm_package module deps header lib defs prog conf)
|
||||
foreach (_item IN ITEMS ${_guess} ${_guess_bin_only})
|
||||
list (APPEND _guess_bin "${PROJECT_BINARY_DIR}/${_item}")
|
||||
endforeach (_item)
|
||||
set (_no_system "")
|
||||
else (NOT (${module}_DIR OR ${module}_ROOT OR ${MODULE}_ROOT))
|
||||
# start looking at the paths in this order
|
||||
set (_guess_bin
|
||||
${${module}_DIR}
|
||||
${${module}_ROOT}
|
||||
${${MODULE}_ROOT}
|
||||
)
|
||||
# when we look for the source, it may be that we have been specified
|
||||
# a build directory which is a sub-dir of the source, so we look in
|
||||
# the parent also
|
||||
set (_guess
|
||||
${${module}_DIR}
|
||||
${${module}_ROOT}
|
||||
${${MODULE}_ROOT}
|
||||
${${module}_DIR}/..
|
||||
${${module}_ROOT}/..
|
||||
${${MODULE}_ROOT}/..
|
||||
)
|
||||
# don't search the system paths! that would be dangerous; if there
|
||||
# is a problem in our own specified directory, we don't necessarily
|
||||
# want an old version that is left in one of the system paths!
|
||||
set (_no_system "NO_DEFAULT_PATH")
|
||||
endif (NOT (${module}_DIR OR ${module}_ROOT OR ${MODULE}_ROOT))
|
||||
|
||||
# by specifying _guess in the HINTS section, it gets searched before
|
||||
# the system locations as well. the CMake documentation has a cloudy
|
||||
# recommendation, but it ends up like this: if NO_DEFAULT_PATH is
|
||||
# specified, then PATHS is used. Otherwise, it looks in HINTS, then in
|
||||
# system paths, and the finally in PATHS (!)
|
||||
if (SIBLING_SEARCH)
|
||||
set (_guess_hints ${_guess})
|
||||
set (_guess_hints_bin ${_guess_bin})
|
||||
else (SIBLING_SEARCH)
|
||||
set (_guess_hints)
|
||||
set (_guess_hints_bin)
|
||||
endif (SIBLING_SEARCH)
|
||||
|
||||
# search for this include and library file to get the installation
|
||||
# directory of the package; hints are searched before the system locations,
|
||||
# paths are searched afterwards
|
||||
find_path (${module}_INCLUDE_DIR
|
||||
NAMES "${header}"
|
||||
PATHS ${_guess}
|
||||
HINTS ${${module}_DIR} ${${module}_ROOT} ${${MODULE}_ROOT} ${PkgConf_${module}_INCLUDE_DIRS}
|
||||
HINTS ${PkgConf_${module}_INCLUDE_DIRS} ${_guess_hints}
|
||||
PATH_SUFFIXES "include"
|
||||
${_no_system}
|
||||
)
|
||||
|
||||
# some modules are all in headers
|
||||
@ -117,8 +157,9 @@ macro (find_opm_package module deps header lib defs prog conf)
|
||||
find_library (${module}_LIBRARY
|
||||
NAMES "${lib}"
|
||||
PATHS ${_guess_bin}
|
||||
HINTS ${${module}_DIR} ${${module}_ROOT} ${${MODULE}_ROOT} ${PkgConf_${module}_LIBRARY_DIRS}
|
||||
HINTS ${PkgConf_${module}_LIBRARY_DIRS} ${_guess_hints_bin}
|
||||
PATH_SUFFIXES "lib" "lib/.libs" ".libs" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}" "build-cmake/lib"
|
||||
${_no_system}
|
||||
)
|
||||
else (NOT "${lib}" STREQUAL "")
|
||||
set (${module}_LIBRARY "")
|
||||
|
Loading…
Reference in New Issue
Block a user