From 4419f722183cd390f09200a1a58162653fd97453 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Tue, 18 Jan 2022 00:45:17 -0500 Subject: [PATCH] devendor libraries --- CMakeLists.txt | 67 +++++++++++++++++++++++++++++++------------------ src/audio/sdl.h | 2 +- 2 files changed, 43 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 80026f41..8b0e5f13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,39 +13,52 @@ else() set(BUILD_GUI ON) endif() -add_subdirectory(extern/fmt) +option(DEVENDOR_LIBRARIES "Use local versions of dependencies instead of the ones provided by submodules" OFF) -set(BUILD_TESTING OFF CACHE BOOL "aaaaaa" FORCE) -set(BUILD_PROGRAMS OFF CACHE BOOL "aaa" FORCE) -set(BUILD_EXAMPLES OFF CACHE BOOL "a" FORCE) -set(ENABLE_EXTERNAL_LIBS OFF CACHE BOOL "come on" FORCE) -set(ENABLE_MPEG OFF CACHE BOOL "come on" FORCE) -add_subdirectory(extern/libsndfile) -add_subdirectory(extern/zlib) +if (NOT DEVENDOR_LIBRARIES) + add_subdirectory(extern/fmt) +endif() -include_directories(extern/zlib ${CMAKE_CURRENT_BINARY_DIR}/extern/zlib) +if (NOT DEVENDOR_LIBRARIES) + set(BUILD_TESTING OFF CACHE BOOL "aaaaaa" FORCE) + set(BUILD_PROGRAMS OFF CACHE BOOL "aaa" FORCE) + set(BUILD_EXAMPLES OFF CACHE BOOL "a" FORCE) + set(ENABLE_EXTERNAL_LIBS OFF CACHE BOOL "come on" FORCE) + set(ENABLE_MPEG OFF CACHE BOOL "come on" FORCE) + add_subdirectory(extern/libsndfile) + add_subdirectory(extern/zlib) -if (WIN32) - set(SDL_SHARED OFF) - set(SDL_STATIC ON) - add_subdirectory(extern/SDL) - set(HAVE_SDL2 SDL2-static) - set(HAVE_Z zlibstatic) - include_directories(extern/SDL/include extern/imgui extern/IconFontCppHeaders extern/imgui/backends extern/igfd extern/fmt/include) + include_directories(extern/zlib ${CMAKE_CURRENT_BINARY_DIR}/extern/zlib) +endif() + +if (DEVENDOR_LIBRARIES) + find_package(SDL REQUIRED) + set(HAVE_SDL2 ${SDL_LIBRARY}) + include_directories(extern/imgui extern/IconFontCppHeaders extern/imgui/backends extern/igfd ${SDL_INCLUDE_DIR}) + find_library(HAVE_JACK jack) else() - if (BUILD_GUI) - set(SDL_SHARED ON) + if (WIN32) + set(SDL_SHARED OFF) + set(SDL_STATIC ON) add_subdirectory(extern/SDL) - include_directories(extern/SDL/include extern/imgui extern/IconFontCppHeaders extern/imgui/backends extern/igfd extern/fmt/include) set(HAVE_SDL2 SDL2-static) + set(HAVE_Z zlibstatic) + include_directories(extern/SDL/include extern/imgui extern/IconFontCppHeaders extern/imgui/backends extern/igfd extern/fmt/include) else() - find_library(HAVE_SDL2 SDL2) + if (BUILD_GUI) + set(SDL_SHARED ON) + add_subdirectory(extern/SDL) + include_directories(extern/SDL/include extern/imgui extern/IconFontCppHeaders extern/imgui/backends extern/igfd extern/fmt/include) + set(HAVE_SDL2 SDL2-static) + else() + find_library(HAVE_SDL2 SDL2) + endif() + if (NOT APPLE) + find_library(HAVE_JACK jack) + endif() + find_library(HAVE_SNDFILE sndfile) + set(HAVE_Z zlibstatic) endif() - if (NOT APPLE) - find_library(HAVE_JACK jack) - endif() - find_library(HAVE_SNDFILE sndfile) - set(HAVE_Z zlibstatic) endif() set(AUDIO_SOURCES src/audio/abstract.cpp) @@ -154,6 +167,10 @@ else() add_executable(furnace ${ENGINE_SOURCES} ${AUDIO_SOURCES} src/main.cpp) endif() +if (DEVENDOR_LIBRARIES) + target_compile_definitions(furnace PUBLIC DEVENDOR_LIBRARIES) +endif() + target_link_libraries(furnace ${HAVE_SDL2} ${HAVE_Z} sndfile fmt) if (HAVE_JACK) diff --git a/src/audio/sdl.h b/src/audio/sdl.h index a9296fd4..6b296855 100644 --- a/src/audio/sdl.h +++ b/src/audio/sdl.h @@ -1,5 +1,5 @@ #include "taAudio.h" -#if defined(_WIN32) || defined(HAVE_GUI) +#if (defined(_WIN32) || defined(HAVE_GUI)) && !defined(DEVENDOR_LIBRARIES) #include #else #include