Skip to content

Commit 011a5a9

Browse files
committed
Add Windows support in CMake build
1 parent 7f18a2b commit 011a5a9

File tree

181 files changed

+76479
-423
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+76479
-423
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
# exclude binaries and temporary files
1010
CMakeCache.txt
11+
CMakeSettings.json
1112
cmake_install.cmake
1213
cmake-build-*
1314
install_manifest.txt

CMakeLists.txt

Lines changed: 71 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,22 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT XRAY_USE_DEFAULT_CXX_LIB)
149149
endif()
150150
endif()
151151

152-
add_compile_options(-Wno-attributes)
153-
if (APPLE)
154-
add_compile_options(-Wl,-undefined,error)
155-
else()
156-
add_compile_options(-Wl,--no-undefined)
152+
if (NOT MSVC)
153+
add_compile_options(-Wno-attributes)
154+
if (APPLE)
155+
add_compile_options(-Wl,-undefined,error)
156+
else()
157+
add_compile_options(-Wl,--no-undefined)
158+
endif()
159+
endif()
160+
161+
if (MASTER_GOLD AND MSVC)
162+
add_compile_definitions(_HAS_EXCEPTIONS=0)
163+
#add_compile_options(/EHsc)
164+
165+
message("!!! CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}")
166+
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
167+
message("!!! CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}")
157168
endif()
158169

159170
# TODO test
@@ -206,10 +217,12 @@ elseif (PROJECT_PLATFORM_PPC)
206217
)
207218
add_compile_definitions(NO_WARN_X86_INTRINSICS)
208219
else()
209-
add_compile_options(
210-
-mfpmath=sse
211-
-msse3
212-
)
220+
if (NOT MSVC)
221+
add_compile_options(
222+
-mfpmath=sse
223+
-msse3
224+
)
225+
endif()
213226
endif()
214227

215228
if (XRAY_LINKER)
@@ -229,6 +242,23 @@ add_compile_definitions(
229242
_CPPUNWIND
230243
)
231244

245+
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
246+
set(ARCH_TYPE x64)
247+
else (CMAKE_SIZEOF_VOID_P EQUAL 4)
248+
set(ARCH_TYPE x86)
249+
endif()
250+
251+
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/sdk")
252+
list(APPEND CMAKE_LIBRARY_PATH "${CMAKE_SOURCE_DIR}/sdk/libraries/${ARCH_TYPE}")
253+
#list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/sdk/cmake")
254+
255+
set(SDL2_DIR "${CMAKE_SOURCE_DIR}/sdk/cmake")
256+
find_package(SDL2 REQUIRED CONFIG)
257+
258+
#set(CMAKE_FIND_DEBUG_MODE TRUE)
259+
find_package(OpenAL REQUIRED)
260+
#set(CMAKE_FIND_DEBUG_MODE FALSE)
261+
232262
if (NOT WIN32)
233263
find_package(SDL2 2.0.18 REQUIRED)
234264
# Fix to support older SDL2
@@ -241,6 +271,9 @@ if (NOT WIN32)
241271
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}"
242272
)
243273
endif()
274+
275+
find_package(OpenGL REQUIRED)
276+
find_package(GLEW REQUIRED)
244277
find_package(OpenAL REQUIRED)
245278
find_package(JPEG)
246279
find_package(Ogg REQUIRED)
@@ -250,6 +283,10 @@ if (NOT WIN32)
250283
find_package(mimalloc NAMES mimalloc2 mimalloc2.0 mimalloc)
251284
endif()
252285

286+
option(XRAY_USE_LUAJIT "Use LuaJIT" ON)
287+
288+
add_subdirectory(Externals)
289+
253290
# Memory allocator option
254291
if (mimalloc_FOUND)
255292
set(MEMORY_ALLOCATOR "mimalloc" CACHE STRING "Use specific memory allocator (mimalloc/standard)")
@@ -258,38 +295,36 @@ else()
258295
endif()
259296
set_property(CACHE MEMORY_ALLOCATOR PROPERTY STRINGS "mimalloc" "standard")
260297

