reset_cmake_required()
endif()
+
+
+#
+# Check whether the compiler supports interprocedural and link-time
+# optimization. If so, we can set the corresponding property on the
+# compile and link targets later on.
+#
+if(DEAL_II_USE_LTO)
+ include(CheckIPOSupported)
+ check_ipo_supported(RESULT _res OUTPUT _out LANGUAGES CXX)
+ if (_res)
+ message(STATUS "Compiler supports interprocedural/link-time optimizations")
+ set(DEAL_II_USE_LTO "YES")
+ else()
+ message(FATAL_ERROR "You asked for interprocedural/link-time optimizations, but the compiler does not support these optimizations: ${_out}")
+ set(DEAL_II_USE_LTO "NO")
+ endif()
+else()
+ # User did not set DEAL_II_USE_LTO on the command line. Set the
+ # variable to a specific (negative) value.
+ set(DEAL_II_USE_LTO "NO")
+endif()
#
# populate_target_properties(<target> <build>)
#
-# This function populate target properties according to (globally) defined
+# This function populates target properties according to (globally) defined
# DEAL_II_* variables. Specifically:
#
# DEAL_II_LIBRARIES DEAL_II_LIBRARIES_<build>
${DEAL_II_LIBRARIES} ${DEAL_II_LIBRARIES_${_build}}
${DEAL_II_TARGETS} ${DEAL_II_TARGETS_${_build}}
)
+
+
+ # For release builds (and their corresponding object files),
+ # use interprocedural optimizations if possible
+ if (DEAL_II_USE_LTO AND ("${_build}" STREQUAL "RELEASE"))
+ set_property(TARGET ${_target}
+ PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
+ endif()
+
endfunction()
#
# CMAKE_BUILD_TYPE
# DEAL_II_ALLOW_PLATFORM_INTROSPECTION
+# DEAL_II_USE_LTO
# DEAL_II_SETUP_COVERAGE
# DEAL_II_UNITY_BUILD
# DEAL_II_EARLY_DEPRECATIONS
)
mark_as_advanced(DEAL_II_ALLOW_PLATFORM_INTROSPECTION)
+option(DEAL_II_USE_LTO
+ "Allow the compiler to use interprocedural and link-time optimization (LTO)."
+ OFF
+ )
+mark_as_advanced(DEAL_II_USE_LTO)
+
option(DEAL_II_SETUP_COVERAGE
"Setup debug compiler flags to provide additional test coverage information. Currently only gprof is supported."
OFF
(default), <acronym>deal.II</acronym> will perform platform
introspection for the given CPU.
+ <li>
+ <code>DEAL_II_USE_LTO</code>: If set to "ON" (the default is
+ "OFF"), allow the compiler to use interprocedural and
+ link-time optimization for release builds. These
+ optimizations often substantially improve performance, but
+ take both a substantial amount of memory and CPU time when
+ compiling the library.
+
<li>
<code>BUILD_SHARED_LIBS</code>: If set (default),
<acronym>deal.II</acronym> will be linked as a shared library
set(build_camelcase "Release")
endif()
+
#
# Combine all ${build} OBJECT targets to a ${build} library:
#