diff --git a/cmake/Modules/FindCXX11Features.cmake b/cmake/Modules/FindCXX11Features.cmake index 14df8fb6..ae89ed6b 100644 --- a/cmake/Modules/FindCXX11Features.cmake +++ b/cmake/Modules/FindCXX11Features.cmake @@ -389,4 +389,6 @@ if(CXX_FEATURES_MISSING) "Your compiler does not seem to implement the following features:\n" "${CXX_FEATURES_MISSING}") endif() +else () + set (CXX11FEATURES_FOUND TRUE) endif() diff --git a/cmake/Modules/FindCxaDemangle.cmake b/cmake/Modules/FindCxaDemangle.cmake index 9f480fa9..cf2d4828 100644 --- a/cmake/Modules/FindCxaDemangle.cmake +++ b/cmake/Modules/FindCxaDemangle.cmake @@ -15,3 +15,9 @@ int main(void){ int status; char *demangled = abi::__cxa_demangle( foo, 0, 0, &status ); }" HAVE_CXA_DEMANGLE) + +include (FindPackageHandleStandardArgs) +# prevent useless message from being displayed +set (FIND_PACKAGE_MESSAGE_DETAILS_CxaDemangle "[1][v()]" + CACHE INTERNAL "Details about finding CxaDemangle") +find_package_handle_standard_args (CxaDemangle DEFAULT_MSG HAVE_CXA_DEMANGLE) diff --git a/cmake/Modules/Finddune-istl.cmake b/cmake/Modules/Finddune-istl.cmake index cc6a064c..8c50d3d5 100644 --- a/cmake/Modules/Finddune-istl.cmake +++ b/cmake/Modules/Finddune-istl.cmake @@ -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 diff --git a/cmake/Modules/Finddune-localfunctions.cmake b/cmake/Modules/Finddune-localfunctions.cmake index 8a7fbd0e..38bcf805 100644 --- a/cmake/Modules/Finddune-localfunctions.cmake +++ b/cmake/Modules/Finddune-localfunctions.cmake @@ -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" diff --git a/cmake/Modules/OpmFind.cmake b/cmake/Modules/OpmFind.cmake index f77c6d31..a54e86d5 100644 --- a/cmake/Modules/OpmFind.cmake +++ b/cmake/Modules/OpmFind.cmake @@ -132,13 +132,15 @@ macro (find_and_append_package_to prefix name) # using config mode is better than using module (aka. find) mode # because then the package has already done all its probes and # stored them in the config file for us - if (${name}_DIR) - message (STATUS "Finding package ${name} using config mode") - find_package (${name} ${ARGN} NO_MODULE PATHS ${${name}_DIR} NO_DEFAULT_PATH) - else (${name}_DIR) - message (STATUS "Finding package ${name} using module mode") - find_package (${name} ${ARGN}) - endif (${name}_DIR) + if (NOT ${NAME}_FOUND) + if (${name}_DIR) + message (STATUS "Finding package ${name} using config mode") + find_package (${name} ${ARGN} NO_MODULE PATHS ${${name}_DIR} NO_DEFAULT_PATH) + else (${name}_DIR) + message (STATUS "Finding package ${name} using module mode") + find_package (${name} ${ARGN}) + endif (${name}_DIR) + endif (NOT ${NAME}_FOUND) # the variable "NAME" may be replaced during find_package (as this is # now a macro, and not a function anymore), so we must reinitialize diff --git a/cmake/Modules/OpmPackage.cmake b/cmake/Modules/OpmPackage.cmake index 90f94b52..28c96176 100644 --- a/cmake/Modules/OpmPackage.cmake +++ b/cmake/Modules/OpmPackage.cmake @@ -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}}") diff --git a/cmake/Modules/opm-material-prereqs.cmake b/cmake/Modules/opm-material-prereqs.cmake index bb0ca9bc..9a6ae4f7 100644 --- a/cmake/Modules/opm-material-prereqs.cmake +++ b/cmake/Modules/opm-material-prereqs.cmake @@ -14,6 +14,6 @@ set (opm-material_DEPS # compile with C++0x/11 support if available "CXX11Features REQUIRED" # DUNE dependency - "dune-common" - "dune-istl" + "dune-common REQUIRED" + "dune-istl REQUIRED" )