Skip to content

Commit

Permalink
Replace JNGL_SDL2 with JNGL_WINAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
jhasse committed Dec 18, 2024
1 parent dce757e commit f37cbd8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
key: cpm
- uses: ilammy/msvc-dev-cmd@v1
- name: Configure
run: cmake -Bbuild -G"Ninja Multi-Config" -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl
run: cmake -Bbuild -G"Ninja Multi-Config" -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl -DJNGL_WINAPI=1
- name: Build (Debug)
run: cmake --build build --config Debug
- name: Unittest (Debug)
Expand Down Expand Up @@ -56,7 +56,7 @@ jobs:
path: .cache/cpm
key: cpm
- name: Configure
run: cmake -Bbuild
run: cmake -Bbuild -DJNGL_WINAPI=1
- name: Build (Debug)
run: cmake --build build --config Debug
- name: Unittest (Debug)
Expand Down Expand Up @@ -106,7 +106,7 @@ jobs:
- uses: actions/checkout@v4
- name: Build with CMake and GCC
run: |
mingw64-cmake -Bbuild-windows -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=0 -DJNGL_SDL2=1
mingw64-cmake -Bbuild-windows -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=0 -DJNGL_WINAPI=0
cmake --build build-windows
env:
Expand Down
29 changes: 13 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,7 @@ elseif (UNIX)

target_link_libraries(jngl PRIVATE $<$<AND:$<CXX_COMPILER_ID:GNU>,$<VERSION_LESS:$<CXX_COMPILER_VERSION>,9.0>>:stdc++fs>)
else() # Windows
set(JNGL_SDL2_DEFAULT OFF)
if(WINDOWS_STORE)
set(JNGL_SDL2_DEFAULT ON)

FetchContent_Declare(
angle
GIT_REPOSITORY https://github.com/jhasse/angle.git
Expand All @@ -125,10 +122,13 @@ else() # Windows
set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_OLD} CACHE BOOL "" FORCE)
endif()
endif()
option(JNGL_SDL2 "Use SDL2 instead of WinAPI" ${JNGL_SDL2_DEFAULT})
option(JNGL_WINAPI "Use legacy WinAPI backend" ON)

target_compile_definitions(jngl PRIVATE _WIN32_WINNT=0x602 _SILENCE_ALL_CXX20_DEPRECATION_WARNINGS UNICODE)
if(JNGL_SDL2)
if(JNGL_WINAPI)
file(GLOB SRC src/win32/*.cpp src/xinput/XinputController.cpp)
target_link_libraries(jngl PRIVATE opengl32)
else()
file(GLOB SRC src/sdl/*.cpp)
if(WINDOWS_STORE)
target_sources(jngl PRIVATE src/xinput/XinputController.cpp)
Expand All @@ -137,9 +137,6 @@ else() # Windows
endif()
target_sources(jngl PRIVATE src/win32/fontfile.cpp src/win32/message.cpp src/win32/other.cpp
src/win32/unicode.cpp)
else()
file(GLOB SRC src/win32/*.cpp src/xinput/XinputController.cpp)
target_link_libraries(jngl PRIVATE opengl32)
endif()
target_sources(jngl PRIVATE ${SRC})
target_link_libraries(jngl PUBLIC winmm)
Expand Down Expand Up @@ -237,14 +234,7 @@ else()

if(MSVC)
target_compile_definitions(jngl PUBLIC _USE_MATH_DEFINES)
if(JNGL_SDL2)
CPMAddPackage(NAME sdl2
URL https://www.libsdl.org/release/SDL2-2.28.4.zip
URL_HASH SHA1=0d9e0da0e935c4f0524cfd16d47d38b6045b9573
OPTIONS
"SDL_SENSOR OFF" # doesn't work with UWP
)
else()
if(JNGL_WINAPI)
CPMAddPackage(NAME sdl2
URL https://www.libsdl.org/release/SDL2-2.28.4.zip
URL_HASH SHA1=0d9e0da0e935c4f0524cfd16d47d38b6045b9573
Expand All @@ -263,6 +253,13 @@ else()
"SDL_SHARED OFF"
"SDL_TIMERS OFF"
)
else()
CPMAddPackage(NAME sdl2
URL https://www.libsdl.org/release/SDL2-2.28.4.zip
URL_HASH SHA1=0d9e0da0e935c4f0524cfd16d47d38b6045b9573
OPTIONS
"SDL_SENSOR OFF" # doesn't work with UWP
)
endif()
target_link_libraries(jngl PRIVATE SDL2-static)
if(WINDOWS_STORE)
Expand Down

0 comments on commit f37cbd8

Please sign in to comment.