Skip to content

Commit d21f9c3

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

File tree

181 files changed

+76453
-415
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

+76453
-415
lines changed

.gitignore

+1
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

+97-37
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ cmake_policy(SET CMP0095 NEW)
88
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
99

1010
include(utils)
11+
1112
calculate_xray_build_id(XRAY_BUILD_ID)
1213

1314
project(OpenXRay
@@ -18,6 +19,22 @@ project(OpenXRay
1819
LANGUAGES CXX C
1920
)
2021

22+
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
23+
set(OS_LINUX TRUE)
24+
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
25+
set(OS_MACOS TRUE)
26+
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
27+
set(OS_WINDOWS TRUE)
28+
elseif(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD" OR CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
29+
set(OS_BSD TRUE)
30+
else()
31+
message(FATAL_ERROR "Unsupported CMAKE_SYSTEM_NAME \"${CMAKE_SYSTEM_NAME}\"")
32+
endif()
33+
34+
if(OS_WINDOWS)
35+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/windows")
36+
endif()
37+
2138
message(STATUS "CMAKE_PROJECT_VERSION: ${CMAKE_PROJECT_VERSION}")
2239

2340
set(CMAKE_CXX_STANDARD 17)
@@ -149,11 +166,18 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT XRAY_USE_DEFAULT_CXX_LIB)
149166
endif()
150167
endif()
151168

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)
169+
if (NOT OS_WINDOWS)
170+
add_compile_options(-Wno-attributes)
171+
if (APPLE)
172+
add_compile_options(-Wl,-undefined,error)
173+
else()
174+
add_compile_options(-Wl,--no-undefined)
175+
endif()
176+
endif()
177+
178+
if (MASTER_GOLD AND OS_WINDOWS)
179+
add_compile_definitions(_HAS_EXCEPTIONS=0)
180+
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
157181
endif()
158182

159183
# TODO test
@@ -206,10 +230,12 @@ elseif (PROJECT_PLATFORM_PPC)
206230
)
207231
add_compile_definitions(NO_WARN_X86_INTRINSICS)
208232
else()
209-
add_compile_options(
210-
-mfpmath=sse
211-
-msse3
212-
)
233+
if (NOT OS_WINDOWS)
234+
add_compile_options(
235+
-mfpmath=sse
236+
-msse3
237+
)
238+
endif()
213239
endif()
214240

215241
if (XRAY_LINKER)
@@ -229,7 +255,28 @@ add_compile_definitions(
229255
_CPPUNWIND
230256
)
231257

232-
if (NOT WIN32)
258+
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
259+
set(ARCH_TYPE x64)
260+
else (CMAKE_SIZEOF_VOID_P EQUAL 4)
261+
set(ARCH_TYPE x86)
262+
endif()
263+
264+
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/sdk")
265+
list(APPEND CMAKE_LIBRARY_PATH "${CMAKE_SOURCE_DIR}/sdk/libraries/${ARCH_TYPE}")
266+
267+
# TODO move
268+
if(OS_WINDOWS)
269+
set(SDL2_DIR "${CMAKE_SOURCE_DIR}/sdk/cmake")
270+
endif()
271+
272+
find_package(SDL2 REQUIRED CONFIG)
273+
find_package(mimalloc)
274+
275+
if(NOT TARGET mimalloc::mimalloc)
276+
add_library(mimalloc::mimalloc ALIAS mimalloc)
277+
endif()
278+
279+
if (NOT OS_WINDOWS)
233280
find_package(SDL2 2.0.18 REQUIRED)
234281
# Fix to support older SDL2
235282
# https://github.com/OpenXRay/xray-16/issues/1595
@@ -241,15 +288,22 @@ if (NOT WIN32)
241288
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}"
242289
)
243290
endif()
291+
292+
find_package(OpenGL REQUIRED)
293+
find_package(GLEW REQUIRED)
244294
find_package(OpenAL REQUIRED)
245295
find_package(JPEG)
246296
find_package(Ogg REQUIRED)
247297
find_package(Vorbis REQUIRED)
248298
find_package(Theora REQUIRED)
249299
find_package(LZO REQUIRED)
250-
find_package(mimalloc NAMES mimalloc2 mimalloc2.0 mimalloc)
300+
251301
endif()
252302

303+
option(XRAY_USE_LUAJIT "Use LuaJIT" ON)
304+
305+
add_subdirectory(Externals)
306+
253307
# Memory allocator option
254308
if (mimalloc_FOUND)
255309
set(MEMORY_ALLOCATOR "mimalloc" CACHE STRING "Use specific memory allocator (mimalloc/standard)")
@@ -258,38 +312,44 @@ else()
258312
endif()
259313
set_property(CACHE MEMORY_ALLOCATOR PROPERTY STRINGS "mimalloc" "standard")
260314

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

