]> git.lizzy.rs Git - nothing.git/blobdiff - CMakeLists.txt
Merge pull request #1255 from tsoding/1253
[nothing.git] / CMakeLists.txt
index 8461c7d21cde42fc5a7f8c3bc267f365cb59979a..44b061269dd3823baa4f4fdfdd511f73a858fdb1 100644 (file)
@@ -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
@@ -88,6 +73,8 @@ add_executable(nothing
   src/game/level/lava/wavy_rect.c
   src/game/level/platforms.h
   src/game/level/platforms.c
+  src/game/level/phantom_platforms.h
+  src/game/level/phantom_platforms.c
   src/game/level/player.h
   src/game/level/player.c
   src/game/level/explosion.h
@@ -99,10 +86,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
@@ -122,6 +109,8 @@ add_executable(nothing
   src/sdl/renderer.c
   src/sdl/texture.h
   src/sdl/texture.c
+  src/ui/cursor.c
+  src/ui/cursor.h
   src/ui/console.h
   src/ui/console.c
   src/ui/console_log.h
@@ -130,16 +119,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
@@ -160,13 +143,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