Skip to content

Commit

Permalink
Move to CMake and add linux support
Browse files Browse the repository at this point in the history
Changes were done to rework most system specific code to be platform
independent. This not only gives Linux support but also might open the
doors for other operating systems. I do not own an Apple tho so I can
not promise anything on that front (especially since Apple kicked out
OpenGL iirc). There are also some bug fixes that I ran across while
testing and playing the game. Finally I ran valgrind over the tests to
check for memory leaks and fixed those. I do not use Windows anymore
really so I haven't tested this with Visual Studio but it compiled fine
using MinGW (see TC-mingw.cmake for a cross compilation template under
linux) and also ran fine with Wine.

* Removed Visual Studio files
* Removed SDL2 files (CMake handles dependency)
* Removed googletest files (CMake handles dependency)
* Moved Windows resources (icon) out of src
* Reworked Win32 to compatible System
* Rework code to use C++17 std::filesystem::path
* Rework WinMain to standard main and let SDL2main and GTestmain handle Windows
* Add GNU/Linux support
* Fixed lightning effect in Catacombs Adventures
* Fixed several memory leaks (mostly in test code)
  • Loading branch information
GoGoOtaku committed Oct 28, 2022
1 parent 2dd9dc4 commit 3337e59
Show file tree
Hide file tree
Showing 266 changed files with 3,432 additions and 73,259 deletions.
109 changes: 109 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
cmake_minimum_required(VERSION 3.16)

set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)

project(CatacombGL LANGUAGES CXX VERSION 0.5.3)

option(BUILD_TESTS "Build Tests" OFF)

set(CMAKE_CXX_STANDARD 17)

if(MINGW)
# This might not only be required for mingw
set(CMAKE_EXE_LINKER_FLAGS "-static -static-libstdc++")
endif()

find_package(OpenGL)

add_library( CatacombGL_Objects OBJECT
ThirdParty/RefKeen/be_st.h
ThirdParty/RefKeen/be_st_sdl_audio_timer.cpp
ThirdParty/RefKeen/id_sd.cpp
ThirdParty/RefKeen/id_sd.h
ThirdParty/opl/dbopl.cpp
ThirdParty/opl/dbopl.h
)

add_subdirectory(src/Engine)
add_subdirectory(src/Abyss)
add_subdirectory(src/Apocalypse)
add_subdirectory(src/Armageddon)
add_subdirectory(src/Catacomb3D)

if(WIN32)
include(FetchContent)

if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
cmake_policy(SET CMP0135 NEW)
endif()

FetchContent_Declare(
sdldev
URL https://github.com/libsdl-org/SDL/releases/download/release-2.24.1/SDL2-devel-2.24.1-VC.zip
URL_MD5 63dd0eca2c6715c8170b1cd3e84017fc
)

FetchContent_MakeAvailable(sdldev)
set(SDL2_PATH ${sdldev_SOURCE_DIR})
find_package(SDL2 REQUIRED CONFIG PATHS ${sdldev_SOURCE_DIR}/cmake NO_DEFAULT_PATH)

target_link_libraries( CatacombGL_Objects
"shlwapi"
SDL2::SDL2main
)

else()
find_package(SDL2 REQUIRED)

endif()

if(SDL2_VERSION VERSION_GREATER_EQUAL "2.0.12")
target_link_libraries( CatacombGL_Objects
SDL2::SDL2
)

else()
include_directories(${SDL2_INCLUDE_DIRS})
target_link_libraries( CatacombGL_Objects
${SDL2_LIBRARIES}
)

endif()

add_executable(CatacombGL)
add_subdirectory(src/System)

if(WIN32)
target_sources( CatacombGL
PUBLIC
${CMAKE_SOURCE_DIR}/res/win/CatacombGL.ico
${CMAKE_SOURCE_DIR}/res/win/CatacombGL.rc
${CMAKE_SOURCE_DIR}/res/win/resource.h
)

set_source_files_properties(
${CMAKE_SOURCE_DIR}/res/win/CatacombGL.rc
PROPERTIES LANGUAGE RC
)

endif()

target_link_libraries( CatacombGL
CatacombGL_Objects
OpenGL::GL
OpenGL::GLU
)

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTS)
add_subdirectory(src/Test)
endif()

include(CPack)
if(WIN32)
set(CMAKE_INSTALL_BINDIR ".")
set(CMAKE_INSTALL_LIBDIR ".")
install(FILES $<TARGET_RUNTIME_DLLS:CatacombGL> TYPE LIB)
endif()
install(TARGETS CatacombGL RUNTIME)

20 changes: 20 additions & 0 deletions TC-mingw.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# the name of the target operating system
set(CMAKE_SYSTEM_NAME Windows)

# which compilers to use for C and C++
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)

# where is the target environment located
set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32/)

# adjust the default behavior of the FIND_XXX() commands:
# search programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

# search headers and libraries in the target environment
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

# run windows tests in wine
set(CMAKE_CROSSCOMPILING_EMULATOR wine)
157 changes: 0 additions & 157 deletions ThirdParty/GoogleTest/CHANGES

This file was deleted.

Loading

0 comments on commit 3337e59

Please sign in to comment.