From 0a69727bf7b88567e7db288ec7d4979ee2a3a61e Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Tue, 22 Oct 2013 22:38:08 +0200 Subject: [PATCH 1/8] Add missing header for function used inline in class --- opm/parser/eclipse/RawDeck/StarToken.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/opm/parser/eclipse/RawDeck/StarToken.hpp b/opm/parser/eclipse/RawDeck/StarToken.hpp index e44b03f59..b964124f2 100644 --- a/opm/parser/eclipse/RawDeck/StarToken.hpp +++ b/opm/parser/eclipse/RawDeck/StarToken.hpp @@ -22,6 +22,7 @@ #include #include +#include // strtol, strtod #define STAR '*' #define C_EOS '\0' From 781ef04a0e659bf71f1513bb408bf9b65620c1fb Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Tue, 22 Oct 2013 23:39:49 +0200 Subject: [PATCH 2/8] Compare size with unsigned int literal Surprisingly, some compilers (notably GCC 4.6.3) will issue a warning when comparing a literal which is clearly positive to an unsigned type, when looking for a suitable instantiation in Boost. This is fixed by making the literal unsigned too, so there's no doubt. --- opm/parser/eclipse/Parser/tests/ParserTests.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opm/parser/eclipse/Parser/tests/ParserTests.cpp b/opm/parser/eclipse/Parser/tests/ParserTests.cpp index 6c5f5aa4a..1886a4634 100644 --- a/opm/parser/eclipse/Parser/tests/ParserTests.cpp +++ b/opm/parser/eclipse/Parser/tests/ParserTests.cpp @@ -228,12 +228,12 @@ BOOST_AUTO_TEST_CASE(ReplaceKeyword) { ParserPtr parser(new Parser()); ParserKeywordConstPtr eqldims = parser->getKeyword("EQLDIMS"); - BOOST_CHECK_EQUAL( 5 , eqldims->numItems()); + BOOST_CHECK_EQUAL( 5u , eqldims->numItems()); parser->loadKeywordFromFile( "testdata/parser/EQLDIMS2" ); eqldims = parser->getKeyword("EQLDIMS"); - BOOST_CHECK_EQUAL( 1 , eqldims->numItems()); + BOOST_CHECK_EQUAL( 1u , eqldims->numItems()); } From b1f6e665c190828d70761510f4ba64a040e60112 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Wed, 23 Oct 2013 19:50:29 +0200 Subject: [PATCH 3/8] Search for headers relative to project root The find module may be called from a CMakeLists.txt in a subdirectory, and it would start the search from there. --- cmake/Modules/Findcjson.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Modules/Findcjson.cmake b/cmake/Modules/Findcjson.cmake index 87b160bb8..956de05a0 100644 --- a/cmake/Modules/Findcjson.cmake +++ b/cmake/Modules/Findcjson.cmake @@ -16,7 +16,7 @@ endif (CJSON_ROOT) find_path (CJSON_INCLUDE_DIR NAMES "cjson/cJSON.h" HINTS "${CJSON_ROOT}" - PATHS "../opm-parser" + PATHS "${PROJECT_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}/../opm-parser" PATH_SUFFIXES "include" "opm/json" DOC "Path to cjson library header files" ${_no_default_path} ) From 8ac10629686e3501c10d49f8047c808e00c434bd Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Wed, 23 Oct 2013 21:22:14 +0200 Subject: [PATCH 4/8] Allow lowercase variables for specifying project root --- cmake/Modules/Findopm-parser.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmake/Modules/Findopm-parser.cmake b/cmake/Modules/Findopm-parser.cmake index 93d801e24..10f0ba430 100644 --- a/cmake/Modules/Findopm-parser.cmake +++ b/cmake/Modules/Findopm-parser.cmake @@ -18,6 +18,14 @@ else () set (OPM_PARSER_QUIET "") 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) set (OPM_PARSER_ROOT "${OPM_ROOT}/opm-parser") From bb4fffc2274ce8eaa7b2daaa32ba10ad9fc6ed5e Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Wed, 23 Oct 2013 21:24:20 +0200 Subject: [PATCH 5/8] Don't search relative directories if root is given The PATHS that are specified is always searched, also if NO_DEFAULT_PATH is given. --- cmake/Modules/Findopm-parser.cmake | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/cmake/Modules/Findopm-parser.cmake b/cmake/Modules/Findopm-parser.cmake index 10f0ba430..8e5c9012d 100644 --- a/cmake/Modules/Findopm-parser.cmake +++ b/cmake/Modules/Findopm-parser.cmake @@ -32,17 +32,27 @@ if ((NOT OPM_PARSER_ROOT) AND OPM_ROOT) endif () # if a root is specified, then don't search in system directories +# or in relative directories to this one if (OPM_PARSER_ROOT) set (_no_default_path "NO_DEFAULT_PATH") + set (_opm_parser_source "") + set (_opm_parser_build "") else () set (_no_default_path "") + set (_opm_parser_source + "${PROJECT_SOURCE_DIR}/../opm-parser") + set (_opm_parser_build + "${PROJECT_BINARY_DIR}/../opm-parser" + "${PROJECT_BINARY_DIR}/../opm-parser-build" + "${PROJECT_BINARY_DIR}/../../opm-parser/build" + "${PROJECT_BINARY_DIR}/../../opm-parser/cmake-build") 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" + PATHS ${_opm_parser_source} PATH_SUFFIXES "include" DOC "Path to OPM parser header files" ${_no_default_path} ) @@ -57,10 +67,7 @@ endif (CMAKE_SIZEOF_VOID_P) find_library (OPM_PARSER_LIBRARY NAMES "Parser" HINTS "${OPM_PARSER_ROOT}" - PATHS "${PROJECT_BINARY_DIR}/../opm-parser" - "${PROJECT_BINARY_DIR}/../opm-parser-build" - "${PROJECT_BINARY_DIR}/../../opm-parser/build" - "${PROJECT_BINARY_DIR}/../../opm-parser/cmake-build" + 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" @@ -69,10 +76,7 @@ find_library (OPM_PARSER_LIBRARY find_library (OPM_JSON_LIBRARY NAMES "opm-json" HINTS "${OPM_PARSER_ROOT}" - PATHS "${PROJECT_BINARY_DIR}/../opm-parser" - "${PROJECT_BINARY_DIR}/../opm-parser-build" - "${PROJECT_BINARY_DIR}/../../opm-parser/build" - "${PROJECT_BINARY_DIR}/../../opm-parser/cmake-build" + 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" From 7e9c45b765d8e3f7404697d76537043a49f956af Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Wed, 23 Oct 2013 21:44:51 +0200 Subject: [PATCH 6/8] Allow package to be specified as required Although CMake prefers the uppercase variant variables, and the find_package_handle_standard_args will convert to them for us, the part that parses REQUIRED and QUIET arguments to find_package still only uses the package name verbatim (sic). --- cmake/Modules/Findcjson.cmake | 2 ++ cmake/Modules/Findopm-parser.cmake | 2 ++ 2 files changed, 4 insertions(+) diff --git a/cmake/Modules/Findcjson.cmake b/cmake/Modules/Findcjson.cmake index 956de05a0..fba8c733f 100644 --- a/cmake/Modules/Findcjson.cmake +++ b/cmake/Modules/Findcjson.cmake @@ -76,6 +76,8 @@ 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 (CJSON_FIND_REQUIRED ${cjson_FIND_REQUIRED}) +set (CJSON_FIND_QUIETLY ${cjson_FIND_QUIETLY}) find_package_handle_standard_args (CJSON DEFAULT_MSG CJSON_INCLUDE_DIRS CJSON_LIBRARIES HAVE_CJSON diff --git a/cmake/Modules/Findopm-parser.cmake b/cmake/Modules/Findopm-parser.cmake index 8e5c9012d..2911addaf 100644 --- a/cmake/Modules/Findopm-parser.cmake +++ b/cmake/Modules/Findopm-parser.cmake @@ -132,6 +132,8 @@ 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_DIR OPM_PARSER_LIBRARIES HAVE_OPM_PARSER From 940f31295be9ec9d9992870a4b1dd6a8a37e5d76 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Wed, 23 Oct 2013 21:48:50 +0200 Subject: [PATCH 7/8] Test for all the required header directories --- cmake/Modules/Findopm-parser.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Modules/Findopm-parser.cmake b/cmake/Modules/Findopm-parser.cmake index 2911addaf..f739cd6b9 100644 --- a/cmake/Modules/Findopm-parser.cmake +++ b/cmake/Modules/Findopm-parser.cmake @@ -136,6 +136,6 @@ 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_DIR OPM_PARSER_LIBRARIES HAVE_OPM_PARSER + OPM_PARSER_INCLUDE_DIRS OPM_PARSER_LIBRARIES HAVE_OPM_PARSER ) set (opm-parser_FOUND ${OPM_PARSER_FOUND}) From 54d94d7634d50643b0058ae44cd48647ce07c649 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Thu, 24 Oct 2013 09:37:14 +0200 Subject: [PATCH 8/8] Parser->addKeyword() will erase first; NOW the ReplaceKeyword works --- opm/parser/eclipse/Parser/Parser.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/opm/parser/eclipse/Parser/Parser.cpp b/opm/parser/eclipse/Parser/Parser.cpp index d16f33dfd..8d97e4ff3 100644 --- a/opm/parser/eclipse/Parser/Parser.cpp +++ b/opm/parser/eclipse/Parser/Parser.cpp @@ -65,6 +65,9 @@ namespace Opm { } void Parser::addKeyword(ParserKeywordConstPtr parserKeyword) { + if (hasKeyword(parserKeyword->getName())) + m_parserKeywords.erase(parserKeyword->getName()); + m_parserKeywords.insert(std::make_pair(parserKeyword->getName(), parserKeyword)); }