261-
if (MEMORY_ALLOCATOR STREQUAL "mimalloc" AND NOT mimalloc_FOUND)
298+
if (MEMORY_ALLOCATOR STREQUAL "mimalloc" AND NOT (mimalloc_FOUND OR TARGET mimalloc::mimalloc))
262299
message(FATAL_ERROR "mimalloc allocator requested but not found. Please, install mimalloc package or select standard allocator.")
263300
endif()
264301

265302
message("Using ${MEMORY_ALLOCATOR} memory allocator")
266303

267-
option(XRAY_USE_LUAJIT "Use LuaJIT" ON)
268-
269-
add_subdirectory(Externals)
270-
271-
add_compile_options(
272-
-Wall
273-
#-Werror
274-
-Wextra
275-
#-pedantic
276-
-Wno-unknown-pragmas
277-
-Wno-strict-aliasing
278-
-Wno-parentheses
279-
-Wno-unused-label
280-
-Wno-unused-parameter
281-
-Wno-switch
282-
#-Wno-padded
283-
#-Wno-c++98-compat
284-
#-Wno-c++98-compat-pedantic
285-
#-Wno-c++11-compat
286-
#-Wno-c++11-compat-pedantic
287-
#-Wno-c++14-compat
288-
#-Wno-c++14-compat-pedantic
289-
#-Wno-newline-eof
290-
$<$<CXX_COMPILER_ID:GNU>:$<$<COMPILE_LANGUAGE:CXX>:-Wno-class-memaccess>>
291-
$<$<CXX_COMPILER_ID:GNU>:$<$<COMPILE_LANGUAGE:CXX>:-Wno-interference-size>>
292-
)
304+
if (NOT MSVC)
305+
add_compile_options(
306+
-Wall
307+
#-Werror
308+
-Wextra
309+
#-pedantic
310+
-Wno-unknown-pragmas
311+
-Wno-strict-aliasing
312+
-Wno-parentheses
313+
-Wno-unused-label
314+
-Wno-unused-parameter
315+
-Wno-switch
316+
#-Wno-padded
317+
#-Wno-c++98-compat
318+
#-Wno-c++98-compat-pedantic
319+
#-Wno-c++11-compat
320+
#-Wno-c++11-compat-pedantic
321+
#-Wno-c++14-compat
322+
#-Wno-c++14-compat-pedantic
323+
#-Wno-newline-eof
324+
$<$<CXX_COMPILER_ID:GNU>:$<$<COMPILE_LANGUAGE:CXX>:-Wno-class-memaccess>>
325+
$<$<CXX_COMPILER_ID:GNU>:$<$<COMPILE_LANGUAGE:CXX>:-Wno-interference-size>>
326+
)
327+
endif()
293328

