forked from SpinWaveGenie/SpinWaveGenie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
170 lines (141 loc) · 5.88 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
cmake_minimum_required (VERSION 3.1)
project(SpinWaveGenie)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
set(CMAKE_MACOSX_RPATH TRUE)
set(SPINWAVEGENIE_VERSION_MAJOR "0")
set(SPINWAVEGENIE_VERSION_MINOR "3")
set(SPINWAVEGENIE_VERSION_PATCH "0")
set(SPINWAVEGENIE_VERSION "${SPINWAVEGENIE_VERSION_MAJOR}.${SPINWAVEGENIE_VERSION_MINOR}.${SPINWAVEGENIE_VERSION_PATCH}")
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)
if(BUILD_TESTING)
enable_testing()
endif(BUILD_TESTING)
# We probably don't want this to run on every build.
option(COVERALLS "Generate coveralls data" OFF)
if (COVERALLS)
option(COVERALLS_TRAVISCI "Generate coveralls data for travis-ci" ON)
option(COVERALLS_UPLOAD "Automatically upload coveralls data" ON)
include(Coveralls)
coveralls_turn_on_coverage()
endif()
set(CMAKE_CXX_STANDARD 14)
set(CXX_STANDARD_REQUIRED 14)
# XCode isn't picking up the standard set above.
if(CMAKE_GENERATOR STREQUAL Xcode)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++14")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
string(APPEND CMAKE_CXX_FLAGS " -DEIGEN_DONT_PARALLELIZE -Wall -Wextra")
endif()
option(WITH_SANITIZERS "Enable sanitizers" OFF)
if(WITH_SANITIZERS)
message(STATUS "enabling address & undefined behavior sanitizers")
file(WRITE ${PROJECT_BINARY_DIR}/ubsan.txt "fun:*_Ios_Fmtflags*")
set(SAN_FLAGS "-fno-omit-frame-pointer -fno-common -fsanitize=address,undefined -fno-sanitize-recover=all -fsanitize-blacklist=${PROJECT_BINARY_DIR}/ubsan.txt")
add_compile_options(-fno-omit-frame-pointer -fno-common -fsanitize=address,undefined -fno-sanitize-recover=all -fsanitize-blacklist=${PROJECT_BINARY_DIR}/ubsan.txt)
string(APPEND CMAKE_MODULE_LINKER_FLAGS "${SAN_FLAGS}" )
string(APPEND CMAKE_EXE_LINKER_FLAGS "${SAN_FLAGS}" )
string(APPEND CMAKE_SHARED_LINKER_FLAGS "${SAN_FLAGS}" )
endif()
option(WARNINGS_AS_ERRORS "Treat warnings as errors" OFF)
if(WARNINGS_AS_ERRORS)
if(MSVC)
add_compile_options(/WX)
else()
add_compile_options(-Werror)
endif()
endif()
include(Eigen)
find_package(Threads)
if(USE_THREADS)
find_package(TBB)
endif()
find_package(Boost REQUIRED COMPONENTS unit_test_framework)
if(MSVC)
add_compile_options(/wd4251)
endif()
if(WIN32)
add_definitions( -DBOOST_ALL_NO_LIB
-DBOOST_ALL_DYN_LINK
-D_CRT_SECURE_NO_WARNINGS
-D_USE_MATH_DEFINES
-DNOMINMAX
)
endif()
option(BUILD_EXAMPLES "Build SpinWaveGenie Examples" OFF)
option(BUILD_TESTING "Build unit tests" OFF)
option(ENABLE_DOXYGEN "Enables building of documentation with doxygen" OFF)
option(USE_THREADS "Use Threading Building Blocks to improve performance" ON)
if(BUILD_TESTING)
enable_testing()
endif(BUILD_TESTING)
if(USE_THREADS AND TBB_FOUND )
add_definitions(-DUSE_THREADS)
endif()
# add a target to generate API documentation with Doxygen
find_package(Doxygen)
if(ENABLE_DOXYGEN AND DOXYGEN_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
add_custom_target(doc
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
endif()
option( PYTHON_API "Build Python bindings for SpinWaveGenie" ON)
if(PYTHON_API)
add_subdirectory( pybind11 )
endif()
add_subdirectory(libSpinWaveGenie)
if(PYTHON_API)
add_subdirectory(pythonapi)
endif()
if(BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
######################################################################
# configure everything for cpack
set ( CPACK_PACKAGE_NAME SpinWaveGenie )
set ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "Library for simplifying linear spin wave calculations" )
set ( CPACK_PACKAGE_VERSION_MAJOR "${SPINWAVEGENIE_VERSION_MAJOR}" )
set ( CPACK_PACKAGE_VERSION_MINOR "${SPINWAVEGENIE_VERSION_MINOR}" )
set ( CPACK_PACKAGE_VERSION_PATCH "${SPINWAVEGENIE_VERSION_PATCH}" )
set ( CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}" )
set ( CPACK_PACKAGE_VENDOR "Steven Hahn" )
set ( CPACK_PACKAGE_URL "http://github.com/SpinWaveGenie/SpinWaveGenie" )
set ( CPACK_PACKAGE_CONTACT "[email protected]" )
set ( CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} )
set ( CPACK_RESOURCE_FILE_README ${CMAKE_CURRENT_SOURCE_DIR}/README.md )
set ( CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE )
set ( CPACK_RPM_PACKAGE_LICENSE "BSD 3-clause License" )
set ( CPACK_RPM_PACKAGE_RELEASE 1 )
set ( CPACK_RPM_PACKAGE_URL "${CPACK_PACKAGE_URL}" )
set ( CPACK_RPM_PACKAGE_GROUP "Development/Tools" )
set ( CPACK_RPM_PACKAGE_REQUIRES "gcc-c++ doxygen boost-test boost-devel" )
if ( "${UNIX_DIST}" MATCHES "Fedora" )
string ( APPEND CPACK_RPM_PACKAGE_REQUIRES " cmake >= 3.1" )
else ()
string ( APPEND CPACK_RPM_PACKAGE_REQUIRES " cmake3 >= 3.1" )
endif()
if(USE_THREADS AND TBB_FOUND )
string ( APPEND CPACK_RPM_PACKAGE_REQUIRES " tbb-devel" )
set ( CPACK_RPM_USE_THREADS "1" )
else()
set ( CPACK_RPM_USE_THREADS "0" )
endif()
if(PYTHON_API)
string ( APPEND CPACK_RPM_PACKAGE_REQUIRES " python2-devel" )
endif()
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/SpinWaveGenie.spec.in
${CMAKE_CURRENT_BINARY_DIR}/SpinWaveGenie.spec )
add_custom_command( OUTPUT SpinWaveGenie-${CPACK_PACKAGE_VERSION}.tar.gz
COMMAND git archive-all --prefix=SpinWaveGenie-${CPACK_PACKAGE_VERSION}/ ${CMAKE_CURRENT_BINARY_DIR}/SpinWaveGenie-${CPACK_PACKAGE_VERSION}.tar.gz
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_custom_target( source_tgz
DEPENDS SpinWaveGenie-${CPACK_PACKAGE_VERSION}.tar.gz )