Enable opt-out of precompiled headers

Some versions of the compiler are buggy, and will actually crash if
precompiled headers are used. This option enable disabling the feature
and building without by simply setting a command-line option.
This commit is contained in:
Roland Kaufmann
2013-01-24 20:45:39 +01:00
parent 2cc9807b63
commit 05a4ff30bf
2 changed files with 28 additions and 14 deletions

View File

@@ -234,18 +234,25 @@ configure_file (
# pre-compile common headers; this is setup *after* the library to pick
# up extra options set there
get_target_property (_type opmcore TYPE)
precompile_header (CXX ${_type}
HEADER "${opmcore_PRECOMP_CXX_HEADER}"
TARGET opmcore_CXX_pch
FLAGS opmcore_PRECOMP_CXX_FLAGS
)
# must set property on source files instead of entire target, because
# it only applies to C++ modules (and cannot be used for C)
set_source_files_properties (${opmcore_CXX_SOURCES} PROPERTIES
OBJECT_DEPENDS "${opmcore_CXX_pch}"
COMPILE_FLAGS "${opmcore_PRECOMP_CXX_FLAGS}"
)
option (PRECOMPILE_HEADERS "Precompile common headers for speed." ON)
mark_as_advanced (PRECOMPILE_HEADERS)
if (PRECOMPILE_HEADERS)
get_target_property (_type opmcore TYPE)
precompile_header (CXX ${_type}
HEADER "${opmcore_PRECOMP_CXX_HEADER}"
TARGET opmcore_CXX_pch
FLAGS opmcore_PRECOMP_CXX_FLAGS
)
# must set property on source files instead of entire target, because
# it only applies to C++ modules (and cannot be used for C)
set_source_files_properties (${opmcore_CXX_SOURCES} PROPERTIES
OBJECT_DEPENDS "${opmcore_CXX_pch}"
COMPILE_FLAGS "${opmcore_PRECOMP_CXX_FLAGS}"
)
message (STATUS "Precompiled headers: ${opmcore_CXX_pch}")
else (PRECOMPILE_HEADERS)
message (STATUS "Precompiled headers: disabled")
endif (PRECOMPILE_HEADERS)
### installation ###
foreach (_hdr IN LISTS opmcore_HEADERS)

11
configure vendored
View File

@@ -14,7 +14,8 @@ Optional Features:
--enable-shared build a shared library [default=yes]
--enable-static build a static library [default=no]. Note: only one
of the options shared and static may be built.
--disable-debug build a release version of the library [default=no]
--disable-debug build a release version of the library [default=no]
--disable-pch do not use precompiled headers (if buggy compiler)
Optional Packages:
--with-dune-common=PATH use DUNE-common library from a specified location
@@ -64,6 +65,8 @@ EOF
# default values
prefix=/usr/local
buildtype=Debug
#pch_use=" -DPRECOMPILE_HEADERS:BOOL=ON"
pch_use=
# this variable will get feature options
FEATURES=
@@ -142,6 +145,10 @@ while getopts -- ":-:" optchar; do
# special flag: don't disable any particular package
pkgname=""
;;
pch)
pch_use=" -DPRECOMPILE_HEADERS:BOOL=OFF"
pkgname=""
;;
agmg |\
ert |\
superlu)
@@ -196,7 +203,7 @@ shift $((OPTIND-1))
ENVVARS=${@/ACLOCAL_*=*/}
# pass everything on to CMake
CMDLINE="env ${ENVVARS} cmake \"$(dirname "$0")\" \"-DCMAKE_INSTALL_PREFIX=$prefix\" -DCMAKE_BUILD_TYPE=${buildtype} ${FEATURES}"
CMDLINE="env ${ENVVARS} cmake \"$(dirname "$0")\" \"-DCMAKE_INSTALL_PREFIX=$prefix\" -DCMAKE_BUILD_TYPE=${buildtype}${pch_use} ${FEATURES}"
echo --- calling CMake for opm-core ---
echo ${CMDLINE}
eval exec ${CMDLINE}