294329
add_subdirectory(src)
295330
add_subdirectory(res)
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
add_library(bugtrap_bugtrap SHARED)
2+
3+
add_library(BugTrap::BugTrap ALIAS bugtrap_bugtrap)
4+
5+
target_include_directories(bugtrap_bugtrap
6+
PRIVATE
7+
#../BugTrap/include
8+
../zlib
9+
../zlib/include
10+
../zlib/contrib/minizip
11+
"${CMAKE_BINARY_DIR}/Externals/zlib"
12+
)
13+
14+
target_compile_definitions(bugtrap_bugtrap
15+
PUBLIC
16+
_USRDLL
17+
BUGTRAP_EXPORTS
18+
WIN64
19+
_WINDOWS
20+
21+
)
22+
23+
target_link_libraries(bugtrap_bugtrap
24+
PRIVATE
25+
zlib::zlib
26+
ws2_32.lib
27+
comctl32.lib
28+
shlwapi.lib
29+
version.lib
30+
wininet.lib
31+
)
32+
33+
target_link_options(bugtrap_bugtrap
34+
PRIVATE
35+
/DEF:../BugTrap/source/Client/BugTrap.def
36+
nothrownew.obj
37+
)
38+
39+
#TODO add unity build
40+
41+
target_sources(bugtrap_bugtrap
42+
PRIVATE
43+
../BugTrap/source/Client/AboutDlg.cpp
44+
../BugTrap/source/Client/AboutDlg.h
45+
../BugTrap/source/Client/AnimProgressBar.cpp
46+
../BugTrap/source/Client/AnimProgressBar.h
47+
../BugTrap/source/Client/Array.h
48+
../BugTrap/source/Client/AssemblyInfo.cpp
49+
../BugTrap/source/Client/BTAtlWindow.h
50+
../BugTrap/source/Client/BTMfcWindow.h
51+
../BugTrap/source/Client/BTTrace.h
52+
../BugTrap/source/Client/BaseStream.h
53+
../BugTrap/source/Client/Buffer.h
54+
../BugTrap/source/Client/BugTrap.cpp
55+
../BugTrap/source/Client/BugTrap.h
56+
../BugTrap/source/Client/BugTrapNet.cpp
57+
../BugTrap/source/Client/BugTrapNet.h
58+
../BugTrap/source/Client/BugTrapUI.cpp
59+
../BugTrap/source/Client/BugTrapUI.h
60+
../BugTrap/source/Client/BugTrapUtils.cpp
61+
../BugTrap/source/Client/BugTrapUtils.h
62+
../BugTrap/source/Client/CMapi.cpp
63+
../BugTrap/source/Client/CMapi.h
64+
../BugTrap/source/Client/ColHelper.cpp
65+
../BugTrap/source/Client/ColHelper.h
66+
../BugTrap/source/Client/DescribeErrorDlg.cpp
67+
../BugTrap/source/Client/DescribeErrorDlg.h
68+
../BugTrap/source/Client/Encoding.cpp
69+
../BugTrap/source/Client/Encoding.h
70+
../BugTrap/source/Client/EnumProcess.cpp
71+
../BugTrap/source/Client/EnumProcess.h
72+
../BugTrap/source/Client/FileStream.cpp
73+
../BugTrap/source/Client/FileStream.h
74+
../BugTrap/source/Client/Globals.cpp
75+
../BugTrap/source/Client/Globals.h
76+
../BugTrap/source/Client/Hash.h
77+
../BugTrap/source/Client/HexView.cpp
78+
../BugTrap/source/Client/HexView.h
79+
../BugTrap/source/Client/HyperLink.cpp
80+
../BugTrap/source/Client/HyperLink.h
81+
../BugTrap/source/Client/ImageView.cpp
82+
../BugTrap/source/Client/ImageView.h
83+
../BugTrap/source/Client/InMemLogFile.cpp
84+
../BugTrap/source/Client/InMemLogFile.h
85+
../BugTrap/source/Client/InputStream.cpp
86+
../BugTrap/source/Client/InputStream.h
87+
../BugTrap/source/Client/InterfacePtr.h
88+
../BugTrap/source/Client/LayoutManager.cpp
89+
../BugTrap/source/Client/LayoutManager.h
90+
../BugTrap/source/Client/LeakWatcher.h
91+
../BugTrap/source/Client/List.h
92+
../BugTrap/source/Client/LogFile.cpp
93+
../BugTrap/source/Client/LogFile.h
94+
../BugTrap/source/Client/LogLink.h
95+
../BugTrap/source/Client/LogStream.cpp
96+
../BugTrap/source/Client/LogStream.h
97+
../BugTrap/source/Client/MachineInfoDlg.cpp
98+
../BugTrap/source/Client/MachineInfoDlg.h
99+
../BugTrap/source/Client/MachineStateDlg.cpp
100+
../BugTrap/source/Client/MachineStateDlg.h
101+
../BugTrap/source/Client/MainDlg.cpp
102+
../BugTrap/source/Client/MainDlg.h
103+
../BugTrap/source/Client/MemStream.cpp
104+
../BugTrap/source/Client/MemStream.h
105+
../BugTrap/source/Client/ModuleImportTable.cpp
106+
../BugTrap/source/Client/ModuleImportTable.h
107+
../BugTrap/source/Client/NetThunks.cpp
108+
../BugTrap/source/Client/NetThunks.h
109+
../BugTrap/source/Client/OutputStream.cpp
110+
../BugTrap/source/Client/OutputStream.h
111+
../BugTrap/source/Client/PreviewDlg.cpp
112+
../BugTrap/source/Client/PreviewDlg.h
113+
../BugTrap/source/Client/ResManager.cpp
114+
../BugTrap/source/Client/ResManager.h
115+
../BugTrap/source/Client/SendMailDlg.cpp
116+
../BugTrap/source/Client/SendMailDlg.h
117+
../BugTrap/source/Client/SimpleDlg.cpp
118+
../BugTrap/source/Client/SimpleDlg.h
119+
../BugTrap/source/Client/SmartPtr.h
120+
../BugTrap/source/Client/Splitter.cpp
121+
../BugTrap/source/Client/Splitter.h
122+
../BugTrap/source/Client/StrHolder.cpp
123+
../BugTrap/source/Client/StrHolder.h
124+
../BugTrap/source/Client/StrStream.cpp
125+
../BugTrap/source/Client/StrStream.h
126+
../BugTrap/source/Client/Stream.h
127+
../BugTrap/source/Client/SymEngine.cpp
128+
../BugTrap/source/Client/SymEngine.h
129+
../BugTrap/source/Client/SymEngineNet.cpp
130+
../BugTrap/source/Client/SymEngineNet.h
131+
../BugTrap/source/Client/TextFormat.cpp
132+
../BugTrap/source/Client/TextFormat.h
133+
../BugTrap/source/Client/TextLogFile.cpp
134+
../BugTrap/source/Client/TextLogFile.h
135+
../BugTrap/source/Client/TextView.cpp
136+
../BugTrap/source/Client/TextView.h
137+
../BugTrap/source/Client/ThemeXP.cpp
138+
../BugTrap/source/Client/ThemeXP.h
139+
../BugTrap/source/Client/TransferProgressDlg.cpp
140+
../BugTrap/source/Client/TransferProgressDlg.h
141+
../BugTrap/source/Client/VersionInfo.h
142+
../BugTrap/source/Client/VersionInfoString.h
143+
../BugTrap/source/Client/WaitCursor.cpp
144+
../BugTrap/source/Client/WaitCursor.h
145+
../BugTrap/source/Client/WaitDlg.cpp
146+
../BugTrap/source/Client/WaitDlg.h
147+
../BugTrap/source/Client/XmlLogFile.cpp
148+
../BugTrap/source/Client/XmlLogFile.h
149+
../BugTrap/source/Client/XmlReader.cpp
150+
../BugTrap/source/Client/XmlReader.h
151+
../BugTrap/source/Client/XmlWriter.cpp
152+
../BugTrap/source/Client/XmlWriter.h
153+
../BugTrap/source/Client/resource.h
154+
../BugTrap/source/Client/stdafx.cpp
155+
../BugTrap/source/Client/stdafx.h
156+
157+
../BugTrap/source/Client/res/Bug.ico
158+
../BugTrap/source/Client/res/CheckMark.bmp
159+
../BugTrap/source/Client/res/ImageToolbar.bmp
160+
../BugTrap/source/Client/res/SortArrows.bmp
161+
162+
../BugTrap/source/Client/BugTrap.def
163+
../BugTrap/source/Client/res/KeyPair.snk
164+
../BugTrap/source/Client/res/Upload.avi
165+
166+
../BugTrap/source/Client/BugTrap.rc
167+
)

Externals/CMakeLists.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,31 @@ add_subdirectory(GameSpy)
1010
add_subdirectory(OPCODE)
1111
add_subdirectory(ode)
1212
add_subdirectory(imgui-proj)
13+
add_subdirectory(DiscordGameSDK)
14+
15+
if (MSVC)
16+
add_subdirectory(BugTrap-proj)
17+
add_subdirectory(libtheora-proj)
18+
add_subdirectory(libvorbis-proj)
19+
add_subdirectory(lzo-proj)
20+
21+
add_subdirectory(libogg)
22+
add_library(Ogg::Ogg ALIAS ogg)
23+
24+
#set(CMAKE_FIND_DEBUG_MODE TRUE)
25+
find_package(DXSDK)
26+
#set(CMAKE_FIND_DEBUG_MODE FALSE)
27+
28+
add_subdirectory(zlib-proj)
29+
30+
find_package(mimalloc)
31+
32+
find_package(DbgHelp)
33+
find_package(FaultRep)
34+
find_package(EAX)
35+
36+
add_subdirectory(OpenAutomate-proj)
37+
endif()
1338

1439
if (NOT TARGET xrLuabind)
1540
message(FATAL_ERROR

0 commit comments

Comments
 (0)