Skip to content

Commit

Permalink
Merge pull request #843 from edge-classic/CMake-CI-Updates
Browse files Browse the repository at this point in the history
Update MinGW32 CI to use Sokol D3D11; update various CMakeLists
  • Loading branch information
pbdot authored Jan 16, 2025
2 parents 8e5c1b1 + 9db2b3b commit cd9e3d9
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=cmake/Toolchain-mingw32.cmake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DEDGE_SOKOL_D3D11=ON -DCMAKE_TOOLCHAIN_FILE=cmake/Toolchain-mingw32.cmake

- name: Build
# Build your program with the given configuration
Expand Down
98 changes: 51 additions & 47 deletions source_files/edge/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,20 +133,18 @@ set (EDGE_SOKOL_SOURCE_FILES
)

if (NOT EDGE_SOKOL)
set (EDGE_SOURCE_FILES ${EDGE_SOURCE_FILES} ${EDGE_GL_SOURCE_FILES})
list (APPEND EDGE_SOURCE_FILES ${EDGE_GL_SOURCE_FILES})
else()

if (EDGE_SOKOL_D3D11)
set (EDGE_SOKOL_SOURCE_FILES ${EDGE_SOKOL_SOURCE_FILES} render/sokol/sokol_d3d11.cc)
list (APPEND EDGE_SOKOL_SOURCE_FILES render/sokol/sokol_d3d11.cc)
endif()

set (EDGE_SOURCE_FILES ${EDGE_SOURCE_FILES} ${EDGE_SOKOL_SOURCE_FILES})

list (APPEND EDGE_SOURCE_FILES ${EDGE_SOKOL_SOURCE_FILES})
endif()

