forked from Curve/chalchiu
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
94 lines (71 loc) · 3.39 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
cmake_minimum_required(VERSION 3.16)
project(loader LANGUAGES CXX VERSION 2.4)
# --------------------------------------------------------------------------------------------------------
# Setup Cross-Compilation on Linux
# --------------------------------------------------------------------------------------------------------
if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
message(FATAL_ERROR "[${PROJECT_NAME}] Make sure to instruct CMake to use the toolchain file!")
endif()
# --------------------------------------------------------------------------------------------------------
# Create library
# --------------------------------------------------------------------------------------------------------
file(GLOB src "src/*.cpp")
file(GLOB exports "export/*")
add_library(${PROJECT_NAME} SHARED ${src} ${exports})
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "iphlpapi")
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 20 CXX_EXTENSIONS OFF CXX_STANDARD_REQUIRED ON)
if (CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE -Wno-missing-field-initializers -Wno-cast-function-type)
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic -Werror -pedantic -pedantic-errors -Wfatal-errors)
endif()
if (MINGW)
target_link_libraries(${PROJECT_NAME} PRIVATE "-Wl,--enable-stdcall-fixup" -static -static-libgcc -static-libstdc++)
endif()
# --------------------------------------------------------------------------------------------------------
# Generate "constants" file
# --------------------------------------------------------------------------------------------------------
configure_file("constants.hpp.in" "${CMAKE_CURRENT_SOURCE_DIR}/private/constants.hpp")
# --------------------------------------------------------------------------------------------------------
# Include directories
# --------------------------------------------------------------------------------------------------------
target_include_directories(${PROJECT_NAME} PUBLIC "include")
target_include_directories(${PROJECT_NAME} PRIVATE "private")
# --------------------------------------------------------------------------------------------------------
# Link Dependencies and Add Sources
# --------------------------------------------------------------------------------------------------------
include("cmake/cpm.cmake")
CPMFindPackage(
NAME sol
VERSION 3.3.0
GIT_REPOSITORY "https://github.com/ThePhD/sol2"
)
CPMFindPackage(
NAME lime
VERSION 2.2
GIT_REPOSITORY "https://github.com/Curve/lime"
)
CPMFindPackage(
NAME spdlog
VERSION 1.12.0
GIT_REPOSITORY "https://github.com/gabime/spdlog"
)
CPMFindPackage(
NAME nlohmann_json
VERSION 3.11.2
GIT_REPOSITORY "https://github.com/nlohmann/json"
)
CPMFindPackage(
NAME semver
VERSION 0.3.0
GIT_REPOSITORY "https://github.com/Neargye/semver"
)
CPMFindPackage(
NAME fmt
GIT_TAG 10.1.0
GIT_REPOSITORY "https://github.com/fmtlib/fmt"
)
find_package(Lua 5.1 EXACT REQUIRED)
target_include_directories(${PROJECT_NAME} PRIVATE ${LUA_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} PUBLIC spdlog sol2 lime nlohmann_json fmt semver imagehlp ${LUA_LIBRARIES})