Skip to content

Commit

Permalink
Fixing static and shared lib builds.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chukobyte committed Apr 1, 2024
1 parent e8ba2d7 commit 34b65c9
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 20 deletions.
21 changes: 17 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ set(CMAKE_C_STANDARD 11)

project(seika C)

if (NOT DEFINED SEIKA_STATIC_LIB)
set(SEIKA_STATIC_LIB "Make seika and dependent libs static" ON)
endif ()

if (CMAKE_C_COMPILER_ID STREQUAL "MSVC")
list(APPEND flags "/W3" "/Zc:preprocessor")
elseif (APPLE)
Expand All @@ -23,17 +27,26 @@ include(Dependencies.cmake)

#--- Link ---#
if (CMAKE_C_COMPILER_ID STREQUAL "MSVC")
target_link_libraries(${PROJECT_NAME} PUBLIC cglm glad stb_image zip miniaudio SDL3::SDL3-static freetype Ws2_32)
target_link_libraries(${PROJECT_NAME} PUBLIC cglm glad stb_image zip miniaudio ${SDL3_LIBRARY} freetype Ws2_32)
elseif (WIN32)
target_link_libraries(${PROJECT_NAME} PUBLIC cglm glad stb_image zip miniaudio -lmingw32 -static-libgcc SDL3::SDL3-static freetype -lws2_32)
target_link_libraries(${PROJECT_NAME} PUBLIC cglm glad stb_image zip miniaudio -lmingw32 -static-libgcc ${SDL3_LIBRARY} freetype -lws2_32)
elseif (APPLE)
target_link_libraries(${PROJECT_NAME} PUBLIC cglm glad stb_image zip miniaudio -Xlinker SDL3::SDL3-static freetype m)
target_link_libraries(${PROJECT_NAME} PUBLIC cglm glad stb_image zip miniaudio -Xlinker ${SDL3_LIBRARY} freetype m)
else ()
target_link_libraries(${PROJECT_NAME} PUBLIC cglm glad stb_image zip miniaudio -static-libgcc -Xlinker -export-dynamic SDL3::SDL3-static freetype m)
target_link_libraries(${PROJECT_NAME} PUBLIC cglm glad stb_image zip miniaudio -static-libgcc -Xlinker -export-dynamic ${SDL3_LIBRARY} freetype m)
endif ()

target_compile_options(${PROJECT_NAME} PUBLIC ${flags})

if (NOT SEIKA_STATIC_LIB)
# SDL
file(GLOB SDL3_DLLS "${CMAKE_BINARY_DIR}/_deps/sdl_content-build/*.dll")
install(FILES ${SDL3_DLLS} DESTINATION ${CMAKE_BINARY_DIR})
# Freetype
file(GLOB FREETYPE_DLLS "${CMAKE_BINARY_DIR}/_deps/freetype_content-build/*.dll")
install(FILES ${FREETYPE_DLLS} DESTINATION ${CMAKE_BINARY_DIR})
endif ()

# Copy directories over that are needed to test
if (NOT DEFINED IS_CI_BUILD)
set(IS_CI_BUILD "false")
Expand Down
10 changes: 6 additions & 4 deletions Dependencies.cmake
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
include(FetchContent)

if (NOT DEFINED SEIKA_STATIC_LIB)
set(SEIKA_STATIC_LIB "Make seika and dependent libs static" ON)
endif ()

# https://github.com/libsdl-org/SDL
if (NOT TARGET SDL3::SDL3-static)
set(SDL_STATIC ${SEIKA_STATIC_LIB})
Expand All @@ -15,6 +11,12 @@ if (NOT TARGET SDL3::SDL3-static)
GIT_TAG cacac6cc341d5856d1857bdcf7390551eed54865
)
FetchContent_MakeAvailable(SDL_content)

if (SEIKA_STATIC_LIB)
SET(SDL3_LIBRARY SDL3::SDL3-static)
else ()
SET(SDL3_LIBRARY SDL3::SDL3)
endif ()
endif ()

# https://github.com/Dav1dde/glad
Expand Down
13 changes: 6 additions & 7 deletions seika/input/sdl_input.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,13 @@ void ska_sdl_process_axis_events() {
} else {
*hasStoppedAxisMotion = false;
}
const f32 axisValueNormalized = ska_math_map_to_range((f32) axisValue, (f32) INT16_MIN, (f32) INT16_MAX,
-1.0f, 1.0f);
const f32 axisValueNormalized = ska_math_map_to_range((f32) axisValue, (f32) INT16_MIN, (f32) INT16_MAX,-1.0f, 1.0f);
const SkaSDLInputEvent inputEvent = {
.sourceType = SkaInputSourceType_GAMEPAD,
.triggerType = triggerType,
.deviceIndex = i,
.key = ska_sdl_gamepad_axis_to_input_key(axis),
.axisMotionValue = axisValueNormalized
.sourceType = SkaInputSourceType_GAMEPAD,
.triggerType = triggerType,
.deviceIndex = (SkaInputDeviceIndex)i,
.key = ska_sdl_gamepad_axis_to_input_key(axis),
.axisMotionValue = axisValueNormalized
};
ska_sdl_notify_input_event(&inputEvent);
}
Expand Down
4 changes: 0 additions & 4 deletions seika/seika.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,6 @@ void ska_update() {
}
}
ska_sdl_process_axis_events();

if (ska_input_is_key_just_pressed(SkaInputKey_KEYBOARD_ESCAPE, SKA_INPUT_FIRST_PLAYER_DEVICE_INDEX)) {
skaState.shutdownRequested = true;
}
}

void ska_fixed_update(f32 deltaTime) {
Expand Down
2 changes: 1 addition & 1 deletion seika/version_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

#define SKA_VERSION_MAJOR 0
#define SKA_VERSION_MINOR 1
#define SKA_VERSION_PATCH 1
#define SKA_VERSION_PATCH 2

#define SKA_VERSION (SKA_MACRO_TO_STRING(SKA_VERSION_MAJOR) "." SKA_MACRO_TO_STRING(SKA_VERSION_MINOR) "." SKA_MACRO_TO_STRING(SKA_VERSION_PATCH))

0 comments on commit 34b65c9

Please sign in to comment.