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)
project (Pastis
VERSION 0.0.4)
#------------------------------------------------------
set(PASTIS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_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 "")
endif()
# sets Kokkos debug flags when non release build
if (CMAKE_BUILD_TYPE MATCHES "Release")
set (KOKKOS_ENABLE_DEBUG OFF)
else()
set (KOKKOS_ENABLE_DEBUG ON)
endif()
# Pastis default compiler flags
set(PASTIS_CXX_FLAGS "-Wall")
#set(CMAKE_CXX_STANDARD "17")
# C++ 17 flags
if(${CMAKE_VERSION} VERSION_LESS "3.8.0")
message(WARNING "Please consider to switch to CMake >= 3.8")
set(PASTIS_CXX_FLAGS "${PASTIS_CXX_FLAGS} -std=gnu++1z")
else()
set(CMAKE_CXX_STANDARD "17")
endif()
add_subdirectory(${PASTIS_SOURCE_DIR}/packages/kokkos)
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
include(GetKokkosCompilerFlags)
......@@ -89,4 +118,3 @@ target_link_libraries(
PastisUtils
PastisMesh
PastisExperimental)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment