-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
66 lines (57 loc) · 1.83 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.17)
set(PROJECT "erutils")
project(${PROJECT} LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native")
set(CMAKE_CXX_FLAGS_DEBUG "-g3")
set(COMMON_COMPILE_OPTIONS
-Wall
-Wno-weak-vtables
-Wno-padded
-Wno-shadow-field
-Wno-shadow-field-in-constructor
-Wno-sign-conversion
-Wno-c++98-compat
-Wno-c++98-compat-extra-semi
)
# Default to a release build
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
message("-- Detected build type: ${CMAKE_BUILD_TYPE}")
# Enable link-time optimizations. Note that it breaks the MacOS build
if(NOT APPLE AND CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
find_package(OpenSSL REQUIRED)
find_package(fmt REQUIRED)
# Code generation for item metadata from ERDB
add_executable(codegen src/codegen/itemparser.cpp)
target_link_libraries(codegen PRIVATE fmt::fmt)
target_compile_options(codegen PRIVATE ${COMMON_COMPILE_OPTIONS})
add_custom_command(
COMMENT "Generating generateditems.h"
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/codegen > ${CMAKE_CURRENT_SOURCE_DIR}/src/codegen/generateditems.h
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/src/codegen/generateditems.h
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS codegen
)
# Main executable
add_executable(${PROJECT}
src/main.cpp
src/util.cpp
src/savefile/savefile.cpp
src/savefile/items.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/codegen/generateditems.h
)
target_link_libraries(${PROJECT}
PRIVATE OpenSSL::Crypto
PRIVATE fmt::fmt
)
if (VERSION)
add_definitions(-DVERSION="${VERSION}")
endif()
target_compile_options(${PROJECT} PRIVATE ${COMMON_COMPILE_OPTIONS})
install(TARGETS ${PROJECT} DESTINATION bin)