-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
79 lines (65 loc) · 1.92 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
cmake_minimum_required(VERSION 3.1)
project(
"Digital Signal Analysis C library"
VERSION 1.0
LANGUAGES C
)
if(NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
endif()
option(DSAC_DEBUG "Activate debug build" OFF)
option(DSAC_OPENMP "Activate the OpenMP parallelization" OFF)
# CFLAGS
# assume it's a GNU-like compiler (GCC, clang)
set(CMAKE_C_FLAGS "-Wall -Wextra -pedantic")
set(CMAKE_C_FLAGS_DEBUG "-O0 -g")
set(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG")
set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")
if (DSAC_DEBUG)
message(STATUS "Debug enable")
set(CMAKE_BUILD_TYPE Debug)
endif()
# Option for OpenMP
if (DSAC_OPENMP)
find_package(OpenMP)
if (OPENMP_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS} -DDSA_OPENMP")
message(STATUS "OpenMP enable")
else()
message(SEND_ERROR "OpenMP not found!")
endif()
else()
message(STATUS "OpenMP disable")
endif()
# Documentation
find_package(Doxygen)
if(DOXYGEN_FOUND)
configure_file("${CMAKE_SOURCE_DIR}/Doxyfile.cmake" "${CMAKE_BINARY_DIR}/Doxyfile" @ONLY)
add_custom_target(doc ${DOXYGEN_EXECUTABLE} "${CMAKE_BINARY_DIR}/Doxyfile")
endif(DOXYGEN_FOUND)
# Depends
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/modules")
find_package(FFTW3 REQUIRED)
# Include library sources
add_subdirectory("src")
# Include GNUInstallDirs (if Unix system)
if(UNIX)
include(GNUInstallDirs)
endif()
# Rules for install
install(TARGETS dsac
EXPORT dsacConfig
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/dsac
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING
PATTERN "*.h"
PATTERN ".swp" EXCLUDE
)
install(
EXPORT dsacConfig
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/dsac"
)