#
# Now, set the project and set up the rest:
#
-PROJECT(deal.II CXX C)
+PROJECT(deal.II CXX)
+ENABLE_LANGUAGE(C OPTIONAL)
INCLUDE(setup_deal_ii)
INCLUDE(setup_compiler_flags)
#
# Determine the Endianess of the platform:
#
-INCLUDE(TestBigEndian)
-TEST_BIG_ENDIAN(DEAL_II_WORDS_BIGENDIAN)
+IF(CMAKE_C_COMPILER_WORKS)
+ INCLUDE(TestBigEndian)
+ TEST_BIG_ENDIAN(DEAL_II_WORDS_BIGENDIAN)
+ELSE()
+ MESSAGE(STATUS
+ "No suitable C compiler was found! Assuming little endian platform."
+ )
+ENDIF()
IF(DEAL_II_ALLOW_PLATFORM_INTROSPECTION)
#
ENABLE_IF_SUPPORTED(CMAKE_REQUIRED_FLAGS "-pthread")
- FOREACH(_func ${DEAL_II_LAPACK_FUNCTIONS})
- STRING(TOUPPER ${_func} _func_uppercase)
- CHECK_FUNCTION_EXISTS(${_func} HAVE_${_func_uppercase})
- ENDFOREACH()
+ IF(CMAKE_C_COMPILER_WORKS)
+ FOREACH(_func ${DEAL_II_LAPACK_FUNCTIONS})
+ STRING(TOUPPER ${_func} _func_uppercase)
+ CHECK_FUNCTION_EXISTS(${_func} HAVE_${_func_uppercase})
+ ENDFOREACH()
+ ELSE()
+ MESSAGE(STATUS
+ "No suitable C compiler was found! Skipping LAPACK symbol check."
+ )
+ FOREACH(_func ${DEAL_II_LAPACK_FUNCTIONS})
+ SET_IF_EMPTY(HAVE_${_func_uppercase} TRUE)
+ ENDFOREACH()
+ ENDIF()
SET(CMAKE_REQUIRED_LIBRARIES)
STRIP_FLAG(CMAKE_REQUIRED_FLAGS "${LAPACK_LINKER_FLAGS}")
MACRO(FEATURE_MPI_FIND_EXTERNAL var)
#
- # Enable Fortran support so that MPI_Fortran_LIBRARIES is set up.
+ # Enable C and Fortran support so that MPI_Fortran_LIBRARIES is set up.
#
IF(NOT CMAKE_Fortran_COMPILER_WORKS)
ENABLE_LANGUAGE(Fortran OPTIONAL)
# directly.
#
SET_IF_EMPTY(MPI_CXX_COMPILER ${CMAKE_CXX_COMPILER})
- SET_IF_EMPTY(MPI_C_COMPILER ${CMAKE_C_COMPILER}) # for good measure
- SET_IF_EMPTY(MPI_Fortran_COMPILER ${CMAKE_Fortran_COMPILER}) # for good measure
+ IF(CMAKE_C_COMPILER_WORKS)
+ SET_IF_EMPTY(MPI_C_COMPILER ${CMAKE_C_COMPILER}) # for good measure
+ ELSE()
+ MESSAGE(STATUS
+ "No suitable C compiler was found! MPI C interface can not be "
+ "autodetected"
+ )
+ ENDIF()
+ IF(CMAKE_Fortran_COMPILER_WORKS)
+ SET_IF_EMPTY(MPI_Fortran_COMPILER ${CMAKE_Fortran_COMPILER}) # for good measure
+ ELSE()
+ MESSAGE(STATUS
+ "No suitable Fortran compiler was found! MPI Fortran interface can "
+ "not be autodetected"
+ )
+ ENDIF()
FIND_PACKAGE(MPI)
IF(NOT MPI_CXX_FOUND)
#
MACRO(SETUP_THREADING)
#
- # Switch the library preference back to prefer dynamic libraries if
- # DEAL_II_PREFER_STATIC_LIBS=TRUE but DEAL_II_STATIC_EXECUTABLE=FALSE. In
- # this case system libraries should be linked dynamically.
+ # Unfortunately the FindThreads macro needs a working C compiler
#
- SWITCH_LIBRARY_PREFERENCE()
- FIND_PACKAGE(Threads)
- SWITCH_LIBRARY_PREFERENCE()
+ IF(CMAKE_C_COMPILER_WORKS)
+ #
+ # Switch the library preference back to prefer dynamic libraries if
+ # DEAL_II_PREFER_STATIC_LIBS=TRUE but DEAL_II_STATIC_EXECUTABLE=FALSE. In
+ # this case system libraries should be linked dynamically.
+ #
+ SWITCH_LIBRARY_PREFERENCE()
+ FIND_PACKAGE(Threads)
+ SWITCH_LIBRARY_PREFERENCE()
+
+ ELSE()
+
+ #
+ # We have no way to query for thread support. Just assume that it is
+ # provided by Pthreads...
+ #
+ MESSAGE(STATUS
+ "No suitable C compiler was found! Assuming threading is provided by Pthreads."
+ )
+ SET_IF_EMPTY(Threads_FOUND TRUE)
+ SET_IF_EMPTY(CMAKE_THREAD_LIBS_INIT "-lpthread")
+ SET_IF_EMPTY(CMAKE_USE_PTHREADS_INIT TRUE)
+ ENDIF()
IF(NOT Threads_FOUND)
- # TODO:
+ #
+ # TODO: This is a dead end. Threading might be setup with internal TBB
+ # so we have no way of returning unsuccessfully...
+ #
MESSAGE(FATAL_ERROR
"\nInternal configuration error: No Threading support found\n\n"
)
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELWITHDEBINFO
+ CMAKE_Fortran_FLAGS_RELEASE
+ CMAKE_Fortran_FLAGS_DEBUG
+ CMAKE_Fortran_FLAGS_MINSIZEREL
+ CMAKE_Fortran_FLAGS_RELWITHDEBINFO
CMAKE_SHARED_LINKER_FLAGS
CMAKE_SHARED_LINKER_FLAGS_DEBUG
CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL
# Set cached compiler flags to an empty string:
#
SET(DEAL_II_USED_FLAGS
- CMAKE_C_FLAGS
CMAKE_CXX_FLAGS
DEAL_II_CXX_FLAGS_DEBUG
DEAL_II_CXX_FLAGS_RELEASE
#
-# Finally, read in CFLAGS, CXXFLAGS and LDFLAGS from environment and
-# prepend them to the saved variables:
+# Finally, read in CXXFLAGS and LDFLAGS from environment and prepend them
+# to the saved variables:
#
-SET(CMAKE_C_FLAGS_SAVED "$ENV{CFLAGS} ${CMAKE_C_FLAGS_SAVED}")
SET(CMAKE_CXX_FLAGS_SAVED "$ENV{CXXFLAGS} ${CMAKE_CXX_FLAGS_SAVED}")
SET(DEAL_II_LINKER_FLAGS_SAVED "$ENV{LDFLAGS} ${DEAL_II_LINKER_FLAGS_SAVED}")
-UNSET(ENV{CFLAGS})
UNSET(ENV{CXXFLAGS})
UNSET(ENV{LDFLAGS})
###########################################################################
#
-# Check the user provided C and CXX flags:
+# Check the user provided CXX flags:
+#
+#
+# Omit to test for a sane C and Fortran toolchain for now..
#
-
-IF(NOT "${CMAKE_C_FLAGS_SAVED}" STREQUAL "${DEAL_II_C_FLAGS_SAVED}")
- UNSET(DEAL_II_HAVE_USABLE_C_FLAGS CACHE)
-ENDIF()
-SET(DEAL_II_C_FLAGS_SAVED "${CMAKE_C_FLAGS_SAVED}" CACHE INTERNAL "" FORCE)
-
-SET(CMAKE_REQUIRED_FLAGS "${CMAKE_C_FLAGS_SAVED}")
-CHECK_C_SOURCE_COMPILES(
- "int main(){ return 0; }"
- DEAL_II_HAVE_USABLE_C_FLAGS)
-SET(CMAKE_REQUIRED_FLAGS "")
-
-IF(NOT DEAL_II_HAVE_USABLE_C_FLAGS)
- UNSET(DEAL_II_HAVE_USABLE_C_FLAGS CACHE)
- MESSAGE(FATAL_ERROR "\n"
- "Configuration error: Cannot compile with the specified C flags: "
- "${CMAKE_C_FLAGS_SAVED}\n"
- )
-ENDIF()
-
-
IF(NOT "${CMAKE_CXX_FLAGS_SAVED}" STREQUAL "${DEAL_II_CXX_FLAGS_SAVED}")
UNSET(DEAL_II_HAVE_USABLE_CXX_FLAGS CACHE)
ENDIF()
ENDIF()
-#
-# CMAKE_C_COMPILER and CMAKE_CXX_COMPILER have to be of the same brand.
-#
-IF(NOT ( "${CMAKE_C_COMPILER_ID}" STREQUAL "${CMAKE_CXX_COMPILER_ID}" AND
- "${CMAKE_C_COMPILER_VERSION}" STREQUAL "${CMAKE_CXX_COMPILER_VERSION}" ) )
- MESSAGE(FATAL_ERROR "\n"
- "Configuration error: The specified C and CXX compiler have to be of the "
- "same family, but cmake found:\n"
- "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION}\n"
- "CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}\n"
- )
-ENDIF()
-
-
###########################################################################
# #
# Compiler setup: #
INCLUDE(CheckCXXCompilerFlag)
INCLUDE(CheckCXXSourceCompiles)
-INCLUDE(CheckCSourceCompiles)
INCLUDE(CheckCXXSourceRuns)
INCLUDE(CheckCXXSymbolExists)
INCLUDE(CheckIncludeFileCXX)