-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
109 lines (84 loc) · 2.84 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
cmake_minimum_required(VERSION 3.27)
include(cmake/env.cmake)
load_env(${CMAKE_CURRENT_SOURCE_DIR})
project(flatt CXX)
# Executable
add_executable(${PROJECT_NAME}
src/main.cpp
src/hash.cpp
src/io.cpp
src/strings.cpp
src/templates.cpp
)
if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /bigobj)
endif()
# target_precompile_headers(${PROJECT_NAME}
# PRIVATE
# "src/pch.hpp"
# )
# Packages
find_package(argparse CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE argparse::argparse)
find_package(cryptopp CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE cryptopp::cryptopp)
find_package(flatbuffers CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE flatbuffers::flatbuffers)
find_package(inja CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE pantor::inja)
find_package(nlohmann_json CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE nlohmann_json::nlohmann_json)
find_package(sol2 CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE sol2)
find_package(spdlog CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE spdlog::spdlog_header_only)
target_link_libraries(${PROJECT_NAME} PRIVATE fmt::fmt-header-only)
find_package(EnTT CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE EnTT::EnTT)
find_package(Lua REQUIRED)
target_include_directories(${PROJECT_NAME} PRIVATE ${LUA_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} PRIVATE ${LUA_LIBRARIES})
# Post
get_cmake_property(_variableNames VARIABLES)
list (SORT _variableNames)
foreach (_variableName ${_variableNames})
message(STATUS "${_variableName}=${${_variableName}}")
endforeach()
set(TRIPLET_NAME ${VCPKG_TARGET_TRIPLET})
if(${VCPKG_HOST_TRIPLET})
set(TRIPLET_NAME ${VCPKG_HOST_TRIPLET})
endif()
find_program(FLATC_BIN NAMES flatc PATHS "${VCPKG_INSTALLED_DIR}/${TRIPLET_NAME}/tools/flatbuffers" REQUIRED)
message(STATUS "Using flatc: ${FLATC_BIN}")
# add_custom_command(
# TARGET ${PROJECT_NAME} PRE_BUILD
# COMMAND
# (${FLATC_BIN}
# --gen-all
# --gen-mutable
# --gen-compare
# --gen-object-api
# --gen-name-strings
# --force-empty
# --force-empty-vectors
# --reflect-types
# --reflect-names
# --cpp
# --cpp-include array
# --cpp-std c++17
# --cpp-static-reflection
# --filename-suffix ""
# -o "${CMAKE_CURRENT_SOURCE_DIR}/src/reflection"
# "${CMAKE_CURRENT_SOURCE_DIR}/src/reflection/reflection.fbs")
# VERBATIM
# )
add_custom_command(
TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${FLATC_BIN} ${CMAKE_INSTALL_PREFIX}
VERBATIM
)
add_custom_command(
TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/dist/${TRIPLET_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/bin/${TRIPLET_NAME}"
VERBATIM
)