X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=CMakeLists.txt;h=38ff578af0232129c5c22a5b1210002db44295e4;hb=3a667bb8b6fc9581f447bda3fa5b12fb01b8ef36;hp=fd717665036cef2bc157b3fb53c014622f205a33;hpb=72d14c852b91bce9ba63ff9cce7d57ebcce05323;p=nothing.git diff --git a/CMakeLists.txt b/CMakeLists.txt index fd717665..38ff578a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,31 +4,38 @@ project(nothing) set(NOTHING_CI OFF CACHE BOOL "Indicates whether the build is running on CI or not") if(WIN32) + # do the flags thing first. if(MINGW) add_compile_definitions(SDL_MAIN_HANDLED) # https://stackoverflow.com/a/25089610 add_compile_definitions(__USE_MINGW_ANSI_STDIO) # https://github.com/trink/symtseries/issues/49#issuecomment-160843756 - # Support both 32 and 64 bit builds - if (${CMAKE_SIZEOF_VOID_P} MATCHES 8) - set(SDL2_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/SDL2/x86_64-w64-mingw32/include/SDL2") - set(SDL2_LIBRARIES "${CMAKE_SOURCE_DIR}/SDL2/x86_64-w64-mingw32/lib/libSDL2.a;${CMAKE_SOURCE_DIR}/SDL2/x86_64-w64-mingw32/lib/libSDL2main.a") - else() - set(SDL2_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/SDL2/i686-w64-mingw32/include/SDL2") - set(SDL2_LIBRARIES "${CMAKE_SOURCE_DIR}/SDL2/i686-w64-mingw32/lib/libSDL2.a;${CMAKE_SOURCE_DIR}/SDL2/i686-w64-mingw32/lib/libSDL2main.a") - endif() - - else() - set(SDL2_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/SDL2/include") + endif() - # Support both 32 and 64 bit builds - if (${CMAKE_SIZEOF_VOID_P} MATCHES 8) - set(SDL2_LIBRARIES "${CMAKE_SOURCE_DIR}/SDL2/lib/x64/SDL2.lib;${CMAKE_SOURCE_DIR}/SDL2/lib/x64/SDL2main.lib") + # then try to find SDL2 using normal means (eg. the user may have installed SDL2 using pacman on msys2) + # note we don't use REQUIRED here, because it can fail -- in which case we fall back to looking for the + # library "directly" using local files. + find_package(SDL2 QUIET) + if(NOT SDL2_FOUND) + if(MINGW) + # Support both 32 and 64 bit builds + if (${CMAKE_SIZEOF_VOID_P} MATCHES 8) + set(SDL2_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/SDL2/x86_64-w64-mingw32/include/SDL2") + set(SDL2_LIBRARIES "${CMAKE_SOURCE_DIR}/SDL2/x86_64-w64-mingw32/lib/libSDL2.a;${CMAKE_SOURCE_DIR}/SDL2/x86_64-w64-mingw32/lib/libSDL2main.a") + else() + set(SDL2_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/SDL2/i686-w64-mingw32/include/SDL2") + set(SDL2_LIBRARIES "${CMAKE_SOURCE_DIR}/SDL2/i686-w64-mingw32/lib/libSDL2.a;${CMAKE_SOURCE_DIR}/SDL2/i686-w64-mingw32/lib/libSDL2main.a") + endif() else() - set(SDL2_LIBRARIES "${CMAKE_SOURCE_DIR}/SDL2/lib/x86/SDL2.lib;${CMAKE_SOURCE_DIR}/SDL2/lib/x86/SDL2main.lib") - endif() + set(SDL2_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/SDL2/include") + # Support both 32 and 64 bit builds + if (${CMAKE_SIZEOF_VOID_P} MATCHES 8) + set(SDL2_LIBRARIES "${CMAKE_SOURCE_DIR}/SDL2/lib/x64/SDL2.lib;${CMAKE_SOURCE_DIR}/SDL2/lib/x64/SDL2main.lib") + else() + set(SDL2_LIBRARIES "${CMAKE_SOURCE_DIR}/SDL2/lib/x86/SDL2.lib;${CMAKE_SOURCE_DIR}/SDL2/lib/x86/SDL2main.lib") + endif() + endif() + string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES) endif() - string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES) - else() find_package(SDL2 REQUIRED) endif() @@ -43,28 +50,6 @@ include_directories(src/) include_directories(${SDL2_INCLUDE_DIRS}) -add_library(system STATIC - src/system/line_stream.h - src/system/line_stream.c - src/system/log.h - src/system/log.c - src/system/lt.h - src/system/lt_adapters.h - src/system/lt_adapters.c - src/system/nth_alloc.h - src/system/nth_alloc.c - src/system/stacktrace.h - src/system/stacktrace.c - src/system/str.h - src/system/str.c - src/dynarray.h - src/dynarray.c - src/hashset.h - src/hashset.c - src/system/file.h - src/system/file.c - ) - add_executable(nothing src/color.h src/color.c @@ -99,10 +84,10 @@ add_executable(nothing src/game/level/action.h src/game/level_picker.h src/game/level_picker.c + src/game/credits.h + src/game/credits.c src/game/settings.h src/game/settings.c - src/game/level_folder.c - src/game/level_folder.h src/game/sound_samples.h src/game/sound_samples.c src/game/sprite_font.h @@ -132,16 +117,10 @@ add_executable(nothing src/ui/edit_field.c src/ui/history.h src/ui/history.c - src/ui/list_selector.h - src/ui/list_selector.c src/ui/wiggly_text.h src/ui/wiggly_text.c src/ui/slider.h src/ui/slider.c - src/ui/grid.h - src/ui/grid.c - src/game/level_metadata.h - src/game/level_metadata.c src/game/level/level_editor.h src/game/level/level_editor.c src/game/level/level_editor/color_picker.h @@ -162,13 +141,31 @@ add_executable(nothing src/game/level/level_editor/background_layer.c src/game/level/level_editor/undo_history.h src/game/level/level_editor/undo_history.c - src/game/level/level_editor/action_picker.h - src/game/level/level_editor/action_picker.c + src/system/log.h + src/system/log.c + src/system/lt.h + src/system/lt_adapters.h + src/system/lt_adapters.c + src/system/nth_alloc.h + src/system/nth_alloc.c + src/system/stacktrace.h + src/system/stacktrace.c + src/system/str.h + src/system/str.c + src/dynarray.h + src/dynarray.c + src/system/file.h + src/system/file.c + src/ring_buffer.h + src/ring_buffer.c ) -target_link_libraries(nothing ${SDL2_LIBRARIES} system) +target_link_libraries(nothing ${SDL2_LIBRARIES}) -ADD_CUSTOM_TARGET(link_assets ALL - COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/assets ${CMAKE_BINARY_DIR}/assets) +if(WIN32) + ADD_CUSTOM_TARGET(link_assets ALL COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/assets ${CMAKE_BINARY_DIR}/assets) +else() + ADD_CUSTOM_TARGET(link_assets ALL COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/assets ${CMAKE_BINARY_DIR}/assets) +endif() if(("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")) set(CMAKE_C_FLAGS