changed: simplify buildsystem a little

- use loops instead of copy-paste
- use object libraries to avoid some unnecessary archives
- tab scrubbing
This commit is contained in:
Arne Morten Kvarving 2019-06-13 14:59:31 +02:00
parent 2f28bb3758
commit 795f412047

View File

@ -1,6 +1,3 @@
# -*- 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:
########################################################################### ###########################################################################
# # # #
# Note: The bulk of the build system is located in the cmake/ directory. # # Note: The bulk of the build system is located in the cmake/ directory. #
@ -80,9 +77,9 @@ include ("${project}-prereqs")
include (CMakeLists_files.cmake) include (CMakeLists_files.cmake)
macro (config_hook) macro (config_hook)
opm_need_version_of ("dune-common") opm_need_version_of ("dune-common")
opm_need_version_of ("dune-istl") opm_need_version_of ("dune-istl")
opm_need_version_of ("ewoms") opm_need_version_of ("ewoms")
endmacro (config_hook) endmacro (config_hook)
macro (prereqs_hook) macro (prereqs_hook)
@ -182,20 +179,23 @@ if (NOT BUILD_EBOS)
else() else()
set(EBOS_DEFAULT_ENABLE_IF "TRUE") set(EBOS_DEFAULT_ENABLE_IF "TRUE")
endif() endif()
# the research oriented general-purpose ECL simulator ("ebos" == &ecl # the research oriented general-purpose ECL simulator ("ebos" == &ecl
# &black-&oil &simulator) # &black-&oil &simulator)
get_target_property(ecl_INCLUDE_DIRS ecl INTERFACE_INCLUDE_DIRECTORIES) get_target_property(ecl_INCLUDE_DIRS ecl INTERFACE_INCLUDE_DIRECTORIES)
include_directories("${ecl_INCLUDE_DIRS}")
add_library(ebos_libblackoil STATIC EXCLUDE_FROM_ALL ebos/ebos_blackoil.cc) foreach(OBJ blackoil solvent polymer gasoil oilwater thermal)
add_library(ebos_lib${OBJ} OBJECT EXCLUDE_FROM_ALL ebos/ebos_${OBJ}.cc)
target_include_directories(ebos_lib${OBJ} PRIVATE ${ecl_INCLUDE_DIRS})
endforeach()
opm_add_test(ebos opm_add_test(ebos
ONLY_COMPILE ONLY_COMPILE
DEFAULT_ENABLE_IF ${EBOS_DEFAULT_ENABLE_IF} DEFAULT_ENABLE_IF ${EBOS_DEFAULT_ENABLE_IF}
ALWAYS_ENABLE ALWAYS_ENABLE
EXE_NAME "ebos" EXE_NAME ebos
LIBRARIES "ebos_libblackoil" "opmsimulators" LIBRARIES opmsimulators
SOURCES "ebos/ebos_main.cc") SOURCES ebos/ebos_main.cc $<TARGET_OBJECTS:ebos_libblackoil>)
if (BUILD_EBOS) if (BUILD_EBOS)
install(TARGETS ebos DESTINATION bin) install(TARGETS ebos DESTINATION bin)
@ -208,52 +208,27 @@ else()
set(EBOS_EXTENSIONS_DEFAULT_ENABLE_IF "TRUE") set(EBOS_EXTENSIONS_DEFAULT_ENABLE_IF "TRUE")
endif() endif()
add_library(ebos_libsolvent STATIC EXCLUDE_FROM_ALL ebos/ebos_solvent.cc) foreach(OBJ solvent polymer gasoil oilwater thermal)
opm_add_test(ebos_solvent opm_add_test(ebos_${OBJ}
ONLY_COMPILE ONLY_COMPILE
DEFAULT_ENABLE_IF ${EBOS_EXTENSIONS_DEFAULT_ENABLE_IF} DEFAULT_ENABLE_IF ${EBOS_EXTENSIONS_DEFAULT_ENABLE_IF}
SOURCES "ebos/ebos_solvent_main.cc" SOURCES ebos/ebos_${OBJ}_main.cc $<TARGET_OBJECTS:ebos_lib${OBJ}>
EXE_NAME "ebos_solvent" EXE_NAME ebos_${OBJ}
LIBRARIES "ebos_libsolvent" "opmsimulators") LIBRARIES opmsimulators)
endforeach()
add_library(ebos_libpolymer STATIC EXCLUDE_FROM_ALL ebos/ebos_polymer.cc)
opm_add_test(ebos_polymer
ONLY_COMPILE
DEFAULT_ENABLE_IF ${EBOS_EXTENSIONS_DEFAULT_ENABLE_IF}
SOURCES "ebos/ebos_polymer_main.cc"
EXE_NAME "ebos_polymer"
LIBRARIES "ebos_libpolymer" "opmsimulators")
add_library(ebos_libgasoil STATIC EXCLUDE_FROM_ALL ebos/ebos_gasoil.cc)
opm_add_test(ebos_gasoil
ONLY_COMPILE
DEFAULT_ENABLE_IF ${EBOS_EXTENSIONS_DEFAULT_ENABLE_IF}
SOURCES "ebos/ebos_gasoil_main.cc"
EXE_NAME "ebos_gasoil"
LIBRARIES "ebos_libgasoil" "opmsimulators")
add_library(ebos_liboilwater STATIC EXCLUDE_FROM_ALL ebos/ebos_oilwater.cc)
opm_add_test(ebos_oilwater
ONLY_COMPILE
DEFAULT_ENABLE_IF ${EBOS_EXTENSIONS_DEFAULT_ENABLE_IF}
SOURCES ebos/ebos_oilwater_main.cc
EXE_NAME ebos_oilwater
LIBRARIES "ebos_liboilwater" "opmsimulators")
add_library(ebos_libthermal STATIC EXCLUDE_FROM_ALL ebos/ebos_thermal.cc)
opm_add_test(ebos_thermal
ONLY_COMPILE
DEFAULT_ENABLE_IF ${EBOS_EXTENSIONS_DEFAULT_ENABLE_IF}
SOURCES "ebos/ebos_thermal_main.cc"
EXE_NAME "ebos_thermal"
LIBRARIES "ebos_libthermal" "opmsimulators")
opm_add_test(mebos opm_add_test(mebos
ONLY_COMPILE ONLY_COMPILE
DEFAULT_ENABLE_IF ${EBOS_EXTENSIONS_DEFAULT_ENABLE_IF} DEFAULT_ENABLE_IF ${EBOS_EXTENSIONS_DEFAULT_ENABLE_IF}
SOURCES "ebos/mebos_main.cc" SOURCES ebos/mebos_main.cc
EXE_NAME "mebos" $<TARGET_OBJECTS:ebos_libblackoil>
LIBRARIES "ebos_libblackoil" "ebos_libpolymer" "ebos_libsolvent" "ebos_libthermal" "ebos_liboilwater" "ebos_libgasoil" "opmsimulators") $<TARGET_OBJECTS:ebos_libsolvent>
$<TARGET_OBJECTS:ebos_libpolymer>
$<TARGET_OBJECTS:ebos_libthermal>
$<TARGET_OBJECTS:ebos_liboilwater>
$<TARGET_OBJECTS:ebos_libgasoil>
EXE_NAME mebos
LIBRARIES opmsimulators)
if (NOT BUILD_EBOS_DEBUG_EXTENSIONS) if (NOT BUILD_EBOS_DEBUG_EXTENSIONS)
set(EBOS_DEBUG_EXTENSIONS_DEFAULT_ENABLE_IF "FALSE") set(EBOS_DEBUG_EXTENSIONS_DEFAULT_ENABLE_IF "FALSE")
@ -266,29 +241,20 @@ opm_add_test(ebos_altidx
DEFAULT_ENABLE_IF ${EBOS_DEBUG_EXTENSIONS_DEFAULT_ENABLE_IF} DEFAULT_ENABLE_IF ${EBOS_DEBUG_EXTENSIONS_DEFAULT_ENABLE_IF}
SOURCES ebos/ebos_altidx.cc SOURCES ebos/ebos_altidx.cc
EXE_NAME ebos_altidx EXE_NAME ebos_altidx
DEPENDS "opmsimulators" DEPENDS opmsimulators
LIBRARIES "opmsimulators") LIBRARIES opmsimulators)
opm_add_test(ebos_plain opm_add_test(ebos_plain
ONLY_COMPILE ONLY_COMPILE
DEFAULT_ENABLE_IF ${EBOS_DEBUG_EXTENSIONS_DEFAULT_ENABLE_IF} DEFAULT_ENABLE_IF ${EBOS_DEBUG_EXTENSIONS_DEFAULT_ENABLE_IF}
SOURCES ebos/ebos_plain.cc SOURCES ebos/ebos_plain.cc
EXE_NAME ebos_plain EXE_NAME ebos_plain
DEPENDS "opmsimulators" DEPENDS opmsimulators
LIBRARIES "opmsimulators") LIBRARIES opmsimulators)
opm_add_bash_completion(ebos_solvent)
opm_add_bash_completion(ebos_polymer)
opm_add_bash_completion(ebos_gasoil)
opm_add_bash_completion(ebos_oilwater)
opm_add_bash_completion(ebos_thermal)
if (BUILD_EBOS_EXTENSIONS) if (BUILD_EBOS_EXTENSIONS)
install(TARGETS ebos_solvent DESTINATION bin) foreach(TGT ebos_solvent ebos_polymer ebos_gasoil ebos_oilwater ebos_thermal mebos)
install(TARGETS ebos_polymer DESTINATION bin) install(TARGETS ${TGT} DESTINATION bin)
install(TARGETS ebos_gasoil DESTINATION bin) opm_add_bash_completion(${TGT})
install(TARGETS ebos_oilwater DESTINATION bin) endforeach()
install(TARGETS ebos_thermal DESTINATION bin)
install(TARGETS mebos DESTINATION bin)
endif() endif()