diff options
| author | realtradam <[email protected]> | 2023-05-03 22:01:52 -0400 |
|---|---|---|
| committer | realtradam <[email protected]> | 2023-05-03 22:01:52 -0400 |
| commit | 2709a71f46acb65535a8ee871a352d2ff1fb82df (patch) | |
| tree | 33383118312a364f491c93770da53c16c7f21141 | |
| parent | 87ca456c3f3e97f149604bc033fdd57998e2dcd4 (diff) | |
| download | RodeoKit-2709a71f46acb65535a8ee871a352d2ff1fb82df.tar.gz RodeoKit-2709a71f46acb65535a8ee871a352d2ff1fb82df.zip | |
fix cmake build files for both linux and web
| -rw-r--r-- | CMakeLists.txt | 43 | ||||
| -rw-r--r-- | include/rodeo/input_t.h | 3 | ||||
| -rw-r--r-- | src/compile_flags.txt | 2 | ||||
| -rw-r--r-- | src/input/rodeo_input.c | 2 | ||||
| -rw-r--r-- | src/rodeo.c | 35 | ||||
| -rw-r--r-- | src/rodeo_internal_types.h | 4 | ||||
| -rw-r--r-- | src/rodeo_math.c | 2 |
7 files changed, 50 insertions, 41 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index de61cfd..fbd4e7a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,22 +62,10 @@ if(DEFINED EMSCRIPTEN) set_target_properties(bimg PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/.build/wasm/bin/bimgRelease.bc") add_dependencies(bimg project_bgfx) - target_include_directories(${PROJECT_NAME} - PRIVATE external/bgfx/include - PRIVATE external/bx/include - PRIVATE external/cglm/include - PRIVATE src - PUBLIC include - ) - # `SYSTEM` setting ignores warnings from this external header - target_include_directories(${PROJECT_NAME} - SYSTEM PUBLIC external/STC/include - ) target_link_directories(${PROJECT_NAME} PRIVATE external/bgfx ) target_link_options(${PROJECT_NAME} - PUBLIC "-lSDL" PUBLIC "-sMAX_WEBGL_VERSION=2" PUBLIC "-sMIN_WEBGL_VERSION=2" PUBLIC "-sWASM=1" @@ -87,7 +75,7 @@ if(DEFINED EMSCRIPTEN) PUBLIC "-sALLOW_MEMORY_GROWTH=1" PUBLIC "-sUSE_SDL=2" PUBLIC "-sUSE_SDL_IMAGE=2" - PUBLIC "-sSDL2_IMAGE_FORMATS='[\"png\"]'" + PUBLIC "-sUSE_SDL_MIXER=2" ) target_link_libraries(${PROJECT_NAME} PRIVATE PRIVATE cglm @@ -98,8 +86,12 @@ if(DEFINED EMSCRIPTEN) target_compile_options(${PROJECT_NAME} PUBLIC "-fno-exceptions" PUBLIC "-fno-rtti" + PUBLIC "-sUSE_SDL=2" + PUBLIC "-sUSE_SDL_IMAGE=2" + PUBLIC "-sUSE_SDL_MIXER=2" ) elseif(DEFINED UNIX AND NOT DEFINED APPLE) + add_definitions(-DSDL_VIDEO_DRIVER_X11) option(CGLM_SHARED "Shared build" OFF) option(CGLM_STATIC "Static build" ON) add_subdirectory(external/cglm) @@ -133,17 +125,8 @@ elseif(DEFINED UNIX AND NOT DEFINED APPLE) target_include_directories(${PROJECT_NAME} PRIVATE external/SDL/include - PRIVATE external/SDL_image/include + PRIVATE external/SDL_image PRIVATE external/SDL_mixer/include - PRIVATE external/bgfx/include - PRIVATE external/bx/include - PRIVATE external/cglm/include - PRIVATE src - PUBLIC include - ) - # `SYSTEM` setting ignores warnings from this external header - target_include_directories(${PROJECT_NAME} - SYSTEM PUBLIC external/STC/include ) target_link_directories(${PROJECT_NAME} @@ -163,6 +146,20 @@ elseif(DEFINED UNIX AND NOT DEFINED APPLE) ) endif() +target_include_directories(${PROJECT_NAME} + PRIVATE external/bgfx/include + PRIVATE external/bx/include + PRIVATE external/cglm/include + PRIVATE src + PUBLIC include +) + + +# `SYSTEM` setting ignores warnings from this external header +target_include_directories(${PROJECT_NAME} + SYSTEM PUBLIC external/STC/include + ) + add_dependencies(RodeoKit project_bgfx) # build shaders diff --git a/include/rodeo/input_t.h b/include/rodeo/input_t.h index 2277505..90ab71d 100644 --- a/include/rodeo/input_t.h +++ b/include/rodeo/input_t.h @@ -789,7 +789,8 @@ typedef enum rodeo_input_binary_controllerButton_PADDLE4, /* Xbox Elite paddle P4 (lower right, facing the back) */ rodeo_input_binary_controllerButton_TOUCHPAD, /* PS4/PS5 touchpad button */ rodeo_input_binary_controllerButton_MAX -} rodeo_input_binary_controllerButton_t; +} +rodeo_input_binary_controllerButton_t; // - SDL code end - diff --git a/src/compile_flags.txt b/src/compile_flags.txt index df3f821..09b2ca8 100644 --- a/src/compile_flags.txt +++ b/src/compile_flags.txt @@ -1,11 +1,13 @@ -I./ -I../include -I../external/SDL/include +-I../external/SDL_image -I../external/SDL_mixer/include -I../external/bgfx/include -I../external/bx/include -I../external/cglm/include -I../external/STC/include +-DSDL_VIDEO_DRIVER_X11=ON -Wall -Wextra -Wpedantic diff --git a/src/input/rodeo_input.c b/src/input/rodeo_input.c index 3d46546..158fa79 100644 --- a/src/input/rodeo_input.c +++ b/src/input/rodeo_input.c @@ -6,7 +6,7 @@ #include "rodeo/log.h" // -- external -- -#include "SDL2/SDL.h" +#include "SDL.h" static irodeo_input_state_t istate = {0}; diff --git a/src/rodeo.c b/src/rodeo.c index c6ee71b..1ab12c0 100644 --- a/src/rodeo.c +++ b/src/rodeo.c @@ -12,10 +12,11 @@ #if __EMSCRIPTEN__ #include <emscripten/emscripten.h> #endif -#include "SDL2/SDL.h" -#include "SDL2/SDL_image.h" -#include "SDL2/SDL_mixer.h" -#include "SDL2/SDL_syswm.h" +#include "SDL.h" +#include "SDL_image.h" +#include "SDL_mixer.h" +#include "SDL_syswm.h" +#include "SDL.h" #include "bgfx/c99/bgfx.h" /*#define CGLM_FORCE_LEFT_HANDED*/ #define CGLM_FORCE_DEPTH_ZERO_TO_ONE @@ -25,6 +26,7 @@ // -- system -- #include <time.h> +#include <inttypes.h> static irodeo_state_t state = {0}; @@ -46,19 +48,26 @@ rodeo_window_init( "Initializing SDL..." ); - if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER | SDL_INIT_AUDIO) < 0) { + uint32_t init_flags_sdl = 0; + init_flags_sdl = init_flags_sdl | SDL_INIT_VIDEO; + init_flags_sdl = init_flags_sdl | SDL_INIT_AUDIO; + init_flags_sdl = init_flags_sdl | SDL_INIT_GAMECONTROLLER; + + if(SDL_Init(init_flags_sdl) < 0) + { + rodeo_log( + rodeo_logLevel_error, + "Failed to initialize SDL. SDL_Error: %s", + SDL_GetError() + ); + exit(EXIT_FAILURE); + } rodeo_log( - rodeo_logLevel_error, - "Failed to initialize SDL. SDL_Error: %s", - SDL_GetError() + rodeo_logLevel_info, + "Success initializing SDL" ); - exit(EXIT_FAILURE); } - rodeo_log( - rodeo_logLevel_info, - "Success initializing SDL" - ); rodeo_log( rodeo_logLevel_info, diff --git a/src/rodeo_internal_types.h b/src/rodeo_internal_types.h index 149db6b..531d450 100644 --- a/src/rodeo_internal_types.h +++ b/src/rodeo_internal_types.h @@ -9,8 +9,8 @@ #if __EMSCRIPTEN__ #include <emscripten/emscripten.h> #endif -#include "SDL2/SDL.h" -#include "SDL2/SDL_syswm.h" +#include "SDL.h" +#include "SDL_syswm.h" #include "bgfx/c99/bgfx.h" #include "stc/crandom.h" diff --git a/src/rodeo_math.c b/src/rodeo_math.c index a6f5042..06b6240 100644 --- a/src/rodeo_math.c +++ b/src/rodeo_math.c @@ -10,7 +10,7 @@ #include <math.h> // -- external -- -#include "SDL2/SDL.h" +#include "SDL.h" #include "stc/crandom.h" #define CGLM_FORCE_DEPTH_ZERO_TO_ONE #include "cglm/cglm.h" |
