forked from guyt101z/codec2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
209 lines (179 loc) · 6.42 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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#
# Codec2 - Next-Generation Digital Voice for Two-Way Radio
#
# CMake configuration contributed by Richard Shaw (KF5OIM)
# Please report questions, comments, problems, or patches to the freetel
# mailing list: https://lists.sourceforge.net/lists/listinfo/freetel-codec2
#
project(codec2)
cmake_minimum_required(VERSION 2.8)
include(GNUInstallDirs)
mark_as_advanced(CLEAR
CMAKE_INSTALL_BINDIR
CMAKE_INSTALL_INCLUDEDIR
CMAKE_INSTALL_LIBDIR
)
#add_definitions( -DMATH_Q16_16 )
#
# Prevent in-source builds
# If an in-source build is attempted, you will still need to clean up a few
# files manually.
#
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "In-source builds in ${CMAKE_BINARY_DIR} are not "
"allowed, please remove ./CMakeCache.txt and ./CMakeFiles/, create a "
"separate build directory and run cmake from there.")
endif("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
#
# Set project version information. This should probably be done via external
# file at some point.
#
set(CODEC2_VERSION_MAJOR 0)
set(CODEC2_VERSION_MINOR 3)
# Set to patch level if needed, otherwise leave FALSE.
set(CODEC2_VERSION_PATCH FALSE)
set(CODEC2_VERSION "${CODEC2_VERSION_MAJOR}.${CODEC2_VERSION_MINOR}")
# Patch level version bumps should not change API/ABI.
set(SOVERSION "${CODEC2_VERSION_MAJOR}.${CODEC2_VERSION_MINOR}")
if(CODEC2_VERSION_PATCH)
set(CODEC2_VERSION "${CODEC2_VERSION}.${CODEC2_VERSION_PATCH}")
endif()
message(STATUS "codec2 version: ${CODEC2_VERSION}")
# Set default build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
endif()
# Set default C++ flags.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
# -fPIC is implied on MinGW...
if(NOT WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
endif()
message(STATUS "Build type is: " ${CMAKE_BUILD_TYPE})
message(STATUS "Compiler Flags: " ${CMAKE_CXX_FLAGS})
#
# Setup Windows/MinGW specifics here.
#
if(MINGW)
message(STATUS "System is MinGW.")
endif(MINGW)
#
# Find the svn revision if this is a working copy.
# WORK IN PROGRESS
# Works ok if it is a working copy but errors out if not.
#
#find_package(Subversion)
#if(Subversion_FOUND)
# Subversion_WC_INFO(${CMAKE_CURRENT_SOURCE_DIR} CODEC2)
# message(STATUS "codec2 svn revision: ${CODEC2_WC_REVISION}")
#else(SUBVERSION_FOUND)
# message(WARNING "Subversion not found. Can not determine svn revision.")
#endif(SUBVERSION_FOUND)
#
# Default options
#
option(BUILD_SHARED_LIBS
"Build shared library. Set to OFF for static library." ON)
option(UNITTEST "Build unittest binaries." OFF)
option(INSTALL_EXAMPLES "Install example code." OFF)
if(INSTALL_EXAMPLES)
install(DIRECTORY octave raw script voicing wav
USE_SOURCE_PERMISSIONS
DESTINATION ${CMAKE_INSTALL_DATADIR}/codec2)
endif()
# Math library is automatic on windows
if(UNIX)
set(CMAKE_REQUIRED_INCLUDES math.h)
set(CMAKE_REQUIRED_LIBRARIES m)
endif(UNIX)
include(CheckIncludeFiles)
check_include_files("stdlib.h" HAVE_STDLIB_H)
check_include_files("string.h" HAVE_STRING_H)
include(CheckFunctionExists)
check_function_exists(floor HAVE_FLOOR)
check_function_exists(ceil HAVE_CEIL)
check_function_exists(pow HAVE_POW)
check_function_exists(sqrt HAVE_SQRT)
check_function_exists(sin HAVE_SIN)
check_function_exists(cos HAVE_COS)
check_function_exists(atan2 HAVE_ATAN2)
check_function_exists(log10 HAVE_LOG10)
check_function_exists(round HAVE_ROUND)
check_function_exists(getopt HAVE_GETOPT)
configure_file ("${PROJECT_SOURCE_DIR}/cmake/config.h.in"
"${PROJECT_BINARY_DIR}/config.h" )
include_directories(${PROJECT_BINARY_DIR})
# message(STATUS "Looking for Fix Math Library.")
# find_path(LIBFIXMATH_INCLUDE_DIR fixmath.h)
# find_library(LIBFIXMATH_LIBRARY libfixmath)
# message(STATUS " Fix Math headers: ${SPEEXDSP_INCLUDE_DIR}")
# message(STATUS " Fix Math library: ${SPEEXDSP_LIBRARY}")
# if(NOT LIBFIXMATH_INCLUDE_DIR AND NOT LIBFIXMATH_LIBRARY)
# message(FATAL_ERROR "Libfixmath library not found!")
# endif()
# CMake Package setup
#include(CMakePackageConfigHelpers)
#configure_package_config_file(cmake/codec2-config.cmake.in
# ${CMAKE_CURRENT_BINARY_DIR}/codec2-config.cmake
# INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/codec2
# PATH_VARS CMAKE_INSTALL_INCLUDEDIR
#)
#
# codec2 library
#
add_subdirectory(src)
if(UNITTEST)
# Pthread Library
find_package(Threads REQUIRED)
message(STATUS "Threads library flags: ${CMAKE_THREAD_LIBS_INIT}")
#
# Find speex library
#
message(STATUS "Looking for Speex DSP library.")
find_path(SPEEXDSP_INCLUDE_DIR speex/speex.h)
find_library(SPEEXDSP_LIBRARY speexdsp)
message(STATUS " Speex DSP headers: ${SPEEXDSP_INCLUDE_DIR}")
message(STATUS " Speex DSP library: ${SPEEXDSP_LIBRARY}")
if(NOT SPEEXDSP_INCLUDE_DIR AND NOT SPEEXDSP_LIBRARY)
message(FATAL_ERROR "Speex DSP library not found!")
endif()
add_subdirectory(unittest)
endif(UNITTEST)
#
# Cpack NSIS installer configuration for Windows.
# See: http://nsis.sourceforge.net/Download
#
# *nix systems should use "make install" and/or appropriate
# distribution packaging tools.
#
if(WIN32)
# Detect if we're doing a 32-bit or 64-bit windows build.
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
set(CMAKE_CL_64 TRUE)
endif()
configure_file(cmake/GetDependencies.cmake.in cmake/GetDependencies.cmake
@ONLY
)
install(SCRIPT ${CMAKE_BINARY_DIR}/cmake/GetDependencies.cmake)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Next-Generation Digital Voice for Two-Way Radio")
set(CPACK_PACKAGE_VENDOR "CMake")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
set(CPACK_PACKAGE_VERSION_MAJOR ${CODEC2_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${CODEC2_VERSION_MINOR})
if(CODEC2_VERSION_PATCH)
set(CPACK_PACKAGE_VERSION_PATCH ${CODEC2_VERSION_PATCH})
else()
set(CPACK_PACKAGE_VERSION_PATCH 0)
endif()
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Codec2")
set(CPACK_CREATE_DESKTOP_LINKS "")
set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
set(CPACK_NSIS_URL_INFO_ABOUT "http://codec2.org")
set(CPACK_NSIS_MODIFY_PATH ON)
include(CPack)
endif(WIN32)