forked from Harrm/scale-codec
-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
99 lines (77 loc) · 2.9 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
#
# Copyright Quadrivium LLC
# All Rights Reserved
# SPDX-License-Identifier: Apache-2.0
#
cmake_minimum_required(VERSION 3.12)
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.27")
cmake_policy(SET CMP0144 NEW)
endif ()
include(${CMAKE_CURRENT_LIST_DIR}/cmake/HunterGate.cmake)
HunterGate(
URL https://github.com/qdrvm/hunter/archive/refs/tags/v0.25.3-qdrvm25.tar.gz
SHA1 bf5742041306c4b2c8b65b9c2d2af712a36ac3f9
)
project(Scale LANGUAGES CXX VERSION 1.1.0)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
option(JAM_COMPATIBLE "Build compatible with JAM-codec" OFF)
option(CUSTOM_CONFIG_SUPPORT "Support custom config of streams" OFF)
option(BUILD_TESTS "Whether to include the test suite in build" OFF)
hunter_add_package(Boost)
find_package(Boost CONFIG REQUIRED)
hunter_add_package(qtils)
find_package(qtils CONFIG REQUIRED)
set(DEFINITION_PATH "${CMAKE_CURRENT_SOURCE_DIR}/include/scale/definitions.hpp")
if (NOT EXISTS "${CMAKE_BINARY_DIR}/definition.d" OR NOT EXISTS "${DEFINITION_PATH}")
get_filename_component(LABEL "${CMAKE_BINARY_DIR}" NAME)
file(WRITE "${DEFINITION_PATH}.${LABEL}"
"// This header was generated by cmake (${LABEL})\n"
"// IMPORTANT: Dont modify this file manually!\n")
if (JAM_COMPATIBLE)
file(APPEND "${DEFINITION_PATH}.${LABEL}" "#define JAM_COMPATIBILITY_ENABLED\n")
endif ()
if (CUSTOM_CONFIG_SUPPORT)
file(APPEND "${DEFINITION_PATH}.${LABEL}" "#define CUSTOM_CONFIG_ENABLED\n")
endif ()
file(RENAME "${DEFINITION_PATH}.${LABEL}" "${DEFINITION_PATH}")
message(STATUS "include/scale/definitions.hpp has generated")
file(WRITE "${CMAKE_BINARY_DIR}/definition.d" "include/scale/definitions.hpp has generated")
endif ()
add_subdirectory(src)
if (BUILD_TESTS)
enable_testing()
add_subdirectory(test ${CMAKE_BINARY_DIR}/test_bin)
endif ()
###############################################################################
# INSTALLATION
###############################################################################
include(GNUInstallDirs)
install(TARGETS scale EXPORT scaleConfig
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FRAMEWORK DESTINATION ${CMAKE_INSTALL_PREFIX}
)
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/include/scale
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/scaleConfigVersion.cmake
COMPATIBILITY SameMajorVersion
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/scaleConfigVersion.cmake
DESTINATION share/scale
)
install(
EXPORT scaleConfig
DESTINATION share/scale
NAMESPACE scale::
)