-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathCMakeLists.txt
129 lines (110 loc) · 3.82 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
##################################################
# Main build file for Polyquad
##################################################
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
INCLUDE(CheckIncludeFiles)
PROJECT(polyquad)
# Add our custom CMake module dir
SET(CMAKE_MODULE_PATH ${polyquad_SOURCE_DIR}/cmake)
SET(POLYQUAD_VERSION_MAJOR 1)
SET(POLYQUAD_VERSION_MINOR 1)
SET(POLYQUAD_VERSION "${POLYQUAD_VERSION_MAJOR}.${POLYQUAD_VERSION_MINOR}")
##################################################
# Source files
##################################################
SET(POLYQUAD_HEADERS
src/actions/eval.hpp
src/actions/expand.hpp
src/actions/find.hpp
src/actions/iterate.hpp
src/shapes/base.hpp
src/shapes/hex.hpp
src/shapes/quad.hpp
src/shapes/tet.hpp
src/shapes/tri.hpp
src/shapes/pyr.hpp
src/shapes/pri.hpp
src/utils/io.hpp
src/utils/eigen_addons.hpp
src/utils/ortho_poly.hpp
src/utils/serialization.hpp
src/utils/timer.hpp)
##################################################
# Executable
##################################################
ADD_EXECUTABLE(polyquad src/main.cpp ${POLYQUAD_HEADERS})
##################################################
# Internal includes, these must come before the
# located dependencies!
##################################################
INCLUDE_DIRECTORIES(src)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
##################################################
# External dependencies
##################################################
SET(POLYQUAD_BOOST_LIBS
program_options
serialization)
# Find Boost
FIND_PACKAGE(Boost REQUIRED ${POLYQUAD_BOOST_LIBS})
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(polyquad ${Boost_LIBRARIES})
# Find Eigen 3
FIND_PACKAGE(Eigen3 REQUIRED)
INCLUDE_DIRECTORIES(${EIGEN3_INCLUDE_DIR} ${EIGEN3_INCLUDE_DIR}/unsupported)
##################################################
# MPI
##################################################
FIND_PACKAGE(MPI)
IF(MPI_CXX_FOUND)
FIND_PACKAGE(Boost COMPONENTS mpi)
IF(Boost_MPI_FOUND)
SET(CMAKE_CXX_COMPILE_FLAGS
${CMAKE_CXX_COMPILE_FLAGS}
${MPI_COMPILE_FLAGS})
SET(CMAKE_CXX_LINK_FLAGS ${CMAKE_CXX_LINK_FLAGS} ${MPI_LINK_FLAGS})
INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
TARGET_LINK_LIBRARIES(polyquad
${Boost_MPI_LIBRARY}
${MPI_CXX_LIBRARIES})
SET(POLYQUAD_HAVE_MPI 1)
ENDIF()
ENDIF()
# Avoid ';' in the link flags
STRING(REPLACE ";" " " CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS}")
##################################################
# C++17
##################################################
IF(UNIX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wno-deprecated")
ENDIF()
##################################################
# Build type
##################################################
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE RelWithDebInfo)
ENDIF()
##################################################
# Optimisation
##################################################
# Auto-optimise for CPU arch for non-debug builds
IF(NOT CMAKE_BUILD_TYPE MATCHES Debug)
ADD_DEFINITIONS("-O3 -march=native")
ENDIF()
# For release builds remove all debugging info
IF(CMAKE_BUILD_TYPE MATCHES Release)
ADD_DEFINITIONS("-DNDEBUG")
ENDIF()
##################################################
# Date & compiler info
##################################################
INCLUDE(Today)
TODAY(POLYQUAD_BUILD_DATE)
#INCLUDE(GetGitRevisionDescription)
#GET_GIT_HEAD_REVISION(GIT_REFSPEC POLYQUAD_GIT_SHA1)
##################################################
# Config.h
##################################################
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/config.h)