forked from pwarren/rtl-entropy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
171 lines (149 loc) · 6.04 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
# rtl-entropy, turns your Realtek RTL2832 based DVB dongle into a
# high quality entropy source.
#
# Copyright (C) 2013 by Paul Warren <[email protected]>
#
# Parts taken from:
# - rtl_test. Copyright (C) 2012 by Steve Markgraf <[email protected]>
# - http://openfortress.org/cryptodoc/random/noise-filter.c
# by Rick van Rein <[email protected]>
# - snd-egd Copyright (C) 2008-2010 Nicholas J. Kain <nicholas aatt kain.us>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# In addition, as a special exception, the copyright holders give
# permission to link the code of portions of this program with the
# OpenSSL library under certain conditions as described in each
# individual source file, and distribute linked combinations
# including the two.
# You must obey the GNU General Public License in all respects
# for all of the code used other than OpenSSL. If you modify
# file(s) with this exception, you may extend this exception to your
# version of the file(s), but you are not obligated to do so. If you
# do not wish to do so, delete this exception statement from your
# version. If you delete this exception statement from all source
# files in the program, then also delete it here.
########################################################################
# Project setup
########################################################################
cmake_minimum_required(VERSION 2.6)
project(rtl-entropy C)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
#select the release build type by default to get optimization flags
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
message(STATUS "Build type not specified: defaulting to release.")
endif(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "")
if(NOT EXEC_INSTALL_DIR)
set(EXEC_INSTALL_DIR bin)
endif()
if(NOT LIB_INSTALL_DIR)
set(LIB_INSTALL_DIR lib)
endif()
# Set the version information here
set(VERSION_INFO_MAJOR_VERSION 0)
set(VERSION_INFO_MINOR_VERSION 1)
set(VERSION_INFO_PATCH_VERSION 2)
include(Version)
########################################################################
# Compiler specific setup
########################################################################
IF(CMAKE_CXX_COMPILER MATCHES ".*clang")
SET(CMAKE_COMPILER_IS_CLANGXX 1)
ENDIF()
IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
ADD_DEFINITIONS(-Wall)
ADD_DEFINITIONS(-Wextra)
ADD_DEFINITIONS(-Wno-unused-parameter)
ADD_DEFINITIONS(-Wsign-compare)
#ADD_DEFINITIONS(-Wconversion)
ADD_DEFINITIONS(-pedantic)
#ADD_DEFINITIONS(-ansi)
IF(NOT WIN32)
#only export symbols that are declared to be part of the api (non dll platforms)
ADD_DEFINITIONS(-fvisibility=hidden)
ADD_DEFINITIONS(-fvisibility-inlines-hidden)
ENDIF(NOT WIN32)
ENDIF()
########################################################################
# Find build dependencies
########################################################################
find_package(PkgConfig)
find_package(LibRTLSDR)
find_package(LibbladeRF)
find_package(OpenSSL)
IF(NOT ((${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") OR
(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")))
find_package(LibCAP)
ENDIF(NOT ((${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") OR
(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")))
IF((${CMAKE_SYSTEM_NAME} MATCHES "Darwin"))
set(OPENSSL_INCLUDE_DIRS /usr/local/opt/openssl/include)
ENDIF((${CMAKE_SYSTEM_NAME} MATCHES "Darwin"))
########################################################################
# Setup the include and linker paths
########################################################################
include_directories(
${OPENSSL_INCLUDE_DIRS}
${LIBRTLSDR_INCLUDE_DIRS}
)
IF(NOT ((${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") OR
(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")))
include_directories(
${LibCAP_INCLUDE_DIR}
)
ENDIF(NOT ((${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") OR
(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")))
link_directories(
${OPENSSL_LIBRARIES}
${LIBRTLSDR_LIBRARIES}
)
IF(NOT ((${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") OR
(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")))
link_directories(
${LibCAP_LIBRARY}
)
ENDIF(NOT ((${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") OR
(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")))
add_subdirectory(src)
########################################################################
# 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
)
########################################################################
# Create Pkg Config File
########################################################################
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix \${prefix}/bin)
set(libdir \${exec_prefix}/${LIB_INSTALL_DIR})
set(includedir \${prefix}/include)
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/rtl-entropy.pc.in
${CMAKE_CURRENT_BINARY_DIR}/rtl-entropy.pc
@ONLY)
INSTALL(
FILES ${CMAKE_CURRENT_BINARY_DIR}/rtl-entropy.pc
DESTINATION ${LIB_INSTALL_DIR}/pkgconfig
)
########################################################################
# Print Summary
########################################################################
MESSAGE(STATUS "Building for version: ${VERSION} / ${LIBVER}")
MESSAGE(STATUS "Using install prefix: ${CMAKE_INSTALL_PREFIX}")