forked from diatomic/diy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
55 lines (45 loc) · 2.29 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
project (DIY)
cmake_minimum_required (VERSION 3.0)
option (threads "Build DIY with threading" ON)
option (log "Build DIY with logging" OFF)
option (profile "Build DIY with profiling" OFF)
# Default to Release
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
set_property (CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif (NOT CMAKE_BUILD_TYPE)
# Debugging
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug" OR
${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo")
add_definitions (-DDEBUG)
endif ()
# Logging
if (log)
add_definitions (-DDIY_USE_SPDLOG)
find_path (SPDLOG_INCLUDE_DIR spdlog/spdlog.h)
include_directories (${SPDLOG_INCLUDE_DIR})
endif()
# Profiling
if (profile)
add_definitions (-DDIY_PROFILE)
endif()
# C++11
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
find_package (MPI REQUIRED)
set (mpi_libraries ${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES})
set (libraries ${libraries} ${mpi_libraries})
if (NOT threads)
add_definitions (-DDIY_NO_THREADS)
else (NOT threads)
find_package (Threads)
set (libraries ${libraries} ${CMAKE_THREAD_LIBS_INIT})
endif (NOT threads)
# Set includes
set (CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem")
include_directories (${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
SYSTEM ${MPI_INCLUDE_PATH})
enable_testing ()
add_subdirectory (examples)
add_subdirectory (tests)