forked from amontoison/nomad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
69 lines (54 loc) · 2.08 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# ----------------------------------------------------------------------------
# Root CMake file for Nomad
# ----------------------------------------------------------------------------
# cmake version : the latest one
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
# name of the project
project(Nomad
VERSION 4.0.0
LANGUAGES C CXX)
# use standard compilers parameters for c++14
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Disable in-source builds to prevent source tree corruption.
if(" ${CMAKE_SOURCE_DIR}" STREQUAL " ${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "FATAL: In-source builds are not allowed.
You should create a separate directory for build files.
")
endif()
# Check compiler version
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# require at least gcc 4
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7)
message(FATAL_ERROR "GCC version < 8 has not been tested for Nomad!")
endif()
elseif (("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
# require at least clang 5
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5)
message(FATAL_ERROR "Clang version has not been tested for Nomad!")
endif()
else()
message(WARNING "You are using an unsupported compiler! Compilation has only been tested with Clang and GCC.")
endif()
# Options
# build Nomad with openMP (only work with gcc compiler)
option(NOMAD_WITH_OPENMP "Enable OpenMP flags." ON)
# build Nomad examples
option(NOMAD_WITH_EXAMPLES "Build Nomad examples." ON)
# choose to build with unit tests
# option(BUILD_TESTS "Build unit tests programs" OFF)
# choose to build with benchmarks
# option(BUILD_BENCHMARKS "Build benchmark tests" OFF)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
# special flag required
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Add sgtelib
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/ext)
# Add nomad directory
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src)
if (NOMAD_WITH_EXAMPLES)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/examples)
endif()