Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit 8802cee

Browse files
authored
Merge pull request #17 from maksw2/cmake
Let's hope that this won't undo some things
2 parents 0c2b78a + 69e8a9a commit 8802cee

File tree

16 files changed

+2834
-488
lines changed

16 files changed

+2834
-488
lines changed

.github/workflows/compile.yml

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,19 @@ jobs:
3333
- name: Add MSBuild to PATH
3434
uses: microsoft/[email protected]
3535

36-
#- name: Restore NuGet packages
37-
# working-directory: ${{env.GITHUB_WORKSPACE}}
38-
# run: nuget restore ${{env.SOLUTION_FILE_PATH}}
36+
# ENABLE THIS ON FIRST TIME SETUP
37+
#- name: Install Strawberry Perl for Shaders compilation
38+
# run: choco install strawberryperl
3939

40-
- name: Install Strawberry Perl for Shaders compilation
41-
run: choco install strawberryperl
40+
- name: Install Shader Dependencies
41+
run: cpan String::CRC32
4242

43-
#- name: Build (Legacy VS2010 Version)
44-
# working-directory: ${{env.GITHUB_WORKSPACE}}
45-
# # Add additional options to the MSBuild command line here (like platform or verbosity level).
46-
# # See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference
47-
# run: |
48-
# & "C:/Program Files (x86)/MSBuild/12.0/Bin/MSBuild.exe" /m /p:Configuration=${{env.BUILD_CONFIGURATION}} ${{env.SOLUTION_FILE_PATH}}
4943

5044
- name: Compile Shaders
5145
working-directory: ${{env.GITHUB_WORKSPACE}}
52-
run: |
53-
cd ./materialsystem/swarmshaders/
54-
dir ../../devtools/bin/
55-
./buildshaders.bat deferred_shaders
46+
run: ./materialsystem/swarmshaders/buildshaders.bat game_shader_generic_swarm deferred_shaders
5647

57-
- name: Build (VS2022 Version)
48+
- name: Build
5849
working-directory: ${{env.GITHUB_WORKSPACE}}
5950
# Add additional options to the MSBuild command line here (like platform or verbosity level).
6051
# See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference

.gitignore

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ materialsystem/swarmshaders/Release_dx9/
1010
ipch/
1111
materialsystem/shaderlib/Debug/
1212
materialsystem/shaderlib/Release/
13-
*.vsidx
14-
/.vs
15-
/.vs/SourceDEFUN/v17/Solution.VC.db-shm
16-
/.vs/SourceDEFUN/v17/Browse.VC.db
13+
/build
14+
/materialsystem/shaderlib/.vs
15+
*.user
16+
/materialsystem/swarmshaders/.vs
17+
*.filters

CMakeLists.txt

Lines changed: 8 additions & 257 deletions
Original file line numberDiff line numberDiff line change
@@ -1,259 +1,10 @@
1-
# oh yes sir, the Linux support is gonna be here soon
1+
cmake_minimum_required(VERSION 3.10)
22

3-
# TODO:
4-
# WASNT TESTED YET
5-
# MORE CMAKE THINGIES (line 81-85)
6-
# CHECK IF IT WILL EVEN COMPILE
3+
# Project Name and Version
4+
project(SourceDEFUN VERSION 1.0.0)
75

