diff --git a/CMakeLists.txt b/CMakeLists.txt index 26a9bc3..038aff7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,19 +15,12 @@ endif() include(cmake/Utils.cmake) -if (CMAKE_SYSTEM_NAME STREQUAL "Windows" AND USE_AUTO_VCPKG) - include(cmake/automate-vcpkg.cmake) - - if ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32") - set(VCPKG_TRIPLET x86-windows-static) - set(VCPKG_TARGET_TRIPLET x86-windows-static) - elseif ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64") - set(VCPKG_TRIPLET x64-windows-static) - set(VCPKG_TARGET_TRIPLET x64-windows-static) - endif() - - vcpkg_bootstrap() - vcpkg_install_packages(zlib bzip2 sdl2 glew libzip nlohmann-json) +include(cmake/dependencies/common.cmake) +if (CMAKE_SYSTEM_NAME STREQUAL "Android") + include(cmake/dependencies/android.cmake) +endif() +if (CMAKE_SYSTEM_NAME STREQUAL "Windows") + include(cmake/dependencies/windows.cmake) endif() add_subdirectory("extern") diff --git a/cmake/dependencies/android.cmake b/cmake/dependencies/android.cmake new file mode 100644 index 0000000..3b400c4 --- /dev/null +++ b/cmake/dependencies/android.cmake @@ -0,0 +1,12 @@ +find_package(SDL2 QUIET) +if (NOT ${SDL2_FOUND}) + include(FetchContent) + FetchContent_Declare( + SDL2 + GIT_REPOSITORY https://github.com/libsdl-org/SDL.git + GIT_TAG release-2.28.1 + ) + message("SDL2 not found. Downloading now...") + FetchContent_MakeAvailable(SDL2) + message("SDL2 downloaded to " ${FETCHCONTENT_BASE_DIR}/sdl2-src) +endif() diff --git a/cmake/dependencies/common.cmake b/cmake/dependencies/common.cmake new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/cmake/dependencies/common.cmake @@ -0,0 +1 @@ + diff --git a/cmake/dependencies/windows.cmake b/cmake/dependencies/windows.cmake new file mode 100644 index 0000000..78cf4ff --- /dev/null +++ b/cmake/dependencies/windows.cmake @@ -0,0 +1,14 @@ +if (USE_AUTO_VCPKG) + include(cmake/automate-vcpkg.cmake) + + if ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32") + set(VCPKG_TRIPLET x86-windows-static) + set(VCPKG_TARGET_TRIPLET x86-windows-static) + elseif ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64") + set(VCPKG_TRIPLET x64-windows-static) + set(VCPKG_TARGET_TRIPLET x64-windows-static) + endif() + + vcpkg_bootstrap() + vcpkg_install_packages(zlib bzip2 sdl2 glew libzip nlohmann-json tinyxml2) +endif() diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index 0d2ec53..c39a69f 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -6,24 +6,6 @@ elseif (NOT CMAKE_SYSTEM_NAME STREQUAL "Android") find_package(SDL2 REQUIRED) endif() -################################################################################ -# Find/download SDL2 for Android -################################################################################ -if (CMAKE_SYSTEM_NAME STREQUAL "Android") - find_package(SDL2 QUIET) - if (NOT ${SDL2_FOUND}) - include(FetchContent) - FetchContent_Declare( - SDL2 - GIT_REPOSITORY https://github.com/libsdl-org/SDL.git - GIT_TAG release-2.28.1 - ) - message("SDL2 not found. Downloading now...") - FetchContent_MakeAvailable(SDL2) - message("SDL2 downloaded to " ${FETCHCONTENT_BASE_DIR}/sdl2-src) - endif() -endif() - #=================== DrLibs =================== set(DRLIBS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/dr_libs)