cmake_minimum_required(VERSION 3.2)
project(nothing)
-find_package(SDL2 REQUIRED)
+if(WIN32)
+ 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")
+
+ # 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()
+
+if("${SDL2_LIBRARIES}" STREQUAL "")
+ message(WARNING "SDL2_LIBRARIES wasn't set, manually setting to SDL2::SDL2")
+ set(SDL2_LIBRARIES "SDL2::SDL2")
+endif()
include_directories(${CMAKE_BINARY_DIR})
include_directories(src/)
-include_directories(${SDL2_INCLUDE_DIR})
+include_directories(${SDL2_INCLUDE_DIRS})
add_library(system STATIC
src/system/line_stream.c
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
src/dynarray.c
src/hashset.h
src/hashset.c
+ src/system/file.h
+ src/system/file.c
)
add_library(ebisp STATIC
target_link_libraries(ebisp system)
add_executable(nothing
- broadcast_lisp.h
src/broadcast.c
src/broadcast.h
src/color.c
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
src/game/level/level_editor/player_layer.c
src/game/level/level_editor/layer.h
src/game/level/level_editor/layer.c
+ src/game/level/level_editor/label_layer.c
+ src/game/level/level_editor/label_layer.h
+ src/game/level/level_editor/undo_history.h
+ src/game/level/level_editor/undo_history.c
)
-target_link_libraries(nothing ${SDL2_LIBRARIES} m system ebisp)
-
-add_custom_command(
- OUTPUT broadcast_lisp.h
- COMMAND ${CMAKE_BINARY_DIR}/baker ${CMAKE_SOURCE_DIR}/src/broadcast.lisp broadcast_lisp.h broadcast_lisp_library
- DEPENDS baker src/broadcast.lisp)
+target_link_libraries(nothing ${SDL2_LIBRARIES} system ebisp)
add_executable(repl
src/ebisp/repl.c
src/ebisp/repl_runtime.c
)
-target_link_libraries(repl ${SDL2_LIBRARIES} m system ebisp)
-
-add_executable(baker
- src/ebisp/baker.c
- )
-target_link_libraries(baker m system ebisp)
+target_link_libraries(repl ${SDL2_LIBRARIES} system ebisp)
add_executable(nothing_test
test/main.c
test/test.h
test/tokenizer_suite.h
)
-target_link_libraries(nothing_test ${SDL2_LIBRARIES} m system ebisp)
-
-if (UNIX)
- add_subdirectory(devtools/svg2level)
-endif()
+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 \
-Wswitch \
-Wmissing-field-initializers \
-fno-common \
+ -fno-strict-aliasing \
-pedantic \
-std=c11 \
-ggdb \
-O3")
target_link_libraries(nothing m)
+elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
+ set(CMAKE_C_FLAGS
+ "${CMAKE_C_FLAGS} \
+ /Wall \
+ /WX \
+ /wd4127 \
+ /wd4201 \
+ /wd4204 \
+ /wd4255 \
+ /wd4389 \
+ /wd4668 \
+ /wd4702 \
+ /wd4710 \
+ /wd4777 \
+ /wd4820 \
+ /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()
-file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/sounds DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
-file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/images DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test-data DESTINATION ${CMAKE_CURRENT_BINARY_DIR})