From 5500dcfe8b1db441a1e8c1df4215a66dabc736f5 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Mon, 12 Jun 2017 21:13:58 +0200 Subject: [PATCH 1/3] Pass sibling dirs HINTS to find_package calls for opm-parser. These take precendence over the package registry where we have no control on which entry will be used. The registry is only the last resort. On some Linux version the most recently created package registry key will be used. Please not that an entry is only created for a build try that is not already in the registry. If there is already key, then not even the modification date of the key will be updated. This default behaviour might lead to strange mixes of build configurations. --- cmake/Modules/Findopm-parser.cmake | 52 ++++++++++++++++-------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/cmake/Modules/Findopm-parser.cmake b/cmake/Modules/Findopm-parser.cmake index 316539da29d..b04bbf17c4c 100644 --- a/cmake/Modules/Findopm-parser.cmake +++ b/cmake/Modules/Findopm-parser.cmake @@ -18,31 +18,6 @@ else () set (OPM_PARSER_QUIET "") endif () -find_package(opm-parser CONFIG) -if (opm-parser_FOUND) - find_package(ecl REQUIRED) - set(HAVE_OPM_PARSER 1) - # setting HAVE_ERT is a mega hack here, but some downstreams require it. - # Eventually projets should move on to properly handle dependencies and - # configurations, and Findopm-parser be deprecated - set(HAVE_ERT 1) - set(opm-parser_CONFIG_VARS HAVE_OPM_PARSER HAVE_REGEX HAVE_ERT) - set(opm-parser_LIBRARIES opmparser) - - find_package_handle_standard_args(opm-parser - DEFAULT_MSG - opm-parser_LIBRARIES HAVE_OPM_PARSER HAVE_ERT - ) - return () -endif () - -# use lowercase versions of the variables if those are set -if (opm-parser_ROOT) - set (OPM_PARSER_ROOT ${opm-parser_ROOT}) -endif () -if (opm_ROOT) - set (OPM_ROOT ${opm_ROOT}) -endif () # inherit "suite" root if not specifically set for this library if ((NOT OPM_PARSER_ROOT) AND OPM_ROOT) @@ -68,6 +43,33 @@ else () "${PROJECT_BINARY_DIR}/../../opm-parser/${BUILD_DIR_SUFFIX}") endif () + +find_package(opm-parser CONFIG HINTS ${_opm_parser_build}) +if (opm-parser_FOUND) + find_package(ecl REQUIRED) + set(HAVE_OPM_PARSER 1) + # setting HAVE_ERT is a mega hack here, but some downstreams require it. + # Eventually projets should move on to properly handle dependencies and + # configurations, and Findopm-parser be deprecated + set(HAVE_ERT 1) + set(opm-parser_CONFIG_VARS HAVE_OPM_PARSER HAVE_REGEX HAVE_ERT) + set(opm-parser_LIBRARIES opmparser) + + find_package_handle_standard_args(opm-parser + DEFAULT_MSG + opm-parser_LIBRARIES HAVE_OPM_PARSER HAVE_ERT + ) + return () +endif () + +# use lowercase versions of the variables if those are set +if (opm-parser_ROOT) + set (OPM_PARSER_ROOT ${opm-parser_ROOT}) +endif () +if (opm_ROOT) + set (OPM_ROOT ${opm_ROOT}) +endif () + # use this header as signature find_path (OPM_PARSER_INCLUDE_DIR NAMES "opm/parser/eclipse/Parser/Parser.hpp" From bea6eb9240108e3d2cd8e84cad74d64887129020 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Tue, 13 Jun 2017 10:21:54 +0200 Subject: [PATCH 2/3] Removed dead code. --- cmake/Modules/Findopm-parser.cmake | 135 +---------------------------- 1 file changed, 1 insertion(+), 134 deletions(-) diff --git a/cmake/Modules/Findopm-parser.cmake b/cmake/Modules/Findopm-parser.cmake index b04bbf17c4c..e4a0765a99c 100644 --- a/cmake/Modules/Findopm-parser.cmake +++ b/cmake/Modules/Findopm-parser.cmake @@ -59,139 +59,6 @@ if (opm-parser_FOUND) DEFAULT_MSG opm-parser_LIBRARIES HAVE_OPM_PARSER HAVE_ERT ) - return () endif () -# use lowercase versions of the variables if those are set -if (opm-parser_ROOT) - set (OPM_PARSER_ROOT ${opm-parser_ROOT}) -endif () -if (opm_ROOT) - set (OPM_ROOT ${opm_ROOT}) -endif () - -# use this header as signature -find_path (OPM_PARSER_INCLUDE_DIR - NAMES "opm/parser/eclipse/Parser/Parser.hpp" - HINTS "${OPM_PARSER_ROOT}" - PATHS ${_opm_parser_source} - PATH_SUFFIXES "include" - DOC "Path to OPM parser header files" - ${_no_default_path} ) - -find_path (OPM_PARSER_GEN_INCLUDE_DIR - NAMES "opm/parser/eclipse/Parser/ParserKeywords.hpp" - HINTS "${OPM_PARSER_ROOT}" - PATHS ${_opm_parser_build} - PATH_SUFFIXES "generated-source/include" "include" - DOC "Path to OPM parser generated header files" - ${_no_default_path} ) - - -# backup: if we didn't find any headers there, but a CMakeCache.txt, -# then it is probably a build directory; read the CMake cache of -# opm-parser to figure out where the source directory is -if ((NOT OPM_PARSER_INCLUDE_DIR) AND - (OPM_PARSER_ROOT AND (EXISTS "${OPM_PARSER_ROOT}/CMakeCache.txt"))) - set (_regex "^OPMParser_SOURCE_DIR:STATIC=\(.*\)$") - file (STRINGS - "${OPM_PARSER_ROOT}/CMakeCache.txt" - _cache_entry - REGEX "${_regex}") - string(REGEX REPLACE "${_regex}" "\\1" - OPM_PARSER_INCLUDE_DIR - "${_cache_entry}") - if (OPM_PARSER_INCLUDE_DIR) - set (OPM_PARSER_INCLUDE_DIR "${OPM_PARSER_INCLUDE_DIR}" - CACHE PATH "Path to OPM parser header files" FORCE) - endif () -endif () - -# find out the size of a pointer. this is required to only search for -# libraries in the directories relevant for the architecture -if (CMAKE_SIZEOF_VOID_P) - math (EXPR _BITS "8 * ${CMAKE_SIZEOF_VOID_P}") -endif () - -# these libraries constitute the parser core -find_library (OPM_PARSER_LIBRARY - NAMES "opmparser" - HINTS "${OPM_PARSER_ROOT}" - PATHS ${_opm_parser_build} - PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}" - "opm/parser/eclipse" - DOC "Path to OPM parser library archive/shared object files" - ${_no_default_path} ) - -# find the OPM-parser wrapper library around cJSON -find_library (OPM_JSON_LIBRARY - NAMES "opmjson" - HINTS "${OPM_PARSER_ROOT}" - PATHS ${_opm_parser_build} - PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}" - "opm/json" - DOC "Path to OPM JSON library archive/shared object files" - ${_no_default_path} ) - -# get the prerequisite Boost libraries -find_package(Boost 1.44.0 COMPONENTS filesystem date_time system unit_test_framework regex ${OPM_PARSER_QUIET}) - -if (Boost_FOUND AND - OPM_PARSER_LIBRARY AND OPM_JSON_LIBRARY AND OPM_PARSER_INCLUDE_DIR) - # setup list of all required libraries to link with opm-parser. notice that - # we use the plural form to get *all* the libraries needed by cjson - set (opm-parser_INCLUDE_DIRS - ${OPM_PARSER_INCLUDE_DIR} - ${OPM_PARSER_GEN_INCLUDE_DIR} - ${Boost_INCLUDE_DIRS}) - - set (opm-parser_LIBRARIES - ${OPM_PARSER_LIBRARY} - ${OPM_JSON_LIBRARY} - ${Boost_LIBRARIES}) - - # We might be using an external cJSON library - # but we have to unset the OPM_PARSER_ROOT stuff to find it - # (other NO_DEFAULT_PATH will be set). - set(_OPM_PARSER_ROOT_bak ${OPM_PARSER_ROOT}) - set(OPM_PARSER_ROOT "") - find_package(cjson) - set(OPM_PARSER_ROOT ${OPM_PARSER_ROOT_bak}) - - if (CJSON_FOUND) - # If we do we need to add it to the libs. - set (opm-parser_LIBRARIES - ${opm-parser_LIBRARIES} - ${CJSON_LIBRARY}) - endif (CJSON_FOUND) - - # see if we can compile a minimum example - # CMake logical test doesn't handle lists (sic) - include (CMakePushCheckState) - include (CheckCSourceCompiles) - cmake_push_check_state () - set (CMAKE_REQUIRED_INCLUDES ${opm-parser_INCLUDE_DIRS}) - set (CMAKE_REQUIRED_LIBRARIES ${opm-parser_LIBRARIES}) - - check_cxx_source_compiles ( - "#include -#include - -int main (void) { - return EXIT_SUCCESS; -}" HAVE_OPM_PARSER) - cmake_pop_check_state () -endif() - -# if the test program didn't compile, but was required to do so, bail -# out now and display an error; otherwise limp on -set (OPM_PARSER_FIND_REQUIRED ${opm-parser_FIND_REQUIRED}) -find_package_handle_standard_args (opm-parser - DEFAULT_MSG - opm-parser_INCLUDE_DIRS opm-parser_LIBRARIES HAVE_OPM_PARSER - ) - -set (opm-parser_CONFIG_VARS "HAVE_OPM_PARSER;HAVE_REGEX") -set (opm-parser_FOUND ${OPM-PARSER_FOUND}) - -mark_as_advanced(opm-parser_LIBRARIES opm-parser_INCLUDE_DIRS OPM-PARSER_FOUND) +mark_as_advanced(opm-parser_LIBRARIES) From 5c731bf2ce4f6a38c8b9de01836659c82f5a1c78 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Tue, 13 Jun 2017 11:09:11 +0200 Subject: [PATCH 3/3] Stop marking non-stored variables as advanced. --- cmake/Modules/Findopm-parser.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/cmake/Modules/Findopm-parser.cmake b/cmake/Modules/Findopm-parser.cmake index e4a0765a99c..a7d02429674 100644 --- a/cmake/Modules/Findopm-parser.cmake +++ b/cmake/Modules/Findopm-parser.cmake @@ -61,4 +61,3 @@ if (opm-parser_FOUND) ) endif () -mark_as_advanced(opm-parser_LIBRARIES)