From d530dcfe17c0458927839ce80fe394b91747dc2c Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Wed, 11 Jun 2014 22:05:02 +0200 Subject: [PATCH] Findopm-parser.cmake: make sure that the ERT libraries are available and some other minor cleanups to the module. For me it still works, but this being the build system, I can't guarantee more... --- cmake/Modules/Findopm-parser.cmake | 111 ++++++++++++------------- cmake/Modules/opm-parser-prereqs.cmake | 19 ----- 2 files changed, 55 insertions(+), 75 deletions(-) delete mode 100644 cmake/Modules/opm-parser-prereqs.cmake diff --git a/cmake/Modules/Findopm-parser.cmake b/cmake/Modules/Findopm-parser.cmake index 3dfb0b49d..6f3015991 100644 --- a/cmake/Modules/Findopm-parser.cmake +++ b/cmake/Modules/Findopm-parser.cmake @@ -78,11 +78,6 @@ if ((NOT OPM_PARSER_INCLUDE_DIR) AND 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 (CMAKE_SIZEOF_VOID_P) # these libraries constitute the parser core find_library (OPM_PARSER_LIBRARY @@ -94,6 +89,7 @@ find_library (OPM_PARSER_LIBRARY 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 "opm-json" HINTS "${OPM_PARSER_ROOT}" @@ -103,72 +99,75 @@ find_library (OPM_JSON_LIBRARY DOC "Path to OPM JSON library archive/shared object files" ${_no_default_path} ) -# get the prerequisite CJSON library -if (NOT CJSON_FOUND) - find_package (cjson ${OPM_PARSER_QUIET}) +# get the prerequisite ERT libraries +if (NOT ERT_FOUND) + find_package(ERT ${opm-parser_FIND_REQUIRED} ${OPM_PARSER_QUIET}) endif () +# get the prerequisite CJSON library if (NOT CJSON_FOUND) + find_package(cjson ${opm-parser_FIND_REQUIRED} ${OPM_PARSER_QUIET}) +endif () + +# get the prerequisite Boost libraries +if (NOT Boost_FOUND) + find_package(Boost 1.44.0 + COMPONENTS filesystem date_time system unit_test_framework + ${opm-parser_FIND_REQUIRED} ${OPM_PARSER_QUIET}) +endif () + +if (NOT CJSON_FOUND OR NOT ERT_FOUND OR NOT Boost_FOUND) set(opm-parser_FOUND "0") else() - # get the prerequisite Boost libraries - if (NOT Boost_FOUND) - find_package(Boost 1.44.0 - COMPONENTS filesystem date_time system unit_test_framework ${OPM_PARSER_QUIET}) - endif () + # 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} + ${CJSON_INCLUDE_DIRS} + ${Boost_INCLUDE_DIRS}) - if (NOT Boost_FOUND) - set(opm-parser_FOUND "0") - else() - # 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} - ${CJSON_INCLUDE_DIRS} - ${Boost_INCLUDE_DIRS}) + set (OPM_PARSER_LIBRARIES + ${OPM_PARSER_LIBRARY} + ${OPM_JSON_LIBRARY} + ${CJSON_LIBRARIES} + ${Boost_LIBRARIES} + ${ERT_LIBRARIES}) - set (OPM_PARSER_LIBRARIES - ${OPM_PARSER_LIBRARY} - ${OPM_JSON_LIBRARY} - ${CJSON_LIBRARIES} - ${Boost_LIBRARIES}) + # see if we can compile a minimum example + # CMake logical test doesn't handle lists (sic) + if (NOT (OPM_PARSER_INCLUDE_DIR MATCHES "-NOTFOUND" + OR OPM_PARSER_LIBRARIES MATCHES "-NOTFOUND")) + include (CMakePushCheckState) + include (CheckCSourceCompiles) + cmake_push_check_state () + set (CMAKE_REQUIRED_INCLUDES ${OPM_PARSER_INCLUDE_DIRS}) + set (CMAKE_REQUIRED_LIBRARIES ${OPM_PARSER_LIBRARIES}) - # see if we can compile a minimum example - # CMake logical test doesn't handle lists (sic) - if (NOT (OPM_PARSER_INCLUDE_DIR MATCHES "-NOTFOUND" - OR OPM_PARSER_LIBRARIES MATCHES "-NOTFOUND")) - 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 ( + check_cxx_source_compiles ( "#include #include int main (void) { return EXIT_SUCCESS; }" HAVE_OPM_PARSER) - cmake_pop_check_state () - else () - # clear the cache so the find probe is attempted again if files becomes - # available (only upon a unsuccessful *compile* should we disable further - # probing) - set (HAVE_OPM_PARSER) - unset (HAVE_OPM_PARSER CACHE) - endif () + cmake_pop_check_state () + else () + # clear the cache so the find probe is attempted again if files become + # available (only upon a unsuccessful *compile* should we disable further + # probing) + set (HAVE_OPM_PARSER) + unset (HAVE_OPM_PARSER CACHE) + 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}) - set (OPM_PARSER_FIND_QUIETLY ${opm-parser_FIND_QUIETLY}) - find_package_handle_standard_args (OPM_PARSER - DEFAULT_MSG - OPM_PARSER_INCLUDE_DIRS OPM_PARSER_LIBRARIES HAVE_OPM_PARSER - ) - endif() # BOOST -endif() # cJSON + # 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}) + set (OPM_PARSER_FIND_QUIETLY ${opm-parser_FIND_QUIETLY}) + find_package_handle_standard_args (OPM_PARSER + DEFAULT_MSG + OPM_PARSER_INCLUDE_DIRS OPM_PARSER_LIBRARIES HAVE_OPM_PARSER + ) +endif() set (opm-parser_FOUND ${OPM_PARSER_FOUND}) if(OPM_PARSER_FOUND) diff --git a/cmake/Modules/opm-parser-prereqs.cmake b/cmake/Modules/opm-parser-prereqs.cmake deleted file mode 100644 index 6cf975b9e..000000000 --- a/cmake/Modules/opm-parser-prereqs.cmake +++ /dev/null @@ -1,19 +0,0 @@ -# -*- mode: cmake; tab-width: 2; indent-tabs-mode: t; truncate-lines: t; compile-command: "cmake -Wdev" -*- -# vim: set filetype=cmake autoindent tabstop=2 shiftwidth=2 noexpandtab softtabstop=2 nowrap: - -# defines that must be present in config.h for our headers -set (opm-parser_CONFIG_VAR - HAVE_ERT - ) - -# dependencies -set (opm-parser_DEPS - # compile with C99 support if available - "C99" - # compile with C++0x/11 support if available - "CXX11Features REQUIRED" - # various runtime library enhancements - "Boost 1.44.0 - COMPONENTS date_time filesystem system iostream unit_test_framework REQUIRED" - "cJSON" - )