diff --git a/cmake/Modules/FindERT.cmake b/cmake/Modules/FindERT.cmake index e911703d..87bf3e76 100644 --- a/cmake/Modules/FindERT.cmake +++ b/cmake/Modules/FindERT.cmake @@ -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 diff --git a/cmake/Modules/FindSuiteSparse.cmake b/cmake/Modules/FindSuiteSparse.cmake index 845571f5..11894218 100644 --- a/cmake/Modules/FindSuiteSparse.cmake +++ b/cmake/Modules/FindSuiteSparse.cmake @@ -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}) diff --git a/cmake/Modules/FindSuperLU.cmake b/cmake/Modules/FindSuperLU.cmake index b51086a1..ab9d513d 100644 --- a/cmake/Modules/FindSuperLU.cmake +++ b/cmake/Modules/FindSuperLU.cmake @@ -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 diff --git a/cmake/Modules/OpmPackage.cmake b/cmake/Modules/OpmPackage.cmake index 649402f1..b3413cc7 100644 --- a/cmake/Modules/OpmPackage.cmake +++ b/cmake/Modules/OpmPackage.cmake @@ -97,6 +97,29 @@ 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)) # search for this include and library file to get the installation @@ -105,8 +128,9 @@ macro (find_opm_package module deps header lib defs prog conf) 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} PATH_SUFFIXES "include" + ${_no_system} ) # some modules are all in headers @@ -117,8 +141,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} PATH_SUFFIXES "lib" "lib/.libs" ".libs" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}" "build-cmake/lib" + ${_no_system} ) else (NOT "${lib}" STREQUAL "") set (${module}_LIBRARY "")