if (EDGE_CLASSIC)
set (EDGE_SOURCE_FILES
${EDGE_SOURCE_FILES}
list (APPEND
EDGE_SOURCE_FILES
l_deh.cc
p_umapinfo.cc
s_doom.cc
Expand All @@ -157,18 +155,41 @@ if (EDGE_CLASSIC)
vm_player.cc
)
else()
set (EDGE_SOURCE_FILES
${EDGE_SOURCE_FILES}
list (APPEND
EDGE_SOURCE_FILES
s_midi.cc
)
endif()

if (EMSCRIPTEN)
set (EDGE_SOURCE_FILES ${EDGE_SOURCE_FILES} i_web.cc)
list (APPEND EDGE_SOURCE_FILES i_web.cc)
else()
set (EDGE_SOURCE_FILES ${EDGE_SOURCE_FILES} i_main.cc)
list (APPEND EDGE_SOURCE_FILES i_main.cc)
endif()

if (WIN32 OR MINGW)
list (APPEND EDGE_SOURCE_FILES w32_res.rc)
endif()

add_executable(
edge-classic
${EDGE_SOURCE_FILES}
)

if(WIN32 OR MINGW)
target_compile_definitions(edge-classic PRIVATE WIN32)
else()
target_compile_definitions(edge-classic PRIVATE UNIX)
endif()

if(WIN32 AND (MSVC OR CLANG))
target_include_directories(edge-classic PRIVATE ${EDGE_LIBRARY_DIR}/sdl2/msvc/include)
elseif (MINGW)
target_include_directories(edge-classic SYSTEM PRIVATE ${EDGE_LIBRARY_DIR}/sdl2/mingw/include)
endif()

target_include_directories(edge-classic PRIVATE ./)

set (EDGE_LINK_LIBRARIES
ajbsp
ddf
Expand All @@ -188,53 +209,37 @@ set (EDGE_LINK_LIBRARIES
)

if (NOT EMSCRIPTEN)
set (EDGE_LINK_LIBRARIES ${EDGE_LINK_LIBRARIES} thread)
list (APPEND EDGE_LINK_LIBRARIES thread)
endif()

if (EDGE_CLASSIC)
set (EDGE_LINK_LIBRARIES
${EDGE_LINK_LIBRARIES}
list (APPEND
EDGE_LINK_LIBRARIES
coal
dehacked
m4p
opalmidi
)
endif()

if (WIN32 OR MINGW)
set (EDGE_SOURCE_FILES ${EDGE_SOURCE_FILES} w32_res.rc)
endif()

if (EDGE_PROFILING)
set (EDGE_LINK_LIBRARIES ${EDGE_LINK_LIBRARIES} TracyClient)
endif()

add_executable(
edge-classic
${EDGE_SOURCE_FILES}
)

if(WIN32 OR MINGW)
target_compile_definitions(edge-classic PRIVATE WIN32)
else()
target_compile_definitions(edge-classic PRIVATE UNIX)
list (APPEND EDGE_LINK_LIBRARIES TracyClient)
endif()

if (EDGE_SOKOL)
set(EDGE_LINK_LIBRARIES ${EDGE_LINK_LIBRARIES} sokol)
list(APPEND EDGE_LINK_LIBRARIES sokol)
if (MINGW)
if (EDGE_SOKOL_GL)
list(APPEND EDGE_LINK_LIBRARIES winmm kernel32)
else ()
list(APPEND EDGE_LINK_LIBRARIES d3d11 winmm kernel32)
endif()
endif()
else ()
target_include_directories(edge-classic PRIVATE ${EDGE_LIBRARY_DIR}/glad/include/glad)
set(EDGE_LINK_LIBRARIES ${EDGE_LINK_LIBRARIES} glad ${OPENGL_LIBRARIES})
list(APPEND EDGE_LINK_LIBRARIES glad ${OPENGL_LIBRARIES})
endif()

if(WIN32 AND (MSVC OR CLANG))
target_include_directories(edge-classic PRIVATE ${EDGE_LIBRARY_DIR}/sdl2/msvc/include)
elseif (MINGW)
target_include_directories(edge-classic SYSTEM PRIVATE ${EDGE_LIBRARY_DIR}/sdl2/mingw/include)
endif()

target_include_directories(edge-classic PRIVATE ./)

target_link_libraries(edge-classic PRIVATE ${EDGE_LINK_LIBRARIES})

target_compile_options(edge-classic PRIVATE
Expand Down Expand Up @@ -283,15 +288,14 @@ if (WIN32)
list(APPEND COPY_FILES "${CMAKE_SOURCE_DIR}/libraries/sdl2/msvc/x86/SDL2.dll")
endif ()
elseif(MINGW)
if (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
list(APPEND COPY_FILES "${CMAKE_SOURCE_DIR}/libraries/sdl2/mingw/x64/SDL2.dll")
else ()
list(APPEND COPY_FILES "${CMAKE_SOURCE_DIR}/libraries/sdl2/mingw/x86/SDL2.dll")
endif ()
if (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
list(APPEND COPY_FILES "${CMAKE_SOURCE_DIR}/libraries/sdl2/mingw/x64/SDL2.dll")
else ()
list(APPEND COPY_FILES "${CMAKE_SOURCE_DIR}/libraries/sdl2/mingw/x86/SDL2.dll")
endif ()
endif()
endif()

if (COPY_FILES)
add_custom_command( TARGET edge-classic POST_BUILD COMMAND_EXPAND_LISTS COMMAND ${CMAKE_COMMAND} -E copy_if_different ${COPY_FILES} ${DEST_DIR})
endif()

endif()
8 changes: 4 additions & 4 deletions source_files/epi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ add_library(
epi_scanner.cpp
)

set (epi_LIBRARIES almostequals HandmadeMath stb xxhash)
set (EPI_LIBRARIES almostequals HandmadeMath stb xxhash)

if (NOT EMSCRIPTEN AND NOT MINGW)
list(APPEND epi_LIBRARIES mimalloc)
if (NOT EMSCRIPTEN)
list(APPEND EPI_LIBRARIES mimalloc)
endif()

target_link_libraries(epi PUBLIC ${epi_LIBRARIES})
target_link_libraries(epi PUBLIC ${EPI_LIBRARIES})

if(WIN32 AND (MSVC OR CLANG))
target_include_directories(epi PRIVATE ${EDGE_LIBRARY_DIR}/sdl2/msvc/include)
Expand Down

0 comments on commit cd9e3d9

Please sign in to comment.