-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
67 lines (59 loc) · 1.6 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
set(SRCS gm.cpp
gm_buffer.cpp
gm_hash.cpp
gm_httprequest.cpp
gm_listeningsocket.cpp
gm_socket.cpp
gm_udpsocket.cpp
gm_pipe.cpp
Buffer.cpp
Hash.cpp
HttpRequest.cpp
Socket.cpp
StringConversion.cpp
)
add_library(gm82net SHARED ${SRCS})
if (CMAKE_SIZEOF_VOID_P EQUAL 4)
set(TARGET_ARCH "x86")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(TARGET_ARCH "x64")
endif()
target_link_libraries(gm82net Ws2_32 "${PROJECT_SOURCE_DIR}/lib/${TARGET_ARCH}/zlibstatic.lib")
set(UPX_PATH "upx" CACHE STRING "Path to upx.exe if applicable")
if(NOT UPX_PATH STREQUAL "")
add_custom_command(
TARGET gm82net
POST_BUILD
COMMAND ${UPX_PATH} --lzma ${CMAKE_BINARY_DIR}/src/$<CONFIG>/gm82net.dll
)
endif()
option(INSTALL_GEX "Install the generated .gex" OFF)
option(NO_GEX "Omit building a .gex" OFF)
set(GEX_URL https://raw.githubusercontent.com/GM82Project/gm82gex/main/gm82gex.py)
set(GEX_PY ${CMAKE_SOURCE_DIR}/gm82gex.py)
file(DOWNLOAD ${GEX_URL} STATUS DOWNLOAD_STATUS)
list(GET DOWNLOAD_STATUS 0 STATUS_CODE)
if(${STATUS_CODE} EQUAL 0)
file(DOWNLOAD ${GEX_URL} ${GEX_PY})
else()
message(WARNING "Couldn't redownload gm82gex.py")
endif()
if (NOT NO_GEX)
if (INSTALL_GEX)
add_custom_command(
TARGET gm82net
POST_BUILD
COMMAND py ${GEX_PY} gm82net.gej
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT "Building .gex"
)
else()
add_custom_command(
TARGET gm82net
POST_BUILD
COMMAND py ${GEX_PY} gm82net.gej --noinstall
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT "Building .gex"
)
endif()
endif()