-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
66 lines (53 loc) · 1.77 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
cmake_minimum_required(VERSION 3.10)
# Generate compile_commands.json
# to make clangd works.
# !WARNING
# This only useful for `Ninja` and `Makefile` generator
# For other generator, CMake ignore it, i.e., do nothing.
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
# Include useful module
include(cmake/utils.cmake)
function (kanon_copy_dll_to_target_dir kanon_target)
if (KANON_ON_WIN)
conzxy_copy_dll_to_target_dir(TARGET ${kanon_target}
DLL_PATH "${CMAKE_BINARY_DIR}/kanon/bin/kanon_base.dll")
conzxy_copy_dll_to_target_dir(TARGET ${kanon_target}
DLL_PATH "${CMAKE_BINARY_DIR}/kanon/bin/kanon_net.dll")
endif ()
endfunction ()
# Extract the version from version.h in the top level of include directory
kanon_extract_version()
project(kanon VERSION ${KANON_VERSION})
message(STATUS "CMake Version: ${CMAKE_VERSION}")
message(STATUS "Building kanon: ${KANON_VERSION}")
include(cmake/compile_flag.cmake)
include(cmake/build_type.cmake)
include(cmake/cache_var.cmake)
include(cmake/platform.cmake)
include(cmake/install.cmake)
# Add third-party before kanon
add_subdirectory(third-party)
# Add source directory before install
add_subdirectory(kanon)
if (KANON_INSTALL)
message(STATUS "Generating (kanon) install files...")
set(kanon_export_targets kanon_base)
if (KANON_ON_UNIX)
list(APPEND kanon_export_targets kanon_net)
endif ()
if (KANON_BUILD_PROTOBUF OR KANON_BUILD_PROTOBUF_RPC)
list(APPEND kanon_export_targets kanon_protobuf)
endif ()
if (KANON_BUILD_PROTOBUF_RPC)
list(APPEND kanon_export_targets kanon_protobuf_rpc)
endif ()
conzxy_install(PROJECT kanon NAMESPACE kanon TARGETS ${kanon_export_targets})
endif ()
# Tests
if (KANON_TESTS)
add_subdirectory(test)
endif ()
# Examples
if (KANON_EXAMPLES)
add_subdirectory(example)
endif ()