nothing/CMakeLists.txt

234 lines
6.7 KiB
CMake
Raw Permalink Normal View History

2019-10-23 20:47:01 -07:00
cmake_minimum_required(VERSION 3.13)
2017-11-30 17:52:59 -08:00
project(nothing)
set(NOTHING_CI OFF CACHE BOOL "Indicates whether the build is running on CI or not")
2019-05-25 04:58:13 -07:00
if(WIN32)
# do the flags thing first.
2019-08-10 19:54:33 -07:00
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
endif()
2019-08-10 19:54:33 -07:00
# 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()
2019-08-10 19:54:33 -07:00
else()
set(SDL2_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/SDL2/include")
2019-05-25 04:58:13 -07:00
# 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)
2019-08-10 19:54:33 -07:00
endif()
2019-05-25 04:58:13 -07:00
else()
find_package(SDL2 REQUIRED)
endif()
2018-03-01 13:03:56 -08:00
2019-06-27 07:28:45 -07:00
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})
2018-04-29 05:45:50 -07:00
include_directories(src/)
2018-12-17 07:27:15 -08:00
2019-05-25 06:29:35 -07:00
include_directories(${SDL2_INCLUDE_DIRS})
2018-12-17 07:27:15 -08:00
add_executable(nothing
2018-04-29 06:59:56 -07:00
src/color.h
2019-11-16 09:16:36 -08:00
src/color.c
src/game.h
2019-11-16 09:16:36 -08:00
src/game.c
2018-05-02 21:43:54 -07:00
src/game/camera.h
2019-11-16 09:16:36 -08:00
src/game/camera.c
2018-04-29 05:48:11 -07:00
src/game/level.h
2019-11-16 09:16:36 -08:00
src/game/level.c
2018-04-29 12:15:15 -07:00
src/game/level/background.h
2019-11-16 09:16:36 -08:00
src/game/level/background.c
2018-07-01 09:29:07 -07:00
src/game/level/boxes.h
2019-11-16 09:16:36 -08:00
src/game/level/boxes.c
2018-04-29 05:59:16 -07:00
src/game/level/goals.h
2019-11-16 09:16:36 -08:00
src/game/level/goals.c
src/game/level/labels.h
2019-11-16 09:16:36 -08:00
src/game/level/labels.c
2018-04-29 06:01:01 -07:00
src/game/level/lava.h
2019-11-16 09:16:36 -08:00
src/game/level/lava.c
src/game/level/lava/wavy_rect.h
2019-11-16 09:16:36 -08:00
src/game/level/lava/wavy_rect.c
2018-04-29 06:59:56 -07:00
src/game/level/platforms.h
2019-11-16 09:16:36 -08:00
src/game/level/platforms.c
2020-01-25 12:17:01 -08:00
src/game/level/phantom_platforms.h
src/game/level/phantom_platforms.c
2018-04-29 06:59:56 -07:00
src/game/level/player.h
2019-11-16 09:16:36 -08:00
src/game/level/player.c
2019-02-16 12:48:36 -08:00
src/game/level/explosion.h
2019-11-16 09:16:36 -08:00
src/game/level/explosion.c
src/game/level/regions.h
2019-11-16 09:16:36 -08:00
src/game/level/regions.c
src/game/level/rigid_bodies.h
2019-11-16 09:16:36 -08:00
src/game/level/rigid_bodies.c
src/game/level/action.h
src/game/level_picker.h
2019-11-16 09:16:36 -08:00
src/game/level_picker.c
2019-11-21 14:45:11 -08:00
src/game/credits.h
src/game/credits.c
2019-11-02 12:53:10 -07:00
src/game/settings.h
2019-11-16 09:16:36 -08:00
src/game/settings.c
2018-05-03 05:53:21 -07:00
src/game/sound_samples.h
2019-11-16 09:16:36 -08:00
src/game/sound_samples.c
2018-07-14 11:22:38 -07:00
src/game/sprite_font.h
2019-11-16 09:16:36 -08:00
src/game/sprite_font.c
src/main.c
src/math/extrema.h
2018-04-29 06:14:14 -07:00
src/math/mat3x3.h
2018-04-29 06:59:56 -07:00
src/math/pi.h
2019-09-28 13:24:30 -07:00
src/math/vec.h
2018-04-29 06:12:50 -07:00
src/math/rand.h
2019-11-16 09:16:36 -08:00
src/math/rand.c
2018-04-29 06:59:56 -07:00
src/math/rect.h
2019-11-16 09:16:36 -08:00
src/math/rect.c
2018-04-29 06:59:56 -07:00
src/math/triangle.h
2019-11-16 09:16:36 -08:00
src/math/triangle.c
2018-04-29 06:59:56 -07:00
src/sdl/renderer.h
2019-11-16 09:16:36 -08:00
src/sdl/renderer.c
2019-03-30 12:03:44 -07:00
src/sdl/texture.h
src/sdl/texture.c
2019-11-16 08:57:16 -08:00
src/ui/cursor.c
2019-11-16 12:18:18 -08:00
src/ui/cursor.h
src/ui/console.h
2019-11-16 09:16:36 -08:00
src/ui/console.c
2018-11-05 05:27:31 -08:00
src/ui/console_log.h
2019-11-16 09:16:36 -08:00
src/ui/console_log.c
src/ui/edit_field.h
2019-11-16 09:16:36 -08:00
src/ui/edit_field.c
src/ui/history.h
2019-11-16 09:16:36 -08:00
src/ui/history.c
2019-07-28 12:48:18 -07:00
src/ui/wiggly_text.h
src/ui/wiggly_text.c
2019-06-30 10:21:52 -07:00
src/ui/slider.h
src/ui/slider.c
2019-04-07 11:19:09 -07:00
src/game/level/level_editor.h
src/game/level/level_editor.c
2019-04-07 12:20:48 -07:00
src/game/level/level_editor/color_picker.h
src/game/level/level_editor/color_picker.c
2019-05-19 09:27:55 -07:00
src/game/level/level_editor/rect_layer.h
src/game/level/level_editor/rect_layer.c
2019-04-28 11:49:55 -07:00
src/game/level/level_editor/layer_picker.h
src/game/level/level_editor/layer_picker.c
2019-05-04 10:58:00 -07:00
src/game/level/level_editor/point_layer.h
src/game/level/level_editor/point_layer.c
2019-05-19 09:59:28 -07:00
src/game/level/level_editor/player_layer.h
src/game/level/level_editor/player_layer.c
2019-05-19 11:56:02 -07:00
src/game/level/level_editor/layer.h
src/game/level/level_editor/layer.c
2019-06-09 09:52:20 -07:00
src/game/level/level_editor/label_layer.h
2019-11-16 09:16:36 -08:00
src/game/level/level_editor/label_layer.c
2019-08-10 11:36:16 -07:00
src/game/level/level_editor/background_layer.h
2019-11-16 09:16:36 -08:00
src/game/level/level_editor/background_layer.c
2019-08-03 12:44:12 -07:00
src/game/level/level_editor/undo_history.h
src/game/level/level_editor/undo_history.c
2019-11-24 09:56:44 -08:00
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
2020-01-05 10:05:36 -08:00
src/ring_buffer.h
src/ring_buffer.c
2017-11-30 17:52:59 -08:00
)
2019-11-24 09:56:44 -08:00
target_link_libraries(nothing ${SDL2_LIBRARIES})
2017-12-09 21:02:44 -08:00
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()
2019-10-23 20:47:01 -07:00
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
"${CMAKE_C_FLAGS} \
-Wall \
-Wextra \
-Wconversion \
-Wunused \
-Wunused-function \
-Wunused-label \
-Wunused-macros \
-Wunused-parameter \
-Wunused-value \
-Wunused-variable \
-Wcast-align \
-Wcast-qual \
-Wmissing-declarations \
-Wredundant-decls \
-Wmissing-prototypes \
-Wnested-externs \
-Wpointer-arith \
-Wshadow \
-Wstrict-prototypes \
-Wwrite-strings \
2018-06-02 09:36:23 -07:00
-Wswitch \
-Wmissing-field-initializers \
-fno-common \
-fno-strict-aliasing \
-pedantic \
-std=c11 \
-ggdb \
-O3")
if (${NOTHING_CI})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
endif()
2017-12-09 21:02:44 -08:00
target_link_libraries(nothing m)
2019-06-23 08:42:48 -07:00
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} \
/Wall \
/wd4127 \
2019-06-23 08:42:48 -07:00
/wd4201 \
/wd4204 \
/wd4255 \
2019-06-27 10:46:24 -07:00
/wd4389 \
2019-06-23 08:42:48 -07:00
/wd4668 \
/wd4702 \
2019-06-23 08:42:48 -07:00
/wd4710 \
/wd4777 \
/wd4820 \
/wd5045 \
/wd4200 \
/wd4706 \
2019-06-23 08:42:48 -07:00
/D \"_CRT_SECURE_NO_WARNINGS\"")
if (${NOTHING_CI})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
endif()
2017-12-09 21:02:44 -08:00
endif()
2019-08-10 19:54:33 -07:00
if(MINGW)
target_link_libraries(nothing hid setupapi Imm32 Version winmm)
elseif(WIN32)
2017-12-09 21:02:44 -08:00
target_link_libraries(nothing Imm32 Version winmm)
endif()