forked from arcosuc3m/grppi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
139 lines (122 loc) · 4.64 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
cmake_minimum_required (VERSION 3.2.0)
set(PROJECT_NAME_STR grppi)
project(${PROJECT_NAME_STR})
# Path for additional CMake modules
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake.modules)
# Print processor and compiler
message(STATUS "Detected processor is " ${CMAKE_SYSTEM_PROCESSOR} )
message(STATUS "CMAKE_C_COMPILER: " ${CMAKE_C_COMPILER} )
message(STATUS "CMAKE_CXX_COMPILER: " ${CMAKE_CXX_COMPILER} )
message(STATUS "CMAKE_CXX_COMPILER_ID: " ${CMAKE_CXX_COMPILER_ID} )
set(CMAKE_CXX_STANDARD 14)
add_compile_options(-Wall -Werror -pedantic -pedantic-errors -Wextra)
# Set specific options depending on compiler
if ( ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" )
if(NOT(${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER 3.9.0))
message(FATAL_ERROR "Clang version " ${CMAKE_CXX_COMPILER_VERSION}
" not supported. Upgrade to 3.9 or above.")
else()
message( STATUS "C++ Compiler is Clang" )
endif()
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
if(NOT(${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER 6.0))
message(FATAL_ERROR "g++ version " ${CMAKE_CXX_COMPILER_VERSION}
" not supported. Upgrade to 6.0 or above.")
else()
message( STATUS "C++ Compiler is GNU")
if (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER 7.0)
#g++ 7 warns in non C++17 for over-aligned new otherwise
add_compile_options(-faligned-new)
endif()
endif()
elseif ( ${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel" )
message(FATAL_ERROR "Intel compiler is not currently supported")
# if(NOT(${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER 16.0))
# message( FATAL_ERROR "Intel version " ${CMAKE_CXX_COMPILER_VERSION}
# " not supported. Upgrade to 16.0 or above.")
# else()
# message( STATUS "C++ Compiler is Intel" )
# message( WARNING "WARNING: GrPPI has not been fully tested with Intel compiler." )
# endif()
else()
message( FATAL_ERROR "Unsupported compiler: "
${CMAKE_CXX_COMPILER_ID}
${CMAKE_CXX_COMPILER_VERSION})
endif()
# GrPPI library
include_directories("${CMAKE_SOURCE_DIR}/include")
# TBB Library
find_package( TBB )
if( TBB_FOUND )
option(GRPPI_TBB_ENABLE "Require TBB library" ON)
message(STATUS "TBB found")
else( TBB_FOUND )
option(GRPPI_TBB_ENABLE "Require TBB library" OFF )
set(GRPPI_TBB_ENABLE OFF CACHE BOOL "Require TBB library" FORCE)
message(STATUS "TBB not found")
endif( TBB_FOUND )
message( STATUS "TBB: " ${GRPPI_TBB_ENABLE} )
if( GRPPI_TBB_ENABLE )
include_directories(${TBB_INCLUDE_DIRS} )
add_definitions(-DGRPPI_TBB)
endif( GRPPI_TBB_ENABLE )
# Threads Library
find_package(Threads REQUIRED)
# OMP library
find_package(OpenMP)
if (OPENMP_FOUND)
option( GRPPI_OMP_ENABLE "Require OpenMP library" ON )
message(STATUS "OpenMP found")
else(OPENMP_FOUND)
option( GRPPI_OMP_ENABLE "Require OpenMP library" OFF )
set(GRPPI_OMP_ENABLE OFF CACHE BOOL "Require OpenMP library" FORCE)
message(STATUS "OpenMP not found")
endif (OPENMP_FOUND)
message( STATUS "OpenMP: " ${GRPPI_OMP_ENABLE})
if( GRPPI_OMP_ENABLE )
add_definitions(-DGRPPI_OMP)
add_compile_options(${OpenMP_CXX_FLAGS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif( GRPPI_OMP_ENABLE )
#FastFlow library
find_package(FF)
if (FF_FOUND)
option( GRPPI_FF_ENABLE "Require FastFlow library" ON)
message(STATUS "FastFlow found")
else()
option(GRPPI_FF_ENABLE "Require FastFlow library" OFF)
set(GRPPI_FF_ENABLE OFF CACHE BOOL "Require FastFlow library" FORCE)
message(STATUS "FastFlow not found")
message(STATUS " GRPPI_FF_ENABLE has been set to OFF")
message(STATUS " To enable it, please, first install FastFlow")
message(STATUS " https://github.com/fastflow/fastflow")
endif()
message( STATUS "FastFlow: " ${GRPPI_FF_ENABLE})
if(GRPPI_FF_ENABLE)
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
set(GRPPI_FF_ENABLE OFF CACHE BOOL "Require Fastflow library" FORCE)
message(WARNING "Fastflow is not currently supported in Clang")
else()
add_definitions(-DGRPPI_FF)
include_directories(${FF_INCLUDE_DIRS})
endif()
endif(GRPPI_FF_ENABLE)
# Doxygen Documentation
option( GRPPI_DOXY_ENABLE "Require Doxygen library" OFF )
if( GRPPI_DOXY_ENABLE )
add_subdirectory(doxy)
endif( GRPPI_DOXY_ENABLE )
# Installation
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION "include/${CMAKE_PROJECT_NAME}"
FILES_MATCHING PATTERN "*.h")
# Example applications
option( GRPPI_EXAMPLE_APPLICATIONS_ENABLE "Sample tests" OFF )
if( GRPPI_EXAMPLE_APPLICATIONS_ENABLE )
add_subdirectory(samples)
endif( GRPPI_EXAMPLE_APPLICATIONS_ENABLE )
# Unit Tests
enable_testing()
option( GRPPI_UNIT_TEST_ENABLE "Unit tests" ON )
if( GRPPI_UNIT_TEST_ENABLE )
add_subdirectory(unit_tests)
endif( GRPPI_UNIT_TEST_ENABLE )