8-
cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
9-
10-
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE)
11-
12-
if (APPLE)
13-
# Secton: UNTESTED
14-
# NOTE: You will need to pass this as a command line parameter for the Xcode generator -DCMAKE_OSX_ARCHITECTURES=i386
15-
# Also note only Xcode 9.4.1 and earlier support i386
16-
set(CMAKE_OSX_ARCHITECTURES i386)
17-
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.9)
18-
set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf-with-dsym")
19-
endif()
20-
21-
project(SourceDEFUN)
22-
23-
# For some reason, checking if CMAKE_BUILD_TYPE is defined is unreliable
24-
# So simply check if it's empty instead
25-
if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
26-
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type" FORCE)
27-
endif()
28-
29-
# Modern VS versions default to C++14 anyway, so make it consistent
30-
# But in the future we may want so support C++20
31-
set(CMAKE_CXX_STANDARD 14)
32-
set(CMAKE_CXX_STANDARD_REQUIRED ON)
33-
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
34-
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
35-
36-
# This is a way to emulate groups.vgc
37-
set(BUILD_GROUP "game" CACHE STRING "Build Group")
38-
39-
# For the CMake GUIs that support a combobox list
40-
set_property(CACHE BUILD_GROUP PROPERTY STRINGS
41-
"everything"
42-
"game"
43-
"shaders"
44-
)
45-
46-
# Which game are we building?
47-
set(BUILD_GAME "hl2" CACHE STRING "Build Game")
48-
49-
set_property(
50-
CACHE BUILD_GAME PROPERTY STRINGS
51-
"defunmod"
52-
)
53-
54-
set(SRCDIR "${CMAKE_CURRENT_LIST_DIR}")
55-
set(GAMEDIR "${CMAKE_CURRENT_LIST_DIR}/game")
56-
# It's a commented code don't highlight ok? | set(THIRDPARTYDIR "${SRCDIR}/thirdparty")
57-
58-
# Compile options that are populated and set for each target depending on their type
59-
set(ADDITIONAL_COMPILE_OPTIONS_EXE)
60-
set(ADDITIONAL_COMPILE_OPTIONS_DLL)
61-
set(ADDITIONAL_COMPILE_OPTIONS_LIB)
62-
63-
# Libraries that are linked to for each target depending on their type
64-
set(ADDITIONAL_LINK_LIBRARIES_EXE)
65-
set(ADDITIONAL_LINK_LIBRARIES_DLL)
66-
67-
# Linker options that are populated and set for each target depending on their type
68-
set(ADDITIONAL_LINK_OPTIONS_EXE)
69-
set(ADDITIONAL_LINK_OPTIONS_DLL)
70-
set(ADDITIONAL_LINK_OPTIONS_LIB)
71-
72-
# Sources that are added to each target depending on their type
73-
set(ADDITIONAL_SOURCES_EXE)
74-
set(ADDITIONAL_SOURCES_DLL)
75-
set(ADDITIONAL_SOURCES_LIB)
76-
77-
# Compile definitions that are added to each target depending on their type
78-
set(ADDITIONAL_COMPILE_DEFINITIONS_EXE)
79-
set(ADDITIONAL_COMPILE_DEFINITIONS_DLL)
80-
set(ADDITIONAL_COMPILE_DEFINITIONS_LIB)
81-
82-
include("_cmake_scripts/pch_skip.cmake")
83-
include("_cmake_scripts/platform_dirs.cmake")
84-
include("_cmake_scripts/base.cmake")
85-
include("_cmake_scripts/video_base.cmake")
86-
include("_cmake_scripts/postbuild.cmake")
87-
88-
set(LIBPUBLIC "${SRCDIR}/lib/public${PLATSUBDIR}")
89-
set(LIBCOMMON "${SRCDIR}/lib/common${PLATSUBDIR}")
90-
91-
link_directories(
92-
${LIBPUBLIC}
93-
${LIBCOMMON}
94-
)
95-
96-
include_directories(
97-
"${SRCDIR}/common"
98-
"${SRCDIR}/public"
99-
"${SRCDIR}/public/tier0"
100-
"${SRCDIR}/public/tier1"
101-
"${SRCDIR}/public/tier2" # Not sure if necessary
102-
"${SRCDIR}/public/tier3" # Ditto
103-
)
104-
105-
add_compile_definitions($<$<CONFIG:Debug>:DEBUG> $<$<CONFIG:Debug>:_DEBUG>)
106-
add_compile_definitions($<$<CONFIG:Release>:NDEBUG>)
107-
108-
if (${IS_WINDOWS})
109-
include("_cmake_scripts/windows_base.cmake")
110-
elseif (${IS_LINUX} OR ${IS_OSX})
111-
include("_cmake_scripts/posix_base.cmake")
112-
endif()
113-
114-
include("_cmake_scripts/groups.cmake")
115-
116-
# Store all targets in a variable name ( See: https://stackoverflow.com/questions/37434946/how-do-i-iterate-over-all-cmake-targets-programmatically/62311397#62311397 )
117-
function(get_all_targets var)
118-
set(targets)
119-
get_all_targets_recursive(targets ${CMAKE_CURRENT_SOURCE_DIR})
120-
set(${var} ${targets} PARENT_SCOPE)
121-
endfunction()
122-
123-
macro(get_all_targets_recursive targets dir)
124-
get_property(subdirectories DIRECTORY ${dir} PROPERTY SUBDIRECTORIES)
125-
foreach(subdir ${subdirectories})
126-
get_all_targets_recursive(${targets} ${subdir})
127-
endforeach()
128-
129-
get_property(current_targets DIRECTORY ${dir} PROPERTY BUILDSYSTEM_TARGETS)
130-
list(APPEND ${targets} ${current_targets})
131-
endmacro()
132-
133-
get_all_targets(ALL_TARGETS)
134-
135-
# Set of helper functions to add defintions/options/libs for each target in a filtered way
136-
function(add_compile_definitions_filtered target definitions)
137-
foreach(additional_definition IN LISTS ${definitions})
138-
set(SHOULD_EXCLUDE 0)
139-
# Exclude the compile definition if target defines an exclude list
140-
foreach(exclude IN LISTS "${target}_exclude_compile_definitions")
141-
if (${additional_definition} STREQUAL ${exclude})
142-
set(SHOULD_EXCLUDE 1)
143-
break()
144-
endif()
145-
endforeach()
146-
if (NOT ${SHOULD_EXCLUDE})
147-
target_compile_definitions(${target} PRIVATE ${additional_definition})
148-
endif()
149-
endforeach()
150-
endfunction()
151-
152-
153-
function(add_compile_options_filtered target options)
154-
foreach(additional_option IN LISTS ${options})
155-
set(SHOULD_EXCLUDE 0)
156-
# Exclude the compile options if target defines an exclude list
157-
foreach(exclude IN LISTS "${target}_exclude_compile_options")
158-
if (${additional_option} STREQUAL ${exclude})
159-
set(SHOULD_EXCLUDE 1)
160-
break()
161-
endif()
162-
endforeach()
163-
if (NOT ${SHOULD_EXCLUDE})
164-
target_compile_options(${target} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:${additional_option}>")
165-
endif()
166-
endforeach()
167-
endfunction()
168-
169-
function(add_sources_filtered target sources)
170-
foreach(additional_source IN LISTS ${sources})
171-
set(SHOULD_EXCLUDE 0)
172-
# Exclude the source if target defines an exclude list
173-
foreach(exclude IN LISTS "${target}_exclude_source")
174-
if (${additional_source} STREQUAL ${exclude})
175-
set(SHOULD_EXCLUDE 1)
176-
break()
177-
endif()
178-
endforeach()
179-
if (NOT ${SHOULD_EXCLUDE})
180-
target_sources(${target} PRIVATE ${additional_source})
181-
endif()
182-
endforeach()
183-
endfunction()
184-
185-
function(add_libraries_filtered target libraries)
186-
foreach(additional_lib IN LISTS ${libraries})
187-
set(SHOULD_EXCLUDE 0)
188-
# Exclude the lib if target defines an exclude list
189-
foreach(exclude IN LISTS "${target}_exclude_lib")
190-
if (${additional_lib} STREQUAL ${exclude})
191-
set(SHOULD_EXCLUDE 1)
192-
break()
193-
endif()
194-
endforeach()
195-
if (NOT ${SHOULD_EXCLUDE})
196-
get_target_property(libraries ${target} LINK_LIBRARIES)
197-
# Don't bother adding it if the target already links it manually
198-
foreach(lib IN LISTS libraries)
199-
if (${additional_lib} STREQUAL ${lib})
200-
set(SHOULD_EXCLUDE 1)
201-
break()
202-
endif()
203-
endforeach()
204-
endif()
205-
if (NOT ${SHOULD_EXCLUDE})
206-
target_link_libraries(${target} PRIVATE ${additional_lib})
207-
endif()
208-
endforeach()
209-
endfunction()
210-
211-
# Iterates over all the targets and add necessary definitions/options/libs
212-
# This is an incredible hack, but it allows for targets to specify exclude lists
213-
# This allows us to emulate -$File and such from VPC
214-
foreach(target ${ALL_TARGETS})
215-
# Define an empty exclude list if one isn't defined
216-
if (NOT DEFINED "${target}_exclude_compile_options")
217-
set("${target}_exclude_compile_options")
218-
endif()
219-
220-
# Define an empty exclude list if one isn't defined
221-
if (NOT DEFINED "${target}_exclude_lib")
222-
set("${target}_exclude_lib")
223-
endif()
224-
225-
# Define an empty exclude list if one isn't defined
226-
if (NOT DEFINED "${target}_exclude_source")
227-
set("${target}_exclude_source")
228-
endif()
229-
230-
get_target_property(target_type ${target} TYPE)
231-
if (${target_type} STREQUAL "EXECUTABLE")
232-
add_compile_options_filtered(${target} ADDITIONAL_COMPILE_OPTIONS_EXE)
233-
add_libraries_filtered(${target} ADDITIONAL_LINK_LIBRARIES_EXE)
234-
add_sources_filtered(${target} ADDITIONAL_SOURCES_EXE)
235-
target_link_options(${target} PRIVATE ${ADDITIONAL_LINK_OPTIONS_EXE})
236-
target_compile_definitions(${target} PRIVATE MEMOVERRIDE_MODULE=$<TARGET_NAME_IF_EXISTS:${target}>)
237-
add_compile_definitions_filtered(${target} ADDITIONAL_COMPILE_DEFINITIONS_EXE)
238-
239-
# Only applies to Linux and OSX
240-
target_strip_symbols(${target})
241-
elseif((${target_type} STREQUAL "SHARED_LIBRARY") OR (${target_type} STREQUAL "MODULE_LIBRARY"))
242-
add_compile_options_filtered(${target} ADDITIONAL_COMPILE_OPTIONS_DLL)
243-
add_libraries_filtered(${target} ADDITIONAL_LINK_LIBRARIES_DLL)
244-
add_sources_filtered(${target} ADDITIONAL_SOURCES_DLL)
245-
target_link_options(${target} PRIVATE ${ADDITIONAL_LINK_OPTIONS_DLL})
246-
target_compile_definitions(${target} PRIVATE MEMOVERRIDE_MODULE=$<TARGET_NAME_IF_EXISTS:${target}> DLLNAME=$<TARGET_NAME_IF_EXISTS:${target}>)
247-
add_compile_definitions_filtered(${target} ADDITIONAL_COMPILE_DEFINITIONS_DLL)
248-
249-
# Only applies to Linux and OSX
250-
target_strip_symbols(${target})
251-
elseif(${target_type} STREQUAL "STATIC_LIBRARY")
252-
add_compile_options_filtered(${target} ADDITIONAL_COMPILE_OPTIONS_LIB)
253-
add_sources_filtered(${target} ADDITIONAL_SOURCES_LIB)
254-
target_link_options(${target} PRIVATE ${ADDITIONAL_LINK_OPTIONS_LIB})
255-
target_compile_definitions(${target} PRIVATE LIBNAME=$<TARGET_NAME_IF_EXISTS:${target}>)
256-
add_compile_definitions_filtered(${target} ADDITIONAL_COMPILE_DEFINITIONS_LIB)
257-
endif()
258-
259-
endforeach()
6+
# Add subdirectories as projects
7+
add_subdirectory(game/client)
8+
add_subdirectory(game/server)
9+
add_subdirectory(materialsystem/swarmshaders)
10+
add_subdirectory(materialsystem/shaderlib)

0 commit comments

Comments
 (0)