-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
131 lines (118 loc) · 6.16 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
cmake_minimum_required(VERSION 3.28)
include(Configuration.cmake)
project(${PROJECT_NAME} VERSION ${PROJECT_VERSION_CMAKE})
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
set(CMAKE_CXX_STANDARD 23 CACHE STRING "")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} CACHE STRING "")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} CACHE STRING "")
file(GLOB_RECURSE PLUGIN_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/Plugin.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/**.cpp)
add_library(${PLUGIN_LIBRARY} SHARED ${PLUGIN_SOURCES})
target_include_directories(${PLUGIN_LIBRARY} PRIVATE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/generated)
target_include_directories(${PLUGIN_LIBRARY} PRIVATE BEFORE ${CMAKE_SOURCE_DIR}/userapi)
set_target_properties(${PLUGIN_LIBRARY} PROPERTIES
OUTPUT_NAME ${OUTPUT_BINARY_NAME})
if((${LINK_UNION_API} OR ${LINK_GOTHIC_API}))
include(cmake/FindUnionAPI.cmake)
if(${UNION_API_FETCH_TYPE} STREQUAL "BINARY")
find_package(UnionAPI CONFIG REQUIRED)
endif()
endif()
if(${LINK_UNION_API})
if(${UNION_API_LINK_TYPE} STREQUAL STATIC)
target_link_libraries(${PLUGIN_LIBRARY} PRIVATE ${UnionAPI_LIB_STATIC})
elseif(${UNION_API_LINK_TYPE} STREQUAL SHARED)
target_link_libraries(${PLUGIN_LIBRARY} PRIVATE ${UnionAPI_LIB_SHARED})
endif()
endif()
if(${LINK_GOTHIC_API})
target_link_libraries(${PLUGIN_LIBRARY} PRIVATE ${GothicAPI_LIB})
if(${GOTHIC_API_G1})
target_compile_definitions(${PLUGIN_LIBRARY} PRIVATE __G1)
endif()
if(${GOTHIC_API_G1A})
target_compile_definitions(${PLUGIN_LIBRARY} PRIVATE __G1A)
endif()
if(${GOTHIC_API_G2})
target_compile_definitions(${PLUGIN_LIBRARY} PRIVATE __G2)
endif()
if(${GOTHIC_API_G2A})
target_compile_definitions(${PLUGIN_LIBRARY} PRIVATE __G2A)
endif()
endif()
string(TIMESTAMP BUILD_TIME "%Y-%m-%dT%H:%M:%S")
execute_process(COMMAND git symbolic-ref --short HEAD OUTPUT_VARIABLE BUILD_BRANCH OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND git log --format=%H -n 1 OUTPUT_VARIABLE BUILD_REVISION OUTPUT_STRIP_TRAILING_WHITESPACE)
configure_file("${CMAKE_SOURCE_DIR}/src/BuildInfo.h.in" "${CMAKE_BINARY_DIR}/generated/BuildInfo.h" @ONLY)
install(FILES $<TARGET_RUNTIME_DLLS:${PLUGIN_LIBRARY}> DESTINATION ${CMAKE_BINARY_DIR})
install(FILES $<TARGET_RUNTIME_DLLS:${PLUGIN_LIBRARY}> TYPE BIN)
install(TARGETS ${PLUGIN_LIBRARY}
EXPORT ${PLUGIN_LIBRARY}Targets
LIBRARY DESTINATION bin
ARCHIVE DESTINATION bin
RUNTIME DESTINATION bin)
if(${LINK_UNION_API} AND ${UNION_API_ENABLE_SIGNATURE})
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/Signatures)
if(${GOTHIC_API_G1})
message(STATUS "Processing Names.txt for G1 (Signatures_G1.tsv)")
set(NAMES_INPUT ${GothicAPI_INCLUDE}/ZenGin/Gothic_I_Classic/Names.txt)
set(NAMES_SIGNATURE Signatures/Signatures_G1.tsv)
set(NAMES_OUTPUT ${CMAKE_BINARY_DIR}/${NAMES_SIGNATURE})
if(NOT EXISTS ${NAMES_OUTPUT})
execute_process(COMMAND ${CMAKE_SOURCE_DIR}/scripts/convert-gothic-names.bat ${NAMES_INPUT} ${NAMES_OUTPUT})
else()
message(STATUS "File exists ${NAMES_OUTPUT}. Delete it to generate again")
endif()
install(FILES ${NAMES_OUTPUT} TYPE BIN RENAME ${NAMES_SIGNATURE})
endif()
if(${GOTHIC_API_G1A})
MESSAGE(STATUS "Processing Names.txt for G1A (Signatures_G1A.tsv)")
set(NAMES_INPUT ${GothicAPI_INCLUDE}/ZenGin/Gothic_I_Addon/Names.txt)
set(NAMES_SIGNATURE Signatures/Signatures_G1A.tsv)
set(NAMES_OUTPUT ${CMAKE_BINARY_DIR}/${NAMES_SIGNATURE})
if(NOT EXISTS ${NAMES_OUTPUT})
execute_process(COMMAND ${CMAKE_SOURCE_DIR}/scripts/convert-gothic-names.bat ${NAMES_INPUT} ${NAMES_OUTPUT})
else()
message(STATUS "File exists ${NAMES_OUTPUT}. Delete it to generate again")
endif()
install(FILES ${NAMES_OUTPUT} TYPE BIN RENAME ${NAMES_SIGNATURE})
endif()
if(${GOTHIC_API_G2})
MESSAGE(STATUS "Processing Names.txt for G2 (Signatures_G2.tsv)")
set(NAMES_INPUT ${GothicAPI_INCLUDE}/ZenGin/Gothic_II_Classic/Names.txt)
set(NAMES_SIGNATURE Signatures/Signatures_G2.tsv)
set(NAMES_OUTPUT ${CMAKE_BINARY_DIR}/${NAMES_SIGNATURE})
if(NOT EXISTS ${NAMES_OUTPUT})
execute_process(COMMAND ${CMAKE_SOURCE_DIR}/scripts/convert-gothic-names.bat ${NAMES_INPUT} ${NAMES_OUTPUT})
else()
message(STATUS "File exists ${NAMES_OUTPUT}. Delete it to generate again")
endif()
install(FILES ${NAMES_OUTPUT} TYPE BIN RENAME ${NAMES_SIGNATURE})
endif()
if(${GOTHIC_API_G2A})
MESSAGE(STATUS "Processing Names.txt for G2A (Signatures_G2A.tsv)")
set(NAMES_INPUT ${GothicAPI_INCLUDE}/ZenGin/Gothic_II_Addon/Names.txt)
set(NAMES_SIGNATURE Signatures/Signatures_G2A.tsv)
set(NAMES_OUTPUT ${CMAKE_BINARY_DIR}/${NAMES_SIGNATURE})
if(NOT EXISTS ${NAMES_OUTPUT})
execute_process(COMMAND ${CMAKE_SOURCE_DIR}/scripts/convert-gothic-names.bat ${NAMES_INPUT} ${NAMES_OUTPUT})
else()
message(STATUS "File exists ${NAMES_OUTPUT}. Delete it to generate again")
endif()
install(FILES ${NAMES_OUTPUT} TYPE BIN RENAME ${NAMES_SIGNATURE})
endif()
endif()
if(${COPY_BUILD_DLL_AUTORUN})
if((${UNION_API_FETCH_TYPE} STREQUAL "BINARY") AND (${UNION_API_LINK_TYPE} STREQUAL "SHARED"))
file(COPY ${CMAKE_BINARY_DIR}/union-api/bin/${CMAKE_BUILD_TYPE}/UnionAPI.dll DESTINATION ${CMAKE_BINARY_DIR})
endif()
string(REPLACE "/" "\\" AUTORUN_SOURCE_DIR ${CMAKE_BINARY_DIR})
string(REPLACE "/" "\\" AUTORUN_DIR ${COPY_BUILD_DLL_AUTORUN_DIRECTORY})
add_custom_target(CopyDLLAutorun
DEPENDS ${PLUGIN_LIBRARY}
COMMAND copy /y /b ${AUTORUN_SOURCE_DIR}\\*.dll ${AUTORUN_DIR})
endif()
add_subdirectory(vdf)
install(FILES ${CMAKE_BINARY_DIR}/plugin.vs TYPE BIN)
install(CODE "execute_process(COMMAND powershell -file ${CMAKE_SOURCE_DIR}/vdf/Build-VDF.ps1 ${CMAKE_INSTALL_PREFIX}/bin)")
install(CODE "execute_process(COMMAND del /y /q ${CMAKE_INSTALL_PREFIX}/bin/plugin.vs)")
install(CODE "execute_process(COMMAND rd /s /q ${CMAKE_INSTALL_PREFIX}/bin/vdf/)")