265319
message("Using ${MEMORY_ALLOCATOR} memory allocator")
266320

267-
option(XRAY_USE_LUAJIT "Use LuaJIT" ON)
268-
269-
add_subdirectory(Externals)
321+
if (OS_WINDOWS)
322+
add_compile_options(
323+
/nologo
324+
)
270325

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-
)
326+
add_link_options(
327+
/nologo
328+
)
329+
else()
330+
add_compile_options(
331+
-Wall
332+
#-Werror
333+
-Wextra
334+
#-pedantic
335+
-Wno-unknown-pragmas
336+
-Wno-strict-aliasing
337+
-Wno-parentheses
338+
-Wno-unused-label
339+
-Wno-unused-parameter
340+
-Wno-switch
341+
#-Wno-padded
342+
#-Wno-c++98-compat
343+
#-Wno-c++98-compat-pedantic
344+
#-Wno-c++11-compat
345+
#-Wno-c++11-compat-pedantic
346+
#-Wno-c++14-compat
347+
#-Wno-c++14-compat-pedantic
348+
#-Wno-newline-eof
349+
$<$<CXX_COMPILER_ID:GNU>:$<$<COMPILE_LANGUAGE:CXX>:-Wno-class-memaccess>>
350+
$<$<CXX_COMPILER_ID:GNU>:$<$<COMPILE_LANGUAGE:CXX>:-Wno-interference-size>>
351+
)
352+
endif()
293353

294354
add_subdirectory(src)
295355
add_subdirectory(res)

Externals/BugTrap-proj/CMakeLists.txt

