mirror of
https://github.com/JaCzekanski/Avocado.git
synced 2024-06-02 03:07:39 -04:00
cmake: find SDL automatically or add it from sources
This commit is contained in:
parent
2984aa8744
commit
00ab650aac
|
@ -3,13 +3,18 @@ project(Avocado)
|
|||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
option(FORCE_BUILD_SDL "Force build SDL2 from sources." OFF)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-Ofast")
|
||||
add_compile_options(-mavx2 -m64)
|
||||
add_link_options(-mavx2 -m64)
|
||||
|
||||
find_program(CCACHE_FOUND ccache)
|
||||
if(CCACHE_FOUND)
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
|
||||
endif()
|
||||
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
message(STATUS "Building as Release")
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
|
@ -36,7 +41,10 @@ target_include_directories(event_bus INTERFACE externals/EventBus/lib/include)
|
|||
|
||||
##############################################
|
||||
# stb_image
|
||||
add_library(stb_image INTERFACE)
|
||||
add_library(stb_image STATIC
|
||||
externals/stb/stb_image.c
|
||||
externals/stb/stb_image_write.c
|
||||
)
|
||||
target_include_directories(stb_image INTERFACE externals/stb)
|
||||
|
||||
##############################################
|
||||
|
@ -161,6 +169,21 @@ target_include_directories(json INTERFACE externals/json/include)
|
|||
add_library(filesystem INTERFACE)
|
||||
target_include_directories(filesystem INTERFACE externals/filesystem/include)
|
||||
|
||||
##############################################
|
||||
# SDL
|
||||
if (FORCE_BUILD_SDL)
|
||||
message(STATUS "Force building SDL2 from sources")
|
||||
add_subdirectory(externals/SDL2)
|
||||
else()
|
||||
find_package(SDL2)
|
||||
if (NOT SDL2_FOUND)
|
||||
message(STATUS "SDL2 not found, compiling from source")
|
||||
add_subdirectory(externals/SDL2)
|
||||
else()
|
||||
message(STATUS "SDL2 found")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
##############################################
|
||||
# core
|
||||
add_library(core STATIC
|
||||
|
@ -278,7 +301,6 @@ set(SOURCES
|
|||
src/platform/windows/gui/options/bios.cpp
|
||||
src/platform/windows/gui/options/memory_card.cpp
|
||||
src/platform/windows/gui/options/options.cpp
|
||||
src/platform/windows/gui/stb_image.cpp
|
||||
src/platform/windows/gui/toasts.cpp
|
||||
src/platform/windows/input/key.cpp
|
||||
src/platform/windows/input/sdl_input_manager.cpp
|
||||
|
@ -295,8 +317,6 @@ set(SOURCES
|
|||
src/renderer/opengl/shader/vertex_array_object.cpp
|
||||
)
|
||||
|
||||
find_package(SDL2 REQUIRED)
|
||||
|
||||
add_executable(avocado ${SOURCES})
|
||||
|
||||
target_include_directories(avocado
|
||||
|
@ -312,4 +332,6 @@ target_link_libraries(avocado
|
|||
json
|
||||
SDL2::SDL2
|
||||
filesystem
|
||||
)
|
||||
)
|
||||
|
||||
# set_property(TARGET avocado PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include <stb_image.h>
|
||||
#include "stb_image.h"
|
2
externals/stb/stb_image_write.c
vendored
Normal file
2
externals/stb/stb_image_write.c
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||
#include "stb_image_write.h"
|
12
premake/stb.lua
Normal file
12
premake/stb.lua
Normal file
|
@ -0,0 +1,12 @@
|
|||
group "externals"
|
||||
project "stb"
|
||||
uuid "70748C53-02F2-42E7-AE0A-8CBD19918850"
|
||||
kind "StaticLib"
|
||||
language "c"
|
||||
location "../build/libs/stb"
|
||||
includedirs {
|
||||
"../externals/stb"
|
||||
}
|
||||
files {
|
||||
"../externals/stb/*.c",
|
||||
}
|
|
@ -144,6 +144,7 @@ include "premake/imgui.lua"
|
|||
include "premake/lzma.lua"
|
||||
include "premake/miniz.lua"
|
||||
include "premake/fmt.lua"
|
||||
include "premake/stb.lua"
|
||||
|
||||
project "core"
|
||||
uuid "176665c5-37ff-4a42-bef8-02edaeb1b426"
|
||||
|
@ -179,6 +180,7 @@ project "core"
|
|||
"flac",
|
||||
"chdr",
|
||||
"fmt",
|
||||
"stb",
|
||||
}
|
||||
|
||||
if _ACTION ~= nil then
|
||||
|
@ -212,6 +214,7 @@ project "avocado"
|
|||
"lzma",
|
||||
"flac",
|
||||
"fmt",
|
||||
"stb",
|
||||
}
|
||||
|
||||
filter "options:headless"
|
||||
|
|
Loading…
Reference in a new issue