-
Notifications
You must be signed in to change notification settings - Fork 35
/
CMakeLists.txt
117 lines (92 loc) · 2.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
113
114
115
116
117
#
# CMake build file for trezord
#
cmake_minimum_required(VERSION 2.8)
project(trezord)
file (STRINGS "VERSION" VERSION)
option(BUILD_TESTS "Build tests?" off)
include_directories(src)
set (SRCS
src/main.cpp
src/http_api.hpp
src/http_server.hpp
src/http_client.hpp
src/core.hpp
src/wire.hpp
src/utils.hpp
src/protobuf/state.hpp
src/protobuf/json_codec.hpp
src/protobuf/wire_codec.hpp
src/config/config.pb.cc
src/config/config.pb.h)
if (WIN32)
set (SRCS src/trezord.rc ${SRCS})
endif(WIN32)
IF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
SET(FREEBSD TRUE)
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
if (UNIX AND NOT APPLE AND NOT FREEBSD)
set (SRCS src/glibc_compat.c ${SRCS})
endif(UNIX AND NOT APPLE)
add_executable(trezord ${SRCS})
# use c++11, add version macro
set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS} -DVERSION='\"${VERSION}\"'")
# use vendored cmake modules
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules")
if (WIN32)
set(OS_LIBRARIES wsock32 ws2_32 z)
add_definitions(-D_WIN32_WINNT=0x6000)
else(WIN32)
if (APPLE)
set(OS_LIBRARIES pthread)
elseif(FREEBSD)
set(OS_LIBRARIES pthread z)
else(APPLE)
set(OS_LIBRARIES pthread dl z)
endif(APPLE)
endif(WIN32)
target_link_libraries(trezord ${OS_LIBRARIES})
# add dynamic libs
find_package(CURL REQUIRED)
find_package(libmicrohttpd REQUIRED)
# add static libs
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set(BUILD_SHARED_LIBS off)
set(Boost_USE_STATIC_LIBS on)
set(CMAKE_FIND_STATIC FIRST)
endif(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
find_package(Boost 1.53.0 REQUIRED
regex thread system unit_test_framework program_options chrono)
find_package(Protobuf 2.5.0 REQUIRED)
find_package(jsoncpp REQUIRED)
# add vendored libs
add_subdirectory(vendor/hidapi)
add_subdirectory(vendor/trezor-crypto)
include_directories(
${Boost_INCLUDE_DIRS}
${LIBMICROHTTPD_INCLUDE_DIRS}
${PROTOBUF_INCLUDE_DIRS}
${JSONCPP_INCLUDE_DIRS}
${CURL_INCLUDE_DIRS}
vendor/hidapi/hidapi
vendor/trezor-crypto
vendor/easyloggingpp)
target_link_libraries(trezord
${Boost_LIBRARIES}
${LIBMICROHTTPD_LIBRARIES}
${CURL_LIBRARIES}
${PROTOBUF_LIBRARIES}
${JSONCPP_LIBRARIES}
hidapi
TrezorCrypto)
if(BUILD_TESTS)
include_directories(test)
add_executable(test-protobuf_codecs test/protobuf_codecs.cpp)
target_link_libraries(test-protobuf_codecs
${Boost_LIBRARIES}
${PROTOBUF_LIBRARIES}
${JSONCPP_LIBRARIES})
enable_testing()
add_test(ProtobufCodecs test-protobuf_codecs)
endif(BUILD_TESTS)