-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt
144 lines (122 loc) · 4.49 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
cmake_minimum_required(VERSION 3.2)
project(marketmaker-cli)
## use or not gcov
option(ENABLE_GCOV "Enable gcov" OFF)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/;${CMAKE_MODULE_PATH}")
include(cmake/GetGitRevisionDescription.cmake)
git_describe(VERSION "--dirty")
# parse the version information into pieces.
if (NOT VERSION MATCHES "^v?([0-9]+)\\.([0-9]+)\\.([0-9]+).*")
message(FATAL_ERROR "Invalid version: " ${VERSION})
endif()
set(VERSION_MAJOR ${CMAKE_MATCH_1})
set(VERSION_MINOR ${CMAKE_MATCH_2})
set(VERSION_PATCH ${CMAKE_MATCH_3})
set(VERSION_SHORT "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
set(PACKAGE_RELEASE "1") # fixed
message(STATUS "Version set to: " ${VERSION})
configure_file(version.h.in include/version.h @ONLY)
configure_file(version_short.txt.in version_short.txt @ONLY)
configure_file(sonar-project.properties.in sonar-project.properties @ONLY)
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 11)
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")
set(CXX_WARNINGS -Werror -Wall -Wno-sign-compare -Wmissing-declarations -Wcast-qual -Wwrite-strings)
set(C_WARNINGS ${CXX_WARNINGS} -Wstrict-prototypes -Wmissing-prototypes)
set(GCOV_CC_FLAGS --coverage -g -O0)
set(GCOV_LD_FLAGS --coverage)
endif ()
if(WIN32)
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS)
add_definitions(-D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING)
endif()
set(CFLAGS_LIST ${CMAKE_C_FLAGS})
separate_arguments(CFLAGS_LIST)
set(SOURCE_FILES
src/main/mmcli.c
src/main/basic.h
src/main/safe_alloc.c
src/main/safe_alloc.h
src/main/property.c
src/main/property.h
src/main/strutil.c
src/main/strutil.h
src/main/api_help.c
src/main/api_help.h
src/main/json.c
src/main/json.h
src/main/url.c
src/main/url.h
src/main/sys_socket.c
src/main/socket.h
src/main/sys_socket.h
src/main/http.c
src/main/http.h
src/main/path.c
src/main/path.h
src/main/file.h
src/main/sys_file.c
src/main/sys_file.h
)
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
target_compile_options(${PROJECT_NAME} PUBLIC ${C_WARNINGS})
if(WIN32)
target_link_libraries(${PROJECT_NAME} wsock32 ws2_32)
endif()
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
include(CTest)
set(UPDATE_DISCONNECTED_IF_AVAILABLE "UPDATE_DISCONNECTED 1")
include(DownloadProject.cmake)
download_project(PROJ googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.8.0
${UPDATE_DISCONNECTED_IF_AVAILABLE}
)
# Prevent GoogleTest from overriding our compiler/linker options
# when building with Visual Studio
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR} EXCLUDE_FROM_ALL)
include_directories("src/main" ${CMAKE_BINARY_DIR}/include)
add_executable(tests
src/test/url_tests.cc
src/test/property_tests.cc
src/main/basic.h
src/main/safe_alloc.c
src/main/safe_alloc.h
src/main/property.c
src/main/strutil.c
src/main/http.c
src/main/url.c
src/main/api_help.c
src/test/api_help_tests.cc
src/main/json.c
src/test/json_tests.cc
src/test/http_tests.cc
src/test/CppSocket.h
src/test/CppSocket.cc
src/test/MockSocket.h
src/main/file.h
src/test/CppFile.cc
src/test/CppFile.h
src/test/MockFile.h
src/test/main.cc)
target_link_libraries(tests gtest gmock)
if(WIN32)
target_link_libraries(tests wsock32 ws2_32)
endif()
if(ENABLE_GCOV)
target_compile_options(tests PUBLIC $<$<COMPILE_LANGUAGE:C>:${GCOV_CC_FLAGS}>)
set_target_properties(tests PROPERTIES LINK_FLAGS ${GCOV_LD_FLAGS})
endif(ENABLE_GCOV)
add_test(NAME Tests COMMAND tests)
set(CPACK_SET_DESTDIR ON)
set(CPACK_PACKAGE_NAME "marketmaker-cli")
set(CPACK_PACKAGE_VENDOR "The SuperNET Developers")
set(CPACK_PACKAGE_CONTACT "Eliezio Oliveira <eliezio@protonmail.com>")
set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
set(CPACK_RPM_PACKAGE_RELEASE ${PACKAGE_RELEASE})
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MarketMaker Command-Line Interface")
set(CPACK_RPM_SPEC_INSTALL_POST "/bin/true")
include(CPack)