-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCmakeLists.txt
114 lines (91 loc) · 3.57 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
#
# IW0HDV Extio
#
# Copyright 2015 by Andrea Montefusco IW0HDV
#
# Licensed under GNU General Public License 3.0 or later.
# Some rights reserved. See COPYING, AUTHORS.
#
# @license GPL-3.0+ <http://spdx.org/licenses/GPL-3.0+>
#
#
# rm -f -r ./build ; mkdir build ; cd build ; cmake ../ -G "MSYS Makefiles" && make clean && make && make dist_perseus && make dist_hpsdr
#
cmake_minimum_required(VERSION 2.8)
include (GenerateExportHeader)
# the name of the target operating system
SET(CMAKE_SYSTEM_NAME Windows)
# here is the target environment located
SET(CMAKE_FIND_ROOT_PATH /c/MinGW/)
# which compilers to use for C and C++
#SET(CMAKE_C_COMPILER gcc)
#SET(CMAKE_CXX_COMPILER g++)
#SET(CMAKE_RC_COMPILER windres)
#SET(CMAKE_RC_LINKER g++)
#
# GIT hash generator
#
# http://stackoverflow.com/questions/1435953/how-can-i-pass-git-sha1-to-compiler-as-definition-using-cmake
# https://github.com/rpavlik/cmake-modules/blob/master/GetGitRevisionDescription.cmake.in
#
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
#### global macro not used: see util/CMakeFile.txt
#### add_definitions("-DGIT_SHA1=${GIT_SHA1}")
#
# parse the version information into pieces.
#
# http://brianmilco.blogspot.it/2012/11/cmake-automatically-use-git-tags-as.html
#
git_describe(VERSION --tags --dirty=-dirty --always)
string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${VERSION}")
string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${VERSION}")
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${VERSION}")
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+(.*)" "\\1" VERSION_SHA1 "${VERSION}")
set(VERSION_SHORT "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
#
# compiler detection
# and parameters assignments
#
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# compiler
# -DFLOG
# -DNDEBUG
# -DCONSOLE
#
set(cxxflags "-static-libgcc -static-libstdc++ " )
# set(cxxflags "${cxxflags} -DCONSOLE" )
set(cxxflags "${cxxflags} -DFLOG" )
set(cxxflags "${cxxflags} -DNDEBUG" )
set(cxxflags "${cxxflags} -DPTW32_STATIC_LIB -D__CLEANUP_CXX" )
set(cxxflags "${cxxflags} -std=gnu++0x -DWINVER=0x502 -fpermissive $(INCLUDES)")
set(cxxflags "${cxxflags} -Wall -Wno-unknown-pragmas" )
# set(cxxflags "${cxxflags} -m64" )
# linker
set(shared_lib_cxxflags "-static -static-libgcc -static-libstdc++ -s -shared -Wl,--add-stdcall-alias,--subsystem,windows -Wl,-Bstatic ")
# set(shared_lib_cxxflags "${shared_lib_cxxflags} -m64 ")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(cxxflags "/W4 /WX /EHsc")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${cxxflags}")
set(CMAKE_SHARED_LINKER_FLAGS "${shared_lib_cxxflags}")
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/util)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/extio)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/guiutil)
include_directories(${CMAKE_BINARY_DIR}/util) ## needed for git-raw.h inclusion in .rc
add_subdirectory (airspyhf)
add_subdirectory (test)
add_subdirectory (airspy)
add_subdirectory (hpsdr)
add_subdirectory (extio)
add_subdirectory (util)
add_subdirectory (guiutil)
add_subdirectory (perseus)
# adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search
# programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)