OPTION(DEAL_II_WITH_THREADS
"Build deal.II with support for threads. This pulls in libtbb as a dependency."
- ON)
+ OFF)
OPTION(DEAL_II_WITH_UMFPACK
"Build deal.II with support for UMFPACK, BLAS and LAPACK."
OPTION(DEAL_II_FORCE_CONTRIB_BOOST
"Always use the bundled boost library instead of an external one."
- ON)
+ OFF)
OPTION(DEAL_II_FORCE_CONTRIB_TBB
"Always use the bundled tbb library instead of an external one."
+
#
# Now, configure a lot of things:
#
-# Used as a dummy target for all the stuff that has to be done before the
-# library can be compiled:
-ADD_CUSTOM_TARGET(deal_ii_target_dependencies)
-# Used to keep track of external libraries and necessary linker flags
-SET(deal_ii_external_libraries "")
-SET(deal_ii_required_linker_flags "")
+###########################################################################
+# #
+# FAT NOTE: #
+# #
+###########################################################################
+
+#
+# To keep things clean, only the following cmake variables should be
+# altered (beside setting a lot of DEAL_II_* definitions...)
+#
+# CMAKE_SHARED_LINKER_FLAGS
+#
+# for setting necessary linker flags for the deal.II library.
+#
+# CMAKE_C_FLAGS and CMAKE_CXX_FLAGS (uncached)
+#
+# for setting necessary compiler flags, e.g. -std=c++0x (if available).
+# Note: Uncached variables are not visible to the user, and cannot be
+# altered.
+#
+ADD_CUSTOM_TARGET(deal_ii_target_dependencies)
+#
+# Used as a dummy target for all the stuff that has to be done before the
+# library can be compiled.
+#
+SET(deal_ii_external_libraries)
+#
+# Used to keep track of external libraries, against which the deal.II
+# library will be linked.
+#
#
# Platform checks:
-# And finally convert deal_ii_required_linker_flags from a list into a
-# string *sigh*
-# TODO: Encapsulate in a macro...
-SET(deal_ii_required_linker_flags_list ${deal_ii_required_linker_flags})
-SET(deal_ii_required_linker_flags "")
-FOREACH (arg ${deal_ii_required_linker_flags_list})
- SET(deal_ii_required_linker_flags "${deal_ii_required_linker_flags} ${arg}")
-ENDFOREACH()
-
-
-
#
# Build the toolchain:
#
INCLUDE(CheckCXXSourceCompiles)
+INCLUDE(CheckCXXCompilerFlag)
INCLUDE(CheckCXXSourceRuns)
#
# Check whether the std::vector::iterator is just a plain pointer
#
+# TODO: Get rid of this negation!
CHECK_CXX_SOURCE_COMPILES(
"
#include <vector>
IF(HAVE_GLIBC_STACKTRACE AND NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
- LIST(APPEND CMAKE_REQUIRED_FLAGS "-rdynamic")
-
- CHECK_CXX_SOURCE_COMPILES(
- "
- int main() { return 0; }
- "
+ CHECK_CXX_COMPILER_FLAG(
+ "-rdynamic"
DEAL_II_COMPILER_HAS_RDYNAMIC)
- LIST(REMOVE_ITEM CMAKE_REQUIRED_FLAGS "-rdynamic")
-
IF(DEAL_II_COMPILER_HAS_RDYNAMIC)
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -rdynamic")
ENDIF()
ENDIF()
ENDIF()
+
+
+
+#
+# Check whether the -as-needed flag is available. If so set it to compile
+# the deal.II library
+#
+CHECK_CXX_COMPILER_FLAG(
+ "-Wl,-as-needed"
+ DEAL_II_COMPILER_HAS_AS_NEEDED)
+
+IF(DEAL_II_COMPILER_HAS_AS_NEEDED)
+ SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-as-needed")
+ENDIF()
INCLUDE(CheckCXXSourceCompiles)
+INCLUDE(CheckCXXCompilerFlag)
INCLUDE(CheckCXXSourceRuns)
INCLUDE(CheckIncludeFiles)
# See if there is a compiler flag to enable C++0x features
# (Only test for -std=c++0x for the moment.)
-
-# Set CMAKE_REQUIRED_FLAGS for the unit tests
-LIST(APPEND CMAKE_REQUIRED_FLAGS "-std=c++0x")
-
-CHECK_CXX_SOURCE_COMPILES(
- "
- int main(){ return 0; }
- "
+CHECK_CXX_COMPILER_FLAG(
+ "-std=c++0x"
DEAL_II_HAVE_CXX0X_FLAG)
-
IF(DEAL_II_HAVE_CXX0X_FLAG)
+ # Set CMAKE_REQUIRED_FLAGS for the unit tests
+ LIST(APPEND CMAKE_REQUIRED_FLAGS "-std=c++0x")
+
CHECK_CXX_SOURCE_COMPILES(
"
#include <array>
ENDIF()
ENDIF()
+ LIST(REMOVE_ITEM CMAKE_REQUIRED_FLAGS "-std=c++0x")
+
ELSE()
MESSAGE(STATUS "Insufficient C++0x support. Disabling -std=c++0x.")
ENDIF()
-LIST(REMOVE_ITEM CMAKE_REQUIRED_FLAGS "-std=c++0x")
-
CHECK_CXX_SOURCE_COMPILES(
INCLUDE_DIRECTORIES(${MPI_CXX_INCLUDE_PATH})
-LIST(APPEND deal_ii_required_linker_flags ${MPI_CXX_LINK_FLAGS})
+SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${MPI_CXX_LINK_FLAGS}")
+
LIST(APPEND deal_ii_external_libraries ${MPI_CXX_LIBRARIES})
SET(DEAL_II_COMPILER_SUPPORTS_MPI TRUE)
FIND_PACKAGE(Threads REQUIRED)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_THREAD_LIBS_INIT}")
-LIST(APPEND deal_ii_required_linker_flags ${CMAKE_THREAD_LIBS_INIT})
+
+SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_THREAD_LIBS_INIT}")
SET(DEAL_II_USE_MT TRUE)