CMakeLists: reorganise how system deps are handled.
Allowing each dependency to be system-wide or not is gonna be an improvement, especially when it comes to IDE memory usage.
This commit is contained in:
parent
35c96af509
commit
bd360b9268
2 changed files with 47 additions and 17 deletions
|
@ -23,23 +23,21 @@ set(ZLIB_USE_STATIC_LIBS ON CACHE BOOL "" FORCE) # Required on setups where zlib
|
||||||
|
|
||||||
option(SAVETOOL_USE_SYSTEM_LIBS "Use system-wide versions of the dependencies instead of the versions provided by submodules." OFF)
|
option(SAVETOOL_USE_SYSTEM_LIBS "Use system-wide versions of the dependencies instead of the versions provided by submodules." OFF)
|
||||||
|
|
||||||
|
include(CMakeDependentOption)
|
||||||
|
cmake_dependent_option(SAVETOOL_USE_SYSTEM_CORRADE_MAGNUM "Use system-wide versions of Corrade and Magnum." ON "SAVETOOL_USE_SYSTEM_LIBS" OFF)
|
||||||
|
cmake_dependent_option(SAVETOOL_USE_SYSTEM_SDL2 "Use a system-wide version of SDL2." ON "SAVETOOL_USE_SYSTEM_LIBS" OFF)
|
||||||
|
cmake_dependent_option(SAVETOOL_USE_SYSTEM_LIBZIP "Use a system-wide version of libzip." ON "SAVETOOL_USE_SYSTEM_LIBS" OFF)
|
||||||
|
cmake_dependent_option(SAVETOOL_USE_SYSTEM_EFSW "Use a system-wide version of EFSW." ON "SAVETOOL_USE_SYSTEM_LIBS" OFF)
|
||||||
|
cmake_dependent_option(SAVETOOL_USE_SYSTEM_LIBCURL "Use a system-wide version of libcurl." ON "SAVETOOL_USE_SYSTEM_LIBS" OFF)
|
||||||
|
|
||||||
if(NOT SAVETOOL_USE_SYSTEM_LIBS)
|
if(NOT SAVETOOL_USE_SYSTEM_LIBS)
|
||||||
# Generic variables shared by multiple libs that don't provide their own.
|
# Generic variables shared by multiple libs that don't provide their own.
|
||||||
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
|
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
|
||||||
set(BUILD_STATIC_LIBS ON CACHE BOOL "" FORCE)
|
set(BUILD_STATIC_LIBS ON CACHE BOOL "" FORCE)
|
||||||
set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
|
set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
|
||||||
|
endif(NOT SAVETOOL_USE_SYSTEM_LIBS)
|
||||||
|
|
||||||
set(CORRADE_BUILD_DEPRECATED OFF CACHE BOOL "" FORCE)
|
if(NOT SAVETOOL_USE_SYSTEM_SDL2)
|
||||||
set(CORRADE_BUILD_STATIC ON CACHE BOOL "" FORCE)
|
|
||||||
set(CORRADE_BUILD_STATIC_PIC ON CACHE BOOL "" FORCE)
|
|
||||||
set(CORRADE_BUILD_STATIC_UNIQUE_GLOBALS OFF CACHE BOOL "" FORCE)
|
|
||||||
set(CORRADE_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
|
||||||
set(CORRADE_WITH_INTERCONNECT OFF CACHE BOOL "" FORCE)
|
|
||||||
set(CORRADE_WITH_PLUGINMANAGER OFF CACHE BOOL "" FORCE)
|
|
||||||
set(CORRADE_WITH_TESTSUITE OFF CACHE BOOL "" FORCE)
|
|
||||||
set(CORRADE_WITH_MAIN ON CACHE BOOL "" FORCE)
|
|
||||||
add_subdirectory(third-party/corrade EXCLUDE_FROM_ALL)
|
|
||||||
|
|
||||||
set(DIRECTX OFF CACHE BOOL "" FORCE) # We use OpenGL.
|
set(DIRECTX OFF CACHE BOOL "" FORCE) # We use OpenGL.
|
||||||
set(SDL_ATOMIC OFF CACHE BOOL "" FORCE)
|
set(SDL_ATOMIC OFF CACHE BOOL "" FORCE)
|
||||||
set(SDL_CPUINFO OFF CACHE BOOL "" FORCE)
|
set(SDL_CPUINFO OFF CACHE BOOL "" FORCE)
|
||||||
|
@ -55,6 +53,19 @@ if(NOT SAVETOOL_USE_SYSTEM_LIBS)
|
||||||
set(SDL_TIMERS ON CACHE BOOL "" FORCE)
|
set(SDL_TIMERS ON CACHE BOOL "" FORCE)
|
||||||
set(SDL_SHARED OFF CACHE BOOL "" FORCE)
|
set(SDL_SHARED OFF CACHE BOOL "" FORCE)
|
||||||
add_subdirectory(third-party/SDL EXCLUDE_FROM_ALL)
|
add_subdirectory(third-party/SDL EXCLUDE_FROM_ALL)
|
||||||
|
endif(NOT SAVETOOL_USE_SYSTEM_SDL2)
|
||||||
|
|
||||||
|
if(NOT SAVETOOL_USE_SYSTEM_CORRADE_MAGNUM)
|
||||||
|
set(CORRADE_BUILD_DEPRECATED OFF CACHE BOOL "" FORCE)
|
||||||
|
set(CORRADE_BUILD_STATIC ON CACHE BOOL "" FORCE)
|
||||||
|
set(CORRADE_BUILD_STATIC_PIC ON CACHE BOOL "" FORCE)
|
||||||
|
set(CORRADE_BUILD_STATIC_UNIQUE_GLOBALS OFF CACHE BOOL "" FORCE)
|
||||||
|
set(CORRADE_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
||||||
|
set(CORRADE_WITH_INTERCONNECT OFF CACHE BOOL "" FORCE)
|
||||||
|
set(CORRADE_WITH_PLUGINMANAGER OFF CACHE BOOL "" FORCE)
|
||||||
|
set(CORRADE_WITH_TESTSUITE OFF CACHE BOOL "" FORCE)
|
||||||
|
set(CORRADE_WITH_MAIN ON CACHE BOOL "" FORCE)
|
||||||
|
add_subdirectory(third-party/corrade EXCLUDE_FROM_ALL)
|
||||||
|
|
||||||
set(MAGNUM_BUILD_STATIC ON CACHE BOOL "" FORCE)
|
set(MAGNUM_BUILD_STATIC ON CACHE BOOL "" FORCE)
|
||||||
set(MAGNUM_BUILD_STATIC_PIC ON CACHE BOOL "" FORCE)
|
set(MAGNUM_BUILD_STATIC_PIC ON CACHE BOOL "" FORCE)
|
||||||
|
@ -85,7 +96,9 @@ if(NOT SAVETOOL_USE_SYSTEM_LIBS)
|
||||||
set(IMGUI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third-party/imgui)
|
set(IMGUI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third-party/imgui)
|
||||||
set(MAGNUM_WITH_IMGUI ON CACHE BOOL "" FORCE)
|
set(MAGNUM_WITH_IMGUI ON CACHE BOOL "" FORCE)
|
||||||
add_subdirectory(third-party/magnum-integration EXCLUDE_FROM_ALL)
|
add_subdirectory(third-party/magnum-integration EXCLUDE_FROM_ALL)
|
||||||
|
endif(NOT SAVETOOL_USE_SYSTEM_CORRADE_MAGNUM)
|
||||||
|
|
||||||
|
if(NOT SAVETOOL_USE_SYSTEM_LIBZIP)
|
||||||
set(ENABLE_COMMONCRYPTO OFF CACHE BOOL "" FORCE)
|
set(ENABLE_COMMONCRYPTO OFF CACHE BOOL "" FORCE)
|
||||||
set(ENABLE_GNUTLS OFF CACHE BOOL "" FORCE)
|
set(ENABLE_GNUTLS OFF CACHE BOOL "" FORCE)
|
||||||
set(ENABLE_MBEDTLS OFF CACHE BOOL "" FORCE)
|
set(ENABLE_MBEDTLS OFF CACHE BOOL "" FORCE)
|
||||||
|
@ -99,12 +112,16 @@ if(NOT SAVETOOL_USE_SYSTEM_LIBS)
|
||||||
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
||||||
set(BUILD_DOC OFF CACHE BOOL "" FORCE)
|
set(BUILD_DOC OFF CACHE BOOL "" FORCE)
|
||||||
add_subdirectory(third-party/libzip EXCLUDE_FROM_ALL)
|
add_subdirectory(third-party/libzip EXCLUDE_FROM_ALL)
|
||||||
|
endif(NOT SAVETOOL_USE_SYSTEM_LIBZIP)
|
||||||
|
|
||||||
|
if(NOT SAVETOOL_USE_SYSTEM_EFSW)
|
||||||
set(VERBOSE OFF CACHE BOOL "" FORCE)
|
set(VERBOSE OFF CACHE BOOL "" FORCE)
|
||||||
set(BUILD_TEST_APP OFF CACHE BOOL "" FORCE)
|
set(BUILD_TEST_APP OFF CACHE BOOL "" FORCE)
|
||||||
set(EFSW_INSTALL OFF CACHE BOOL "" FORCE)
|
set(EFSW_INSTALL OFF CACHE BOOL "" FORCE)
|
||||||
add_subdirectory(third-party/efsw EXCLUDE_FROM_ALL)
|
add_subdirectory(third-party/efsw EXCLUDE_FROM_ALL)
|
||||||
|
endif(NOT SAVETOOL_USE_SYSTEM_EFSW)
|
||||||
|
|
||||||
|
if(NOT SAVETOOL_USE_SYSTEM_LIBCURL)
|
||||||
set(BUILD_CURL_EXE OFF CACHE BOOL "" FORCE)
|
set(BUILD_CURL_EXE OFF CACHE BOOL "" FORCE)
|
||||||
set(ENABLE_UNICODE ON CACHE BOOL "" FORCE)
|
set(ENABLE_UNICODE ON CACHE BOOL "" FORCE)
|
||||||
set(ENABLE_INET_PTON OFF CACHE BOOL "" FORCE)
|
set(ENABLE_INET_PTON OFF CACHE BOOL "" FORCE)
|
||||||
|
@ -118,6 +135,6 @@ if(NOT SAVETOOL_USE_SYSTEM_LIBS)
|
||||||
set(CURL_USE_SCHANNEL ON CACHE BOOL "" FORCE)
|
set(CURL_USE_SCHANNEL ON CACHE BOOL "" FORCE)
|
||||||
set(CURL_USE_LIBSSH2 OFF CACHE BOOL "" FORCE) # For some reason, even when HTTP_ONLY is set to ON, libcurl will try to link to libssh2.
|
set(CURL_USE_LIBSSH2 OFF CACHE BOOL "" FORCE) # For some reason, even when HTTP_ONLY is set to ON, libcurl will try to link to libssh2.
|
||||||
add_subdirectory(third-party/curl EXCLUDE_FROM_ALL)
|
add_subdirectory(third-party/curl EXCLUDE_FROM_ALL)
|
||||||
endif(NOT SAVETOOL_USE_SYSTEM_LIBS)
|
endif(NOT SAVETOOL_USE_SYSTEM_LIBCURL)
|
||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
|
@ -26,11 +26,18 @@ if(CORRADE_TARGET_WINDOWS)
|
||||||
endif()
|
endif()
|
||||||
find_package(Magnum REQUIRED GL Sdl2Application)
|
find_package(Magnum REQUIRED GL Sdl2Application)
|
||||||
find_package(MagnumIntegration REQUIRED ImGui)
|
find_package(MagnumIntegration REQUIRED ImGui)
|
||||||
if(SAVETOOL_USE_SYSTEM_LIBS)
|
|
||||||
|
if(SAVETOOL_USE_SYSTEM_LIBZIP)
|
||||||
find_package(libzip REQUIRED)
|
find_package(libzip REQUIRED)
|
||||||
|
endif(SAVETOOL_USE_SYSTEM_LIBZIP)
|
||||||
|
|
||||||
|
if(SAVETOOL_USE_SYSTEM_EFSW)
|
||||||
find_package(efsw REQUIRED)
|
find_package(efsw REQUIRED)
|
||||||
|
endif(SAVETOOL_USE_SYSTEM_EFSW)
|
||||||
|
|
||||||
|
if(SAVETOOL_USE_SYSTEM_LIBCURL)
|
||||||
find_package(CURL REQUIRED HTTPS)
|
find_package(CURL REQUIRED HTTPS)
|
||||||
endif()
|
endif(SAVETOOL_USE_SYSTEM_LIBCURL)
|
||||||
|
|
||||||
set_directory_properties(PROPERTIES CORRADE_USE_PEDANTIC_FLAGS ON)
|
set_directory_properties(PROPERTIES CORRADE_USE_PEDANTIC_FLAGS ON)
|
||||||
|
|
||||||
|
@ -247,10 +254,16 @@ target_link_libraries(MassBuilderSaveTool PRIVATE
|
||||||
CURL::libcurl_static
|
CURL::libcurl_static
|
||||||
)
|
)
|
||||||
|
|
||||||
if(SAVETOOL_USE_SYSTEM_LIBS)
|
if(SAVETOOL_USE_SYSTEM_LIBZIP)
|
||||||
target_link_libraries(MassBuilderSaveTool PRIVATE libzip::zip efsw::efsw)
|
target_link_libraries(MassBuilderSaveTool PRIVATE libzip::zip)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(MassBuilderSaveTool PRIVATE zip efsw)
|
target_link_libraries(MassBuilderSaveTool PRIVATE zip)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(SAVETOOL_USE_SYSTEM_EFSW)
|
||||||
|
target_link_libraries(MassBuilderSaveTool PRIVATE efsw::efsw)
|
||||||
|
else()
|
||||||
|
target_link_libraries(MassBuilderSaveTool PRIVATE efsw)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CORRADE_TARGET_WINDOWS)
|
if(CORRADE_TARGET_WINDOWS)
|
||||||
|
|
Loading…
Reference in a new issue