mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-11-30 21:13:49 -06:00
Propagate REQUIRED and QUIET according to parent level
If an optional package require further packages, those packages should not be marked as REQUIRED because CMake will then terminate the configuration if it is not found (although it is transitively optional). Conversely, we should be able to specify REQUIRED prerequisites for REQUIRED packages and have a failure cascade up to termination. This changeset allows us to specify REQUIRED or not in the list of prerequisites, and have OpmPackage sort of whether it should be honored or not.
This commit is contained in:
parent
ae727487f5
commit
3ff19f011a
@ -10,20 +10,13 @@
|
||||
# Copyright (C) 2012 Uni Research AS
|
||||
# This code is licensed under The GNU General Public License v3.0
|
||||
|
||||
# dune-common is only required if dune-istl is; the "required-ness" is
|
||||
# not transitive as far as CMake is concerned (i.e. if an optional package
|
||||
# requests a package to be required, the build will fail if it's not found)
|
||||
if (dune-istl_FIND_REQUIRED)
|
||||
set (_require_dune_common "REQUIRED")
|
||||
endif (dune-istl_FIND_REQUIRED)
|
||||
|
||||
include (OpmPackage)
|
||||
find_opm_package (
|
||||
# module name
|
||||
"dune-istl"
|
||||
|
||||
# required dependencies
|
||||
"dune-common ${_require_dune_common};
|
||||
"dune-common REQUIRED;
|
||||
SuperLU
|
||||
"
|
||||
# header to search for
|
||||
|
@ -10,20 +10,13 @@
|
||||
# Copyright (C) 2012 Uni Research AS
|
||||
# This code is licensed under The GNU General Public License v3.0
|
||||
|
||||
# dune-common is only required if dune-localfunctions is; the "required-ness" is
|
||||
# not transitive as far as CMake is concerned (i.e. if an optional package
|
||||
# requests a package to be required, the build will fail if it's not found)
|
||||
if (dune-localfunctions_FIND_REQUIRED)
|
||||
set (_require_dune_common "REQUIRED")
|
||||
endif (dune-localfunctions_FIND_REQUIRED)
|
||||
|
||||
include (OpmPackage)
|
||||
find_opm_package (
|
||||
# module name
|
||||
"dune-localfunctions"
|
||||
|
||||
# required dependencies
|
||||
"dune-common ${_require_dune_common}"
|
||||
"dune-common REQUIRED"
|
||||
# header to search for
|
||||
"dune/localfunctions/common/localbasis.hh"
|
||||
|
||||
|
@ -26,7 +26,6 @@
|
||||
# ${module}_LIBRARIES Directory of shared object files
|
||||
# ${module}_DEFINITIONS Defines that must be set to compile
|
||||
# ${module}_CONFIG_VARS List of defines that should be in config.h
|
||||
# ${module}_QUIET Verbosity of last find of this module
|
||||
# HAVE_${MODULE} Binary value to use in config.h
|
||||
#
|
||||
# Note: Arguments should be quoted, otherwise a list will spill into the
|
||||
@ -52,17 +51,27 @@ macro (append_found src dst)
|
||||
endmacro (append_found src dst)
|
||||
|
||||
macro (find_opm_package module deps header lib defs prog conf)
|
||||
# variables to pass on to other packages
|
||||
if (FIND_QUIETLY)
|
||||
set (${module}_QUIET "QUIET")
|
||||
else (FIND_QUIETLY)
|
||||
set (${module}_QUIET "")
|
||||
endif (FIND_QUIETLY)
|
||||
# in addition to accepting mod-ule_ROOT, we also accept the somewhat
|
||||
# more idiomatic MOD_ULE_ROOT variant
|
||||
string (TOUPPER "${module}" MODULE_UPPER)
|
||||
string (REPLACE "-" "_" MODULE "${MODULE_UPPER}")
|
||||
|
||||
# if someone else has included this test, don't do it again
|
||||
if (${${module}_FOUND})
|
||||
if (${${MODULE}_FOUND})
|
||||
return ()
|
||||
endif (${${module}_FOUND})
|
||||
endif (${${MODULE}_FOUND})
|
||||
|
||||
# variables to pass on to other packages
|
||||
if (${module}_FIND_QUIETLY)
|
||||
set (_${module}_quiet "QUIET")
|
||||
else (${module}_FIND_QUIETLY)
|
||||
set (_${module}_quiet "")
|
||||
endif (${module}_FIND_QUIETLY)
|
||||
if (${module}_FIND_REQUIRED)
|
||||
set (_${module}_required "REQUIRED")
|
||||
else (${module}_FIND_REQUIRED)
|
||||
set (_${module}_required "")
|
||||
endif (${module}_FIND_REQUIRED)
|
||||
|
||||
# see if there is a pkg-config entry for this package, and use those
|
||||
# settings as a starting point
|
||||
@ -73,11 +82,6 @@ macro (find_opm_package module deps header lib defs prog conf)
|
||||
set (${module}_DEFINITIONS ${PkgConf_${module}_CFLAGS_OTHER})
|
||||
set (${module}_LINKER_FLAG ${PkgConf_${module}_LDFLAGS_OTHER})
|
||||
|
||||
# in addition to accepting mod-ule_ROOT, we also accept the somewhat
|
||||
# more idiomatic MOD_ULE_ROOT variant
|
||||
string (TOUPPER ${module} MODULE_UPPER)
|
||||
string (REPLACE "-" "_" MODULE ${MODULE_UPPER})
|
||||
|
||||
# if the user hasn't specified any location, and it isn't found
|
||||
# in standard system locations either, then start to wander
|
||||
# about and look for it in proximity to ourself. Qt Creator likes
|
||||
@ -196,24 +200,37 @@ macro (find_opm_package module deps header lib defs prog conf)
|
||||
# list of necessities to build with the software
|
||||
set (${module}_INCLUDE_DIRS "${${module}_INCLUDE_DIR}")
|
||||
set (${module}_LIBRARIES "${${module}_LIBRARY}")
|
||||
set (_deps)
|
||||
# period because it should be something that evaluates to true
|
||||
# in find_package_handle_standard_args
|
||||
set (${module}_ALL_PREREQS ".")
|
||||
foreach (_dep IN ITEMS ${deps})
|
||||
separate_arguments (_args UNIX_COMMAND ${_dep})
|
||||
if (_args)
|
||||
find_and_append_package_to (${module} ${_args} ${${module}_QUIET})
|
||||
list (GET _args 0 _name_only)
|
||||
list (APPEND _deps ${_name_only})
|
||||
else (_args)
|
||||
separate_arguments (_${module}_args UNIX_COMMAND ${_dep})
|
||||
if (_${module}_args)
|
||||
# keep REQUIRED in the arguments only if we were required ourself
|
||||
# "required-ness" is not transitive as far as CMake is concerned
|
||||
# (i.e. if an optional package requests a package to be required,
|
||||
# the build will fail if it's not found)
|
||||
string (REPLACE "REQUIRED" "${_${module}_required}" _args_req "${_${module}_args}")
|
||||
find_and_append_package_to (${module} ${_args_req} ${_${module}_quiet})
|
||||
list (GET _${module}_args 0 _name_only)
|
||||
string (TOUPPER "${_name_only}" _NAME_ONLY)
|
||||
string (REPLACE "-" "_" _NAME_ONLY "${_NAME_ONLY}")
|
||||
# check manually if it was found if REQUIRED; otherwise poison the
|
||||
# dependency list which is checked later (so that it will fail)
|
||||
if (("${_${module}_args}" MATCHES "REQUIRED") AND NOT ${_NAME_ONLY}_FOUND)
|
||||
list (APPEND ${module}_ALL_PREREQS "${_name_only}-NOTFOUND")
|
||||
endif ()
|
||||
else ()
|
||||
message (WARNING "Empty dependency in find module for ${module} (check for trailing semi-colon)")
|
||||
endif (_args)
|
||||
endif ()
|
||||
endforeach (_dep)
|
||||
|
||||
# since find_and_append_package_to is a macro, this variable have
|
||||
# probably been overwritten (due to its common name); it is now
|
||||
# this module's last dependency instead of the name of the module
|
||||
# itself, so it must be restored
|
||||
string (TOUPPER ${module} MODULE_UPPER)
|
||||
string (REPLACE "-" "_" MODULE ${MODULE_UPPER})
|
||||
string (TOUPPER "${module}" MODULE_UPPER)
|
||||
string (REPLACE "-" "_" MODULE "${MODULE_UPPER}")
|
||||
|
||||
# compile with this option to avoid avalanche of warnings
|
||||
set (${module}_DEFINITIONS "${${module}_DEFINITIONS}")
|
||||
@ -263,7 +280,7 @@ macro (find_opm_package module deps header lib defs prog conf)
|
||||
# if the search is going to fail, then write these variables to
|
||||
# the console as well as a diagnostics
|
||||
if ((NOT (${module}_INCLUDE_DIR ${_and_lib_var} AND HAVE_${MODULE}))
|
||||
AND (${module}_FIND_REQUIRED OR NOT ${module}_FIND_QUIETLY))
|
||||
AND (_${module}_required OR NOT _${module}_quiet))
|
||||
if (DEFINED ${module}_DIR)
|
||||
message ("${module}_DIR = ${${module}_DIR}")
|
||||
elseif (DEFINED ${module}_ROOT)
|
||||
@ -272,11 +289,11 @@ macro (find_opm_package module deps header lib defs prog conf)
|
||||
message ("${MODULE}_ROOT = ${${MODULE}_ROOT}")
|
||||
endif (DEFINED ${module}_DIR)
|
||||
endif ((NOT (${module}_INCLUDE_DIR ${_and_lib_var} AND HAVE_${MODULE}))
|
||||
AND (${module}_FIND_REQUIRED OR NOT ${module}_FIND_QUIETLY))
|
||||
AND (_${module}_required OR NOT _${module}_quiet))
|
||||
find_package_handle_standard_args (
|
||||
${module}
|
||||
DEFAULT_MSG
|
||||
${module}_INCLUDE_DIR ${_lib_var} HAVE_${MODULE}
|
||||
${module}_INCLUDE_DIR ${_lib_var} HAVE_${MODULE} ${module}_ALL_PREREQS
|
||||
)
|
||||
|
||||
# allow the user to override these from user interface
|
||||
@ -286,6 +303,7 @@ macro (find_opm_package module deps header lib defs prog conf)
|
||||
# some genius that coded the FindPackageHandleStandardArgs figured out
|
||||
# that the module name should be in uppercase (?!)
|
||||
set (${module}_FOUND "${${MODULE_UPPER}_FOUND}")
|
||||
set (${MODULE}_FOUND "${${MODULE_UPPER}_FOUND}")
|
||||
|
||||
# print everything out if we're asked to
|
||||
if (${module}_DEBUG)
|
||||
@ -301,7 +319,6 @@ function (debug_find_vars module)
|
||||
message (STATUS "${module}_DEFINITIONS = ${${module}_DEFINITIONS}")
|
||||
message (STATUS "${module}_CONFIG_VARS = ${${module}_CONFIG_VARS}")
|
||||
message (STATUS "${module}_LINKER_FLAGS = ${${module}_LINKER_FLAGS}")
|
||||
message (STATUS "${module}_QUIET = ${${module}_QUIET}")
|
||||
string (TOUPPER ${module} MODULE)
|
||||
string (REPLACE "-" "_" MODULE ${MODULE})
|
||||
message (STATUS "HAVE_${MODULE} = ${HAVE_${MODULE}}")
|
||||
|
Loading…
Reference in New Issue
Block a user