Select Git revision
CMakeLists.txt
-
Stéphane Del Pino authored
If `clang-format` is found the 'clang-format' target is defined. To build this target, clang format is run on pastis sources (c++) omitting 'packages' sources. It is better to configure editors to use clang-format than running this on the whole sources before pushing...
Stéphane Del Pino authoredIf `clang-format` is found the 'clang-format' target is defined. To build this target, clang format is run on pastis sources (c++) omitting 'packages' sources. It is better to configure editors to use clang-format than running this on the whole sources before pushing...
CMakeLists.txt 3.87 KiB
cmake_minimum_required (VERSION 3.4)
# CMake utils
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# Forbids in-source builds
include(CheckNotInSources)
#------------------------------------------------------
#----------------- Main configuration -----------------
#------------------------------------------------------
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)
#------------------------------------------------------
# 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()
# Kokkso compiler flags
add_subdirectory(${PASTIS_SOURCE_DIR}/packages/kokkos)
include_directories(${Kokkos_INCLUDE_DIRS_RET})
include(GetKokkosCompilerFlags)
# 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()
# C++ 17 flags
if(${CMAKE_VERSION} VERSION_LESS "3.8.0")