forked from ydxt25/swirlyc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
145 lines (118 loc) · 4.98 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
# The Restful Matching-Engine.
# Copyright (C) 2013, 2016 Swirly Cloud Limited.
#
# 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 2 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, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
# Version 3.1 required for CMAKE_CXX_STANDARD.
cmake_minimum_required(VERSION 3.1)
project(swirly)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${PROJECT_SOURCE_DIR}/etc")
set(CMAKE_VERBOSE_MAKEFILE 1)
# Configuration options:
set(ENABLE_SHARED_LIBS ON CACHE BOOL "Enable shared libs.")
set(MG_ENABLE_DEBUG OFF CACHE BOOL "Enable Mongoose debug.")
set(SWIRLY_MAX_LEVELS 3 CACHE STRING "Maximum price levels.")
if(NOT CMAKE_BUILD_TYPE)
#set(CMAKE_BUILD_TYPE DEBUG)
#set(CMAKE_BUILD_TYPE RELEASE)
set(CMAKE_BUILD_TYPE RELWITHDEBINFO)
#set(CMAKE_BUILD_TYPE MINSIZEREL)
endif()
# Enable for use with clang-tidy.
if(NOT CMAKE_EXPORT_COMPILE_COMMANDS)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
endif()
string(TOUPPER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE)
set(COMMON_WARN "-Wall -Werror -Wextra -Wstrict-aliasing=2 -Wno-unused-parameter -Wno-unused-variable")
set(COMMON_FLAGS "-fstrict-aliasing -fvisibility=hidden")
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 14)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_FLAGS} ${COMMON_WARN}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS} ${COMMON_WARN} -fno-enforce-eh-specs -fnothrow-opt -fno-rtti")
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_FLAGS} ${COMMON_WARN}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS} ${COMMON_WARN} -fno-rtti")
endif()
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
add_definitions(-DSWIRLY_MAX_LEVELS=${SWIRLY_MAX_LEVELS})
add_definitions(-DBOOST_NO_AUTO_PTR=1 -DBOOST_NO_RTTI=1 -DBOOST_NO_TYPEID=1)
if(CMAKE_BUILD_TYPE STREQUAL "DEBUG")
add_definitions(-DSWIRLY_ENABLE_DEBUG=1)
endif()
set(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin")
set(LIBRARY_OUTPUT_PATH "${PROJECT_BINARY_DIR}/lib")
file(MAKE_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}")
file(MAKE_DIRECTORY "${LIBRARY_OUTPUT_PATH}")
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/share/doc/html")
find_program(DOT_EXECUTABLE dot)
find_program(ENV_EXECUTABLE env)
find_program(RAGEL_EXECUTABLE ragel)
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost 1.55 REQUIRED COMPONENTS date_time filesystem system)
# The sqlite3_errstr() function was added in 3.7.15.
find_package(SQLite3 3.7.15 REQUIRED)
find_package(Doxygen) # Optional.
find_package(Perl) # Optional.
find_package(PythonInterp 2.7 EXACT) # Optional.
# Find Qt components.
find_package(Qt5Widgets QUIET)
find_package(Qt5Network QUIET)
if(DOXYGEN_FOUND)
configure_file("${PROJECT_SOURCE_DIR}/Doxyfile.in"
"${PROJECT_BINARY_DIR}/Doxyfile")
add_custom_target(doc
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
COMMAND "${CMAKE_COMMAND}" -E make_directory "${PROJECT_BINARY_DIR}/share"
COMMAND "${DOXYGEN_EXECUTABLE}" "${PROJECT_BINARY_DIR}/Doxyfile"
SOURCES "${PROJECT_BINARY_DIR}/Doxyfile")
add_custom_command(TARGET doc POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy "${PROJECT_SOURCE_DIR}/CNAME"
"${PROJECT_BINARY_DIR}/share/doc/html/")
add_dependencies(doc image)
install(DIRECTORY "${PROJECT_BINARY_DIR}/share/doc/" DESTINATION share/doc)
endif()
include_directories("${Boost_INCLUDE_DIRS}")
include_directories("${PROJECT_SOURCE_DIR}/contrib")
include_directories("${PROJECT_SOURCE_DIR}/include")
if(ENABLE_SHARED_LIBS)
set(ash_LIBRARY ash_shared)
set(elm_LIBRARY elm_shared)
set(fig_LIBRARY fig_shared)
set(fir_LIBRARY fir_shared)
set(tea_LIBRARY tea_shared)
set(sqlite_LIBRARY sqlite_shared)
else()
set(ash_LIBRARY ash_static)
set(elm_LIBRARY elm_static)
set(fig_LIBRARY fig_static)
set(fir_LIBRARY fir_static)
set(tea_LIBRARY tea_static)
set(sqlite_LIBRARY sqlite_static)
endif()
enable_testing()
add_subdirectory(db)
add_subdirectory(etc)
add_subdirectory(image)
add_subdirectory(include)
add_subdirectory(src)
add_subdirectory(test)
set(CPACK_GENERATOR "TGZ")
set(CPACK_PACKAGE_NAME "Swirly")
set(CPACK_PACKAGE_VENDOR "Swirly Cloud Limited")
set(CPACK_PACKAGE_CONTACT "[email protected]")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Swirly - The Restful Matching-Engine")
set(CPACK_PACKAGE_VERSION "0.1.0")
set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "1")
set(CPACK_PACKAGE_VERSION_PATCH "0")
include(CPack)