-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
CMakeLists.txt
179 lines (150 loc) · 5.43 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# get the millennium version from version file
file(STRINGS "${CMAKE_SOURCE_DIR}/version" VERSION_LINES LIMIT_COUNT 2)
list(GET VERSION_LINES 1 MILLENNIUM_VERSION)
set(MILLENNIUM_VERSION "${MILLENNIUM_VERSION}")
message(STATUS "Millennium Version: ${MILLENNIUM_VERSION}")
cmake_minimum_required(VERSION 3.5.0)
set(BUILD_SHARED_LIBS OFF)
# set c++ directives
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD_REQUIRED ON)
if (NOT APPLE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
endif()
if (WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -s")
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS OFF)
endif()
project(Millennium LANGUAGES CXX)
if (WIN32 AND NOT GITHUB_ACTION_BUILD)
# debug output paths
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "C:/Program Files (x86)/Steam")
set(LIBRARY_OUTPUT_DIRECTORY "C:/Program Files (x86)/Steam")
elseif(UNIX AND NOT GITHUB_ACTION_BUILD)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "$ENV{HOME}/.millennium/")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "$ENV{HOME}/.millennium/")
endif()
# Set version information
add_compile_definitions(MILLENNIUM_VERSION="${MILLENNIUM_VERSION}")
if (WIN32)
string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
string(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
elseif(UNIX)
set(CMAKE_CXX_FLAGS "-fpermissive")
endif()
# build boxer (message-box lib)
# add_subdirectory(vendor/boxer)
include_directories(
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/vendor/fmt/include
${CMAKE_SOURCE_DIR}/vendor/asio/asio/include
${CMAKE_SOURCE_DIR}/vendor/nlohmann/include
${CMAKE_SOURCE_DIR}/vendor/websocketpp
${CMAKE_SOURCE_DIR}/vendor/crow/include
${CMAKE_SOURCE_DIR}/vendor/ini/src
)
add_compile_definitions(
CURL_STATICLIB
_WEBSOCKETPP_CPP11_THREAD_
_WEBSOCKETPP_CPP11_TYPE_TRAITS_
_WEBSOCKETPP_CPP11_RANDOM_DEVICE_
ASIO_STANDALONE
ASIO_HAS_STD_INVOKE_RESULT
FMT_HEADER_ONLY
_CRT_SECURE_NO_WARNINGS
)
if (WIN32)
add_subdirectory(win32)
endif()
add_subdirectory(cli)
find_package(CURL REQUIRED) # used for web requests.
find_package(unofficial-minizip CONFIG REQUIRED) # used for extracting zip files
include_directories(${LIBGIT2_INCLUDE_DIRS})
if(WIN32)
include_directories(${CMAKE_SOURCE_DIR}/vendor/python/include)
elseif(UNIX)
if (APPLE)
include_directories("$ENV{HOME}/.pyenv/versions/3.11.8/include/python3.11")
else()
include_directories("$ENV{HOME}/Documents/LibPython/")
endif()
endif()
set(SOURCE_FILES
"src/main.cc"
"src/core/loader.cc"
"src/core/py_controller/co_spawn.cc"
"src/core/py_controller/logger.cc"
"src/core/ffi/c_python.cc"
"src/core/ffi/javascript.cc"
"src/core/ffi/gil.cc"
"src/core/co_initialize/co_stub.cc"
"src/core/co_initialize/events.cc"
"src/core/hooks/web_load.cc"
"src/core/ipc/pipe.cc"
"src/core/ftp/serv.cc"
"src/sys/log.cc"
"src/sys/io.cc"
"src/sys/settings.cc"
"src/api/executor.cc"
)
if (MSVC)
set(SOURCE_FILES "${SOURCE_FILES} version.rc") # conpile version information on msvc
endif()
if (WIN32)
add_library(Millennium SHARED "${SOURCE_FILES}")
# add_executable(Millennium "${SOURCE_FILES}" version.rc)
elseif(UNIX)
# add_executable(Millennium "${SOURCE_FILES}")
# add_compile_definitions(MILLENNIUM_EXECUTABLE)
add_library(Millennium SHARED "${SOURCE_FILES}")
add_compile_definitions(MILLENNIUM_SHARED)
endif()
if (NOT APPLE)
set_target_properties(Millennium PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32")
target_compile_options (Millennium PRIVATE -m32 )
endif()
if (WIN32)
set_target_properties(Millennium PROPERTIES OUTPUT_NAME "millennium")
set_target_properties(Millennium PROPERTIES PREFIX "")
set_target_properties(Millennium PROPERTIES NO_EXPORT TRUE)
endif()
if(MSVC)
# prevent MSVC from generating .lib and .exp archives
set_target_properties(Millennium PROPERTIES ARCHIVE_OUTPUT_NAME "" LINK_FLAGS "/NOEXP")
endif()
if (GITHUB_ACTION_BUILD)
message("${GITHUB_ACTION_BUILD}")
endif()
find_program(WINDRES windres)
if (WINDRES)
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/version.o
COMMAND ${WINDRES} -i ${CMAKE_SOURCE_DIR}/scripts/version.rc -o ${CMAKE_BINARY_DIR}/version.o
DEPENDS ${CMAKE_SOURCE_DIR}/scripts/version.rc
)
add_custom_target(resource DEPENDS ${CMAKE_BINARY_DIR}/version.o)
add_dependencies(Millennium resource)
target_link_libraries(Millennium ${CMAKE_BINARY_DIR}/version.o)
endif()
target_link_libraries(Millennium CURL::libcurl unofficial::minizip::minizip)
if(WIN32)
target_link_libraries(Millennium Ws2_32.lib wsock32 Iphlpapi)
if (GITHUB_ACTION_BUILD)
target_link_libraries(Millennium "D:/a/Millennium/Millennium/Python-3.11.8/PCbuild/win32/python311.lib")
else()
target_link_libraries(Millennium ${CMAKE_SOURCE_DIR}/vendor/python/python311.lib ${CMAKE_SOURCE_DIR}/vendor/python/python311_d.lib)
endif()
elseif(UNIX)
if (APPLE)
target_link_libraries(Millennium "$ENV{HOME}/.pyenv/versions/3.11.8/lib/libpython3.11.dylib")
else()
if (GITHUB_ACTION_BUILD)
target_link_libraries(Millennium "$ENV{HOME}/.millennium/libpython-3.11.8.so")
else()
target_link_libraries(Millennium "$ENV{HOME}/Documents/LibPython/libpython-3.11.8.so")
endif()
endif()
endif()