-
Notifications
You must be signed in to change notification settings - Fork 17
/
CMakeLists.txt
96 lines (73 loc) · 2.54 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
cmake_minimum_required(VERSION 3.9)
project(m17cxx
VERSION 0.1
DESCRIPTION "M17 Digital Voice modulation and demodulation"
LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
# Require out-of-source builds
file(TO_CMAKE_PATH "${PROJECT_BINARY_DIR}/CMakeLists.txt" LOC_PATH)
if(EXISTS "${LOC_PATH}")
message(FATAL_ERROR "You cannot build in a source directory (or any directory with a CMakeLists.txt file). Please make a build subdirectory. Feel free to remove CMakeCache.txt and CMakeFiles.")
endif()
if(NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE Release)
message(STATUS "Build type not specified: defaulting to release.")
endif()
# Check for dependencies
message(STATUS "# Checking dependencies")
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
include(GNUInstallDirs)
find_package(codec2 REQUIRED)
set(Boost_USE_STATIC_LIBS FALSE)
find_package(Boost COMPONENTS program_options REQUIRED)
if (BLAZE_INCLUDE_DIR)
# in cache already
set(BLAZE_FOUND TRUE)
message(STATUS "Have blaze")
else (BLAZE_INCLUDE_DIR)
find_path(BLAZE_INCLUDE_DIR NAMES blaze/Blaze.h
PATHS
${INCLUDE_INSTALL_DIR}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(BLAZE DEFAULT_MSG BLAZE_INCLUDE_DIR)
mark_as_advanced(BLAZE_INCLUDE_DIR)
message(STATUS "Found blaze")
endif(BLAZE_INCLUDE_DIR)
# Add subdirectories
add_subdirectory(src)
add_subdirectory(apps)
find_package(GTest)
if(GTEST_FOUND)
enable_testing()
add_subdirectory(tests)
endif()
# Setup installation
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${PROJECT_BINARY_DIR}/m17cxxConfigVersion.cmake"
VERSION 0.1
COMPATIBILITY AnyNewerVersion
)
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/m17cxxConfig.cmake.in"
"${PROJECT_BINARY_DIR}/m17cxxConfig.cmake"
INSTALL_DESTINATION lib/cmake/m17cxx
)
install(EXPORT m17cxxTargets DESTINATION lib/cmake/m17cxx)
install(FILES "${PROJECT_BINARY_DIR}/m17cxxConfigVersion.cmake"
"${PROJECT_BINARY_DIR}/m17cxxConfig.cmake"
DESTINATION lib/cmake/m17cxx)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include)
# Create uninstall target
configure_file(
${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
@ONLY)
add_custom_target(uninstall
${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
)
# Print summary
message(STATUS "Using install prefix: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "Building version: ${PROJECT_VERSION}")