+168
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
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+
vfw32.lib
32+
)
33+
34+
target_link_options(bugtrap_bugtrap
35+
PRIVATE
36+
/DEF:../BugTrap/source/Client/BugTrap.def
37+
nothrownew.obj
38+
)
39+
40+
#TODO add unity build
41+
42+
target_sources(bugtrap_bugtrap
43+
PRIVATE
44+
../BugTrap/source/Client/AboutDlg.cpp
45+
../BugTrap/source/Client/AboutDlg.h
46+
../BugTrap/source/Client/AnimProgressBar.cpp
47+
../BugTrap/source/Client/AnimProgressBar.h
48+
../BugTrap/source/Client/Array.h
49+
../BugTrap/source/Client/AssemblyInfo.cpp
50+
../BugTrap/source/Client/BTAtlWindow.h
51+
../BugTrap/source/Client/BTMfcWindow.h
52+
../BugTrap/source/Client/BTTrace.h
53+
../BugTrap/source/Client/BaseStream.h
54+
../BugTrap/source/Client/Buffer.h
55+
../BugTrap/source/Client/BugTrap.cpp
56+
../BugTrap/source/Client/BugTrap.h
57+
../BugTrap/source/Client/BugTrapNet.cpp
58+
../BugTrap/source/Client/BugTrapNet.h
59+
../BugTrap/source/Client/BugTrapUI.cpp
60+
../BugTrap/source/Client/BugTrapUI.h
61+
../BugTrap/source/Client/BugTrapUtils.cpp
62+
../BugTrap/source/Client/BugTrapUtils.h
63+
../BugTrap/source/Client/CMapi.cpp
64+
../BugTrap/source/Client/CMapi.h
65+
../BugTrap/source/Client/ColHelper.cpp
66+
../BugTrap/source/Client/ColHelper.h
67+
../BugTrap/source/Client/DescribeErrorDlg.cpp
68+
../BugTrap/source/Client/DescribeErrorDlg.h
69+
../BugTrap/source/Client/Encoding.cpp
70+
../BugTrap/source/Client/Encoding.h
71+
../BugTrap/source/Client/EnumProcess.cpp
72+
../BugTrap/source/Client/EnumProcess.h
73+
../BugTrap/source/Client/FileStream.cpp
74+
../BugTrap/source/Client/FileStream.h
75+
../BugTrap/source/Client/Globals.cpp
76+
../BugTrap/source/Client/Globals.h
77+
../BugTrap/source/Client/Hash.h
78+
../BugTrap/source/Client/HexView.cpp
79+
../BugTrap/source/Client/HexView.h
80+
../BugTrap/source/Client/HyperLink.cpp
81+
../BugTrap/source/Client/HyperLink.h
82+
../BugTrap/source/Client/ImageView.cpp
83+
../BugTrap/source/Client/ImageView.h
84+
../BugTrap/source/Client/InMemLogFile.cpp
85+
../BugTrap/source/Client/InMemLogFile.h
86+
../BugTrap/source/Client/InputStream.cpp
87+
../BugTrap/source/Client/InputStream.h
88+
../BugTrap/source/Client/InterfacePtr.h
89+
../BugTrap/source/Client/LayoutManager.cpp
90+
../BugTrap/source/Client/LayoutManager.h
91+
../BugTrap/source/Client/LeakWatcher.h
92+
../BugTrap/source/Client/List.h
93+
../BugTrap/source/Client/LogFile.cpp
94+
../BugTrap/source/Client/LogFile.h
95+
../BugTrap/source/Client/LogLink.h
96+
../BugTrap/source/Client/LogStream.cpp
97+
../BugTrap/source/Client/LogStream.h
98+
../BugTrap/source/Client/MachineInfoDlg.cpp
99+
../BugTrap/source/Client/MachineInfoDlg.h
100+
../BugTrap/source/Client/MachineStateDlg.cpp
101+
../BugTrap/source/Client/MachineStateDlg.h
102+
../BugTrap/source/Client/MainDlg.cpp
103+
../BugTrap/source/Client/MainDlg.h
104+
../BugTrap/source/Client/MemStream.cpp
105+
../BugTrap/source/Client/MemStream.h
106+
../BugTrap/source/Client/ModuleImportTable.cpp
107+
../BugTrap/source/Client/ModuleImportTable.h
108+
../BugTrap/source/Client/NetThunks.cpp
109+
../BugTrap/source/Client/NetThunks.h
110+
../BugTrap/source/Client/OutputStream.cpp
111+
../BugTrap/source/Client/OutputStream.h
112+
../BugTrap/source/Client/PreviewDlg.cpp
113+
../BugTrap/source/Client/PreviewDlg.h
114+
../BugTrap/source/Client/ResManager.cpp
115+
../BugTrap/source/Client/ResManager.h
116+
../BugTrap/source/Client/SendMailDlg.cpp
117+
../BugTrap/source/Client/SendMailDlg.h
118+
../BugTrap/source/Client/SimpleDlg.cpp
119+
../BugTrap/source/Client/SimpleDlg.h
120+
../BugTrap/source/Client/SmartPtr.h
121+
../BugTrap/source/Client/Splitter.cpp
122+
../BugTrap/source/Client/Splitter.h
123+
../BugTrap/source/Client/StrHolder.cpp
124+
../BugTrap/source/Client/StrHolder.h
125+
../BugTrap/source/Client/StrStream.cpp
126+
../BugTrap/source/Client/StrStream.h
127+
../BugTrap/source/Client/Stream.h
128+
../BugTrap/source/Client/SymEngine.cpp
129+
../BugTrap/source/Client/SymEngine.h
130+
../BugTrap/source/Client/SymEngineNet.cpp
131+
../BugTrap/source/Client/SymEngineNet.h
132+
../BugTrap/source/Client/TextFormat.cpp
133+
../BugTrap/source/Client/TextFormat.h
134+
../BugTrap/source/Client/TextLogFile.cpp
135+
../BugTrap/source/Client/TextLogFile.h
136+
../BugTrap/source/Client/TextView.cpp
137+
../BugTrap/source/Client/TextView.h
138+
../BugTrap/source/Client/ThemeXP.cpp
139+
../BugTrap/source/Client/ThemeXP.h
140+
../BugTrap/source/Client/TransferProgressDlg.cpp
141+
../BugTrap/source/Client/TransferProgressDlg.h
142+
../BugTrap/source/Client/VersionInfo.h
143+
../BugTrap/source/Client/VersionInfoString.h
144+
../BugTrap/source/Client/WaitCursor.cpp
145+
../BugTrap/source/Client/WaitCursor.h
146+
../BugTrap/source/Client/WaitDlg.cpp
147+
../BugTrap/source/Client/WaitDlg.h
148+
../BugTrap/source/Client/XmlLogFile.cpp
149+
../BugTrap/source/Client/XmlLogFile.h
150+
../BugTrap/source/Client/XmlReader.cpp
151+
../BugTrap/source/Client/XmlReader.h
152+
../BugTrap/source/Client/XmlWriter.cpp
153+
../BugTrap/source/Client/XmlWriter.h
154+
../BugTrap/source/Client/resource.h
155+
../BugTrap/source/Client/stdafx.cpp
156+
../BugTrap/source/Client/stdafx.h
157+
158+
../BugTrap/source/Client/res/Bug.ico
159+
../BugTrap/source/Client/res/CheckMark.bmp
160+
../BugTrap/source/Client/res/ImageToolbar.bmp
161+
../BugTrap/source/Client/res/SortArrows.bmp
162+
163+
../BugTrap/source/Client/BugTrap.def
164+
../BugTrap/source/Client/res/KeyPair.snk
165+
../BugTrap/source/Client/res/Upload.avi
166+
167+
../BugTrap/source/Client/BugTrap.rc
168+
)

0 commit comments

Comments
 (0)