]> git.lizzy.rs Git - nothing.git/blobdiff - CMakeLists.txt
Merge pull request #1009 from The-Renaissance/master
[nothing.git] / CMakeLists.txt
index c6329b4398a1c5197de32ac2563697df9376c43d..b2f0ef4b8d53522e9ecaadc52c8060d32bbaf307 100644 (file)
@@ -2,16 +2,31 @@ cmake_minimum_required(VERSION 3.2)
 project(nothing)
 
 if(WIN32)
-  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")
+  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_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)
+  
 else()
   find_package(SDL2 REQUIRED)
 endif()
@@ -34,6 +49,8 @@ add_library(system STATIC
   src/system/log_script.c
   src/system/log_script.h
   src/system/lt.h
+  src/system/lt_adapters.h
+  src/system/lt_adapters.c
   src/system/nth_alloc.c
   src/system/nth_alloc.h
   src/system/stacktrace.c
@@ -44,6 +61,8 @@ add_library(system STATIC
   src/dynarray.c
   src/hashset.h
   src/hashset.c
+  src/system/file.h
+  src/system/file.c
   )
 
 add_library(ebisp STATIC
@@ -137,14 +156,12 @@ add_executable(nothing
   src/ui/history.h
   src/ui/list_selector.h
   src/ui/list_selector.c
-  src/ui/menu_title.h
-  src/ui/menu_title.c
+  src/ui/wiggly_text.h
+  src/ui/wiggly_text.c
   src/ui/slider.h
   src/ui/slider.c
   src/game/level_metadata.h
   src/game/level_metadata.c
-  src/game/level/level_editor/proto_rect.h
-  src/game/level/level_editor/proto_rect.c
   src/game/level/level_editor.h
   src/game/level/level_editor.c
   src/game/level/level_editor/color_picker.h
@@ -161,8 +178,8 @@ add_executable(nothing
   src/game/level/level_editor/layer.c
   src/game/level/level_editor/label_layer.c
   src/game/level/level_editor/label_layer.h
-  src/system/file.h
-  src/system/file.c
+  src/game/level/level_editor/undo_history.h
+  src/game/level/level_editor/undo_history.c
 )
 target_link_libraries(nothing ${SDL2_LIBRARIES} system ebisp)
 
@@ -179,7 +196,7 @@ add_executable(nothing_test
   )
 target_link_libraries(nothing_test ${SDL2_LIBRARIES} system ebisp)
 
-if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "CLANG"))
+if(("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang"))
   set(CMAKE_C_FLAGS
     "${CMAKE_C_FLAGS} \
      -Wall \
@@ -206,6 +223,7 @@ if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" ST
      -Wswitch \
      -Wmissing-field-initializers \
      -fno-common \
+          -fno-strict-aliasing \
      -pedantic \
      -std=c11 \
      -ggdb \
@@ -229,7 +247,9 @@ elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
     /wd5045 \
     /D \"_CRT_SECURE_NO_WARNINGS\"")
 endif()
-if(WIN32)
+if(MINGW)
+  target_link_libraries(nothing hid setupapi Imm32 Version winmm)
+elseif(WIN32)
   target_link_libraries(nothing Imm32 Version winmm)
 endif()