Files
2023-01-23 01:40:29 +01:00

62 lines
1.5 KiB
CMake

cmake_minimum_required(VERSION 3.10)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
if(CMAKE_BUILD_TYPE MATCHES DEBUG)
add_link_options(-fsanitize=address)
endif()
if(EMSCRIPTEN)
set(CMAKE_C_FLAGS "-s USE_SDL=2 -s USE_SDL_IMAGE=2 -s USE_SDL_TTF=2 -s USE_SDL_MIXER=2 -s SDL2_IMAGE_FORMATS='[\"png\"]' -s USE_OGG=1 -sALLOW_MEMORY_GROWTH --use-preload-plugins --preload-file assets")
set(CMAKE_C_FLAGS_DEBUG "-g -O0")
set(CMAKE_C_FLAGS_RELEASE "-O2")
set(CMAKE_EXECUTABLE_SUFFIX_C ".html")
#help with clangd
add_definitions(-D__EMSCRIPTEN__ -DEXIT_RUNTIME=1 -DMUSIC_WAV)
elseif(MINGW)
set(CMAKE_C_FLAGS "-Wno-undef --static")
set(CMAKE_C_FLAGS_DEBUG "-g -O0")
set(CMAKE_C_FLAGS_RELEASE "-O2")
else()
set(CMAKE_C_FLAGS "-Wall -Wextra -pedantic -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wmaybe-uninitialized -Wno-unused-variable")
set(CMAKE_C_FLAGS_DEBUG "-g -Werror -O0")
set(CMAKE_C_FLAGS_RELEASE "")
endif()
# generate the compile_commands for vscode / clang
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "")
# set the project name
project(LEGEND_OF_ADAME)
set(SRC
src/main.c
src/renderer.c
src/text.c
src/menu.c
src/input.c
src/scaller.c
src/scene.c
src/game.c
src/cinematic.c
)
# add the executable
add_executable(LEGEND_OF_ADAME ${SRC})
target_link_libraries(LEGEND_OF_ADAME SDL2 SDL2_image SDL2_ttf SDL2_mixer m)
set_property(TARGET LEGEND_OF_ADAME PROPERTY C_STANDARD 23)
file(COPY assets DESTINATION ${CMAKE_BINARY_DIR})
if(MINGW)
target_link_libraries(LEGEND_OF_ADAME ws2_32)
endif()