-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathCMakeLists.txt
107 lines (90 loc) · 2.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
cmake_minimum_required(VERSION 3.1)
project(OpenSWE1R)
option(USE_VM "Use hardware virtualization backend for Unicorn-Engine" OFF)
set(CMAKE_C_STANDARD 11)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
find_package(ENet)
find_package(Unicorn REQUIRED)
find_package(OpenGL REQUIRED)
find_package(GLEW REQUIRED)
find_package(SDL2 REQUIRED)
find_package(OpenAL REQUIRED)
if(ENET_FOUND)
include_directories(SYSTEM
${ENET_INCLUDE_DIR}
)
endif()
include_directories(SYSTEM
${LIBUNICORN_INCLUDE_DIR}
${OPENGL_INCLUDE_DIR}
${SDL2_INCLUDE_DIR}
${OPENAL_INCLUDE_DIR}
)
add_executable(openswe1r
main.c
emulation.c
export.c
shader.c
alloc.c
dll/kernel32.c
com/a3d.c
com/dplay.c
)
# Determine version information
if(CMAKE_SIZEOF_VOID_P LESS 8)
set(APP_BUILD_CONFIG x86)
else()
set(APP_BUILD_CONFIG x64)
endif()
if(WIN32)
string(APPEND APP_BUILD_CONFIG "-Windows")
if(MSVC)
string(APPEND APP_BUILD_CONFIG "-MSVC")
elseif(MSYS)
string(APPEND APP_BUILD_CONFIG "-MSYS")
endif()
elseif(APPLE)
string(APPEND APP_BUILD_CONFIG "-macOS")
else()
string(APPEND APP_BUILD_CONFIG "-Linux")
endif()
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/.generated
${CMAKE_BINARY_DIR}/app_version.h
PRE_BUILD
COMMAND
${CMAKE_COMMAND}
-D APP_VERSION_DIR=${CMAKE_BINARY_DIR}
-D APP_BUILD_CONFIG=${APP_BUILD_CONFIG}
-P cmake/create_app_version.cmake
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
target_sources(openswe1r PUBLIC ${CMAKE_BINARY_DIR}/app_version.h)
target_include_directories(openswe1r PRIVATE ${CMAKE_BINARY_DIR})
include(package.cmake)
if(USE_VM)
target_compile_definitions(openswe1r PUBLIC -DUC_KVM)
target_sources(openswe1r PUBLIC
uc_kvm.c
)
else()
target_link_libraries(openswe1r
${LIBUNICORN_LIBRARY}
)
endif()
if(ENET_FOUND)
target_compile_definitions(openswe1r PUBLIC -DDPLAY_ENET)
target_link_libraries(openswe1r
${ENET_LIBRARIES}
)
endif()
target_link_libraries(openswe1r
${OPENGL_LIBRARIES}
GLEW::GLEW
${SDL2_LIBRARY}
${OPENAL_LIBRARY}
)
if(MSVC)
# Silence MSVC CRT security warnings
target_compile_definitions(openswe1r PRIVATE _CRT_SECURE_NO_WARNINGS)
endif()