-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
64 lines (52 loc) · 1.91 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
cmake_minimum_required(VERSION 3.19)
project(gm82dx9 CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS "/O2 /GS- /W2 /WX")
endif()
include_directories("include")
link_directories("lib")
add_library(gm82dx9 SHARED source/gm_interface.cpp source/gm82dx9.cpp source/transform.cpp source/shaders.cpp source/inject.cpp source/dxerr/dxerr.cpp source/vertex_buffers.cpp)
target_link_libraries(gm82dx9 d3d9 d3dx9)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"SAFESEH:NO\"")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH:NO")
macro(compile_shader in_fn out_fn model)
add_custom_command(
TARGET gm82dx9
PRE_BUILD
COMMAND fxc /nologo /T${model} /Fo source/${out_fn} source/${in_fn}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
endmacro()
compile_shader(vs_pass.hlsl vs_pass.vs3 vs_3_0)
compile_shader(ps_pass.hlsl ps_pass.ps3 ps_3_0)
option(INSTALL_GEX "Install the generated .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 (INSTALL_GEX)
add_custom_command(
TARGET gm82dx9
POST_BUILD
COMMAND py ${GEX_PY} gm82dx9.gej
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Building .gex"
)
else()
add_custom_command(
TARGET gm82dx9
POST_BUILD
COMMAND py ${GEX_PY} gm82dx9.gej --noinstall
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Building .gex"
)
endif()