-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
148 lines (119 loc) · 4.89 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
146
147
148
################################################################################
# Copyright (c) 2020, Devin Nakamura
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# SPDX-License-Identifier: BSD-2-Clause
################################################################################
cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
set(HUSTLE_VERSION_SUFFIX "-git")
project(Hustle
LANGUAGES CXX
VERSION 0.2.0)
include(cmake/config.cmake)
find_package(Microsoft.GSL CONFIG REQUIRED)
find_package(fmt CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
find_package(CLI11 CONFIG REQUIRED)
#find_package(ryml CONFIG REQUIRED)
# Hack to fix replxx
find_package(Threads REQUIRED)
find_package(replxx CONFIG REQUIRED)
find_package(yaml-cpp CONFIG REQUIRED)
find_package(cityhash CONFIG REQUIRED)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
find_package(Filesystem REQUIRED)
include(GNUInstallDirs)
include(AddHustle)
include(CPack)
include(cmake/toolchain_config.cmake)
#setup out output paths
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${HUSTLE_BUILD_CFG_DIR}/bin")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${HUSTLE_BUILD_CFG_DIR}/lib")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${HUSTLE_BUILD_CFG_DIR}/lib")
if(CMAKE_SIZEOF_VOID_P LESS 8)
message(SEND_ERROR "Requires 64-bit build")
endif()
function(add_hustlegen func input output)
add_custom_command(
OUTPUT ${output}
DEPENDS
${input}
$<TARGET_FILE:hustlegen>
COMMAND hustlegen ${func} -o "${output}" ${input}
)
endfunction()
enable_testing()
add_subdirectory(extern)
# now that we have finished defining any external apps, we can safely pollute global options
include_directories(include ${HUSTLE_BUILD_CFG_DIR} ${CMAKE_CURRENT_BINARY_DIR}/include ${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED true)
add_subdirectory(docs)
add_subdirectory(utils)
add_hustlegen("tags" "${CMAKE_CURRENT_SOURCE_DIR}/classes.yml" "${CMAKE_CURRENT_BINARY_DIR}/cell_tags.def")
add_hustlegen("classes" "${CMAKE_CURRENT_SOURCE_DIR}/classes.yml" "${CMAKE_CURRENT_BINARY_DIR}/classes.def")
add_hustlegen("primitives" "${CMAKE_CURRENT_SOURCE_DIR}/primitives.yml" "${CMAKE_CURRENT_BINARY_DIR}/primitives.def")
add_custom_target(hustle-generated
DEPENDS
${CMAKE_CURRENT_BINARY_DIR}/cell_tags.def
${CMAKE_CURRENT_BINARY_DIR}/classes.def
${CMAKE_CURRENT_BINARY_DIR}/primitives.def
)
add_subdirectory(lib)
add_subdirectory(hustle)
add_subdirectory(tools)
hustle_add_executable(hustle
main.cpp
${BACKWARD_ENABLE}
)
add_backward(hustle)
add_dependencies(hustle hustle-generated)
file(GLOB_RECURSE global_headers "${CMAKE_SOURCE_DIR}/include/hustle/*.h" "${CMAKE_SOURCE_DIR}/include/hustle/*.hpp")
target_sources(hustle PRIVATE ${global_headers} ${CMAKE_CURRENT_SOURCE_DIR}/utils/hustle.natvis)
target_link_libraries(hustle
HustleVM
HustleSupport
HustleGC
fmt::fmt
CLI11::CLI11
HustleParser
replxx::replxx
std::filesystem
)
install(
TARGETS hustle
RUNTIME DESTINATION ${CMAKE_INSTALL_DIR_BINDIR}
)
add_subdirectory(test)
# configure_file does not like generator expressions so we cant put output under HUSTLE_BUILD_CFG_DIR.
# However, the generated header shouldn't be different based on build config.
configure_file(include/hustle/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/hustle/config.h)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/hustle
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT development
FILES_MATCHING
PATTERN "*.h"
PATTERN "*.hpp"
)