Skip to content
Snippets Groups Projects
Commit 282b3a71 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Improved configuration

- checks for OpenMP before setting it as default value for Kokkos
- checks g++ (>7) or clang++ (>5)
- added a few warning to clang++
parent 9e9b3035
No related branches found
No related tags found
No related merge requests found
...@@ -13,36 +13,65 @@ include(CheckNotInSources) ...@@ -13,36 +13,65 @@ include(CheckNotInSources)
project (Pastis project (Pastis
VERSION 0.0.4) VERSION 0.0.4)
#------------------------------------------------------
set(PASTIS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") set(PASTIS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(PASTIS_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}") set(PASTIS_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
# Default build type is RelWIthDebInfo
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif(NOT CMAKE_BUILD_TYPE)
#------------------------------------------------------ #------------------------------------------------------
# Kokkos # Checks if compiler version is compatible with Pastis sources
set(GNU_CXX_MIN_VERSION "7.0.0")
set(CLANG_CXX_MIN_VERSION "5.0.0")
# Pastis default compiler flags
set(PASTIS_CXX_FLAGS "${PASTIS_CXX_FLAGS} -Wall")
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "${GNU_CXX_MIN_VERSION}")
message(FATAL_ERROR "Pastis build requires at least g++-${GNU_CXX_MIN_VERSION}")
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "${CLANG_CXX_MIN_VERSION}")
message(FATAL_ERROR "Pastis build requires at least llvm/clang ++-${CLANG_CXX_MIN_VERSION}")
endif()
set(PASTIS_CXX_FLAGS "${PASTIS_CXX_FLAGS} -Wsign-compare -Wunused -Wunused-member-function -Wunused-private-field")
endif()
#------------------------------------------------------
# setting Kokkos defaults to OpenMP when available
include(FindOpenMP)
if(${OPENMP_FOUND})
set(KOKKOS_ENABLE_OPENMP ON CACHE BOOL "") set(KOKKOS_ENABLE_OPENMP ON CACHE BOOL "")
endif()
# sets Kokkos debug flags when non release build
if (CMAKE_BUILD_TYPE MATCHES "Release") if (CMAKE_BUILD_TYPE MATCHES "Release")
set (KOKKOS_ENABLE_DEBUG OFF) set (KOKKOS_ENABLE_DEBUG OFF)
else() else()
set (KOKKOS_ENABLE_DEBUG ON) set (KOKKOS_ENABLE_DEBUG ON)
endif() endif()
# C++ 17 flags
# Pastis default compiler flags if(${CMAKE_VERSION} VERSION_LESS "3.8.0")
set(PASTIS_CXX_FLAGS "-Wall") message(WARNING "Please consider to switch to CMake >= 3.8")
set(PASTIS_CXX_FLAGS "${PASTIS_CXX_FLAGS} -std=gnu++1z")
#set(CMAKE_CXX_STANDARD "17") else()
set(CMAKE_CXX_STANDARD "17")
endif()
add_subdirectory(${PASTIS_SOURCE_DIR}/packages/kokkos) add_subdirectory(${PASTIS_SOURCE_DIR}/packages/kokkos)
include_directories(${Kokkos_INCLUDE_DIRS_RET}) include_directories(${Kokkos_INCLUDE_DIRS_RET})
# Default build type is RelWIthDebInfo
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif(NOT CMAKE_BUILD_TYPE)
# Kokkso compiler flags # Kokkso compiler flags
include(GetKokkosCompilerFlags) include(GetKokkosCompilerFlags)
...@@ -89,4 +118,3 @@ target_link_libraries( ...@@ -89,4 +118,3 @@ target_link_libraries(
PastisUtils PastisUtils
PastisMesh PastisMesh
PastisExperimental) PastisExperimental)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment