make the build system compatible with Dune's cmake build system

before this, dune modules that are not using the OPM build system
needed to treat opm-parser as an external library. With this patch,
opm-parser can be build as part of duncontrol build chains, i.e.,
other modules just need to specify a depencency on opm-parser in their
dune.module file and opm-parser's libraries and headers get picked up
just fine.

Things like generating opm-parser-config.cmake should quite likely be
done in a better way, but I'm not really a cmake expert and the
solution proposed in this patch seems to get things done regardless of
whether opm-parser is system-installed or not. Comprehensive solutions
are highly appreciated.
This commit is contained in:
Andreas Lauser
2017-07-13 18:29:25 +02:00
committed by Arne Morten Kvarving
parent e6320dc783
commit af736c1837
4 changed files with 84 additions and 1 deletions

50
config.h.cmake Normal file
View File

@@ -0,0 +1,50 @@
/* begin opm-parser
put the definitions for config.h specific to
your project here. Everything above will be
overwritten
*/
/* begin private */
/* Name of package */
#define PACKAGE "@DUNE_MOD_NAME@"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "@DUNE_MAINTAINER@"
/* Define to the full name of this package. */
#define PACKAGE_NAME "@DUNE_MOD_NAME@"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "@DUNE_MOD_NAME@ @DUNE_MOD_VERSION@"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "@DUNE_MOD_NAME@"
/* Define to the home page for this package. */
#define PACKAGE_URL "@DUNE_MOD_URL@"
/* Define to the version of this package. */
#define PACKAGE_VERSION "@DUNE_MOD_VERSION@"
/* end private */
/* Define to the version of opm-parser */
#define OPM_PARSER_VERSION "${OPM_PARSER_VERSION}"
/* Define to the major version of opm-parser */
#define OPM_PARSER_VERSION_MAJOR ${OPM_PARSER_VERSION_MAJOR}
/* Define to the minor version of opm-parser */
#define OPM_PARSER_VERSION_MINOR ${OPM_PARSER_VERSION_MINOR}
/* Define to the revision of opm-parser */
#define OPM_PARSER_VERSION_REVISION ${OPM_PARSER_VERSION_REVISION}
/* Specify whether ERT/libecl is available or not */
#cmakedefine HAVE_ERT 1
#cmakedefine HAVE_LIBECL 1
/* begin bottom */
/* end bottom */
/* end opm-parser */

View File

@@ -0,0 +1,18 @@
if(NOT opm-parser_FOUND)
#import the target
get_filename_component(_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
include("${_dir}/opm-parser-targets.cmake")
#report other information
set(opm-parser_INSTALLED "@OPM_PARSER_INSTALLED@")
set(opm-parser_PREFIX "@OPM_PARSER_PREFIX@")
set(opm-parser_INCLUDE_DIRS "@OPM_PARSER_INCLUDEDIRS@")
set(opm-parser_LIBRARY_DIRS "@OPM_PARSER_LIBDIRS@")
set(opm-parser_CXX_FLAGS "@CMAKE_CXX_FLAGS@")
set(opm-parser_CXX_FLAGS_DEBUG "@CMAKE_CXX_FLAGS_DEBUG@")
set(opm-parser_CXX_FLAGS_MINSIZEREL "@CMAKE_CXX_FLAGS_MINSIZEREL@")
set(opm-parser_CXX_FLAGS_RELEASE "@CMAKE_CXX_FLAGS_RELEASE@")
set(opm-parser_CXX_FLAGS_RELWITHDEBINFO "@CMAKE_CXX_FLAGS_RELWITHDEBINFO@")
set(opm-parser_LIBRARIES "opmparser")
set(opm-parser_MODULE_PATH "@OPM_PARSER_MODULE_PATH@")
endif(NOT opm-parser_FOUND)

15
opm-parser.pc.in Normal file
View File

@@ -0,0 +1,15 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include
CXX=@CMAKE_CXX_COMPILER@
CC=@CMAKE_C_COMPILER@
DEPENDENCIES=
Name: opm-parser
Version: @VERSION@
Description: The opm-parser module
URL: http://www.opm-project.org/
Requires: ${DEPENDENCIES}
Libs: -L${libdir} -lopmparser
Cflags: -I${includedir}

View File

@@ -152,7 +152,7 @@ endforeach()
add_static_analysis_tests(opmparser_SRC opmparser_INCLUDES)
install(TARGETS opmparser
EXPORT opm-parser-config
EXPORT opm-parser-targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})