changed: refined OpmStaticTargets

- pass on toolchain file
- don't build examples in static directories
- allow non-install mode and custom targets in opm_from_git
- use origin/master to make sure static source trees are built from the
  top should user re-execute the build in an existing build tree
This commit is contained in:
Arne Morten Kvarving
2015-06-30 10:12:03 +02:00
parent 6ecf5313aa
commit 706e49075c

View File

@@ -6,19 +6,43 @@
####################################################################
# Macros
# Clone a git and build it statically
# If ARGN is specified installation is skipped, ARGN0 is
# a build-system target name and the rest of ARGN are build tool parameters
function(opm_from_git repo name revision)
if(ARGN)
list(GET ARGN 0 target)
list(REMOVE_AT ARGN 0)
# This is used for top build of benchmarks.
# Clones the local source tree and builds it against the static libraries,
# skipping the install step. Note that in pricinple URL instead of GIT_REPOSITORY
# could have been used, but externalproject cannot handle build directories
# which are a subdirectory of the source tree, and since that is typically the case
# we work-around by re-cloning the local git.
# The ommision of GIT_TAG ensures that we build the tip of the local git.
set(COMMANDS BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --target ${target} -- ${ARGN}
GIT_TAG ${revision}
INSTALL_COMMAND)
else()
# This is used with "normal" static builds.
set(COMMANDS GIT_TAG ${revision})
endif()
externalproject_add(${name}-static
GIT_REPOSITORY ${repo}
PREFIX static/${name}
GIT_TAG ${revision}
CONFIGURE_COMMAND PKG_CONFIG_PATH=${CMAKE_BINARY_DIR}/static/installed/lib/pkgconfig:${CMAKE_BINARY_DIR}/static/installed/${CMAKE_INSTALL_LIBDIR}/pkgconfig:$ENV{PKG_CONFIG_PATH}
${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/static/installed
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DBUILD_SHARED_LIBS=0
-DBUILD_TESTING=0 <SOURCE_DIR>)
-DBUILD_TESTING=0 -DBUILD_EXAMPLES=0 <SOURCE_DIR>
-G ${CMAKE_GENERATOR}
${COMMANDS} "")
set_target_properties(${name}-static PROPERTIES EXCLUDE_FROM_ALL 1)
endfunction()
# Convenience macro for adding dependencies without having to include the -static all over
macro(opm_static_add_dependencies target)
foreach(arg ${ARGN})
add_dependencies(${target}-static ${arg}-static)
@@ -30,7 +54,7 @@ include(UseMultiArch)
# Defaults to building master
if(NOT OPM_BENCHMARK_VERSION)
set(OPM_BENCHMARK_VERSION "master")
set(OPM_BENCHMARK_VERSION "origin/master")
endif()
# ERT
@@ -50,7 +74,12 @@ if(OPM_BENCHMARK_VERSION STREQUAL "release/2015.04/final")
endif()
# Master currently uses dune v2.3.1
if(OPM_BENCHMARK_VERSION STREQUAL "master")
if(OPM_BENCHMARK_VERSION STREQUAL "origin/master")
set(DUNE_VERSION v2.3.1)
endif()
# Fallback
if(NOT DUNE_VERSION)
set(DUNE_VERSION v2.3.1)
endif()