From 4848632db2dfefb43c8fb2e3bb5e63a20ca7f0d9 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Tue, 7 Dec 2021 10:58:53 +0000 Subject: [PATCH] CMake: Organize files 1. Platform and toolchain files are now all under `platforms/`, with a single `CMake/platforms/${platform}.cmake` per platform. 2. Custom functions/macros are under `functions/`. 3. Finder modules are in `/finders`. --- .github/workflows/Linux_x86.yml | 6 +- .github/workflows/Windows_x64.yml | 6 +- .github/workflows/Windows_x86.yml | 6 +- .github/workflows/iOS.yml | 6 +- 3rdParty/SDL2/CMakeLists.txt | 2 +- 3rdParty/SDL_audiolib/CMakeLists.txt | 2 +- 3rdParty/SDL_image/CMakeLists.txt | 4 +- 3rdParty/asio/CMakeLists.txt | 2 +- 3rdParty/bzip2/CMakeLists.txt | 2 +- 3rdParty/find_steam_game/CMakeLists.txt | 22 +++---- 3rdParty/libfmt/CMakeLists.txt | 2 +- 3rdParty/libmpq/CMakeLists.txt | 2 +- 3rdParty/libpng/CMakeLists.txt | 2 +- 3rdParty/libsmackerdec/CMakeLists.txt | 2 +- 3rdParty/libsodium/CMakeLists.txt | 2 +- 3rdParty/libzt/CMakeLists.txt | 2 +- 3rdParty/simpleini/CMakeLists.txt | 2 +- CMake/Dependencies.cmake | 2 +- CMake/Platforms.cmake | 64 +++++++++---------- CMake/{ => finders}/FindGperftools.cmake | 0 CMake/{ => finders}/FindSDL2_image.cmake | 0 CMake/{ => finders}/Findsodium.cmake | 0 ...hContent_MakeAvailableExcludeFromAll.cmake | 0 .../{ => functions}/dependency_options.cmake | 0 CMake/{ => functions}/genex.cmake | 0 CMake/{ => functions}/git.cmake | 0 CMake/out_of_tree.cmake | 3 - .../amiga.cmake} | 0 .../android.cmake} | 0 .../cpigamesh.cmake} | 0 CMake/{ => platforms}/ctr/Tools3DS.cmake | 0 .../{ => platforms}/ctr/asio/include/errno.h | 0 .../{ => platforms}/ctr/asio/include/net/if.h | 0 .../{ => platforms}/ctr/asio/include/netdb.h | 0 .../ctr/asio/include/netinet/in.h | 0 .../ctr/asio/include/sys/ioctl.h | 0 .../ctr/asio/include/sys/poll.h | 0 .../ctr/asio/include/sys/socket.h | 0 .../ctr/asio/include/sys/uio.h | 0 .../{ => platforms}/ctr/asio/include/sys/un.h | 0 CMake/{ => platforms}/ctr/asio_defs.cmake | 0 CMake/{ => platforms}/ctr/bin2s_header.h.in | 0 .../ctr/modules/FindCITRO3D.cmake | 0 .../ctr/modules/FindCTRULIB.cmake | 0 .../{ => platforms}/ctr/modules/FindPNG.cmake | 0 .../ctr/modules/FindZLIB.cmake | 0 .../ctr/modules/LibFindMacros.cmake | 0 .../ctr/modules/try_add_imported_target.cmake | 0 .../gkd350h.cmake} | 0 CMake/{ios_defs.cmake => platforms/ios.cmake} | 0 CMake/{ => platforms}/ios.toolchain.cmake | 0 .../lepus.cmake} | 0 .../linux_i386.toolchain.cmake} | 0 .../mingwcc.toolchain.cmake} | 0 .../mingwcc64.toolchain.cmake} | 0 .../n3ds_defs.cmake => platforms/n3ds.cmake} | 3 +- .../retrofw.cmake} | 0 .../rg350.cmake} | 0 .../switch.cmake} | 2 + .../switch/asio/include/errno.h | 0 .../switch/asio/include/net/if.h | 0 .../switch/asio/include/netinet/in.h | 0 .../switch/asio/include/sys/uio.h | 0 .../switch/asio/include/sys/un.h | 0 .../{vita_defs.cmake => platforms/vita.cmake} | 0 CMake/switch/asio_defs.cmake | 5 -- CMakeLists.txt | 10 ++- docs/building.md | 6 +- 68 files changed, 82 insertions(+), 85 deletions(-) rename CMake/{ => finders}/FindGperftools.cmake (100%) rename CMake/{ => finders}/FindSDL2_image.cmake (100%) rename CMake/{ => finders}/Findsodium.cmake (100%) rename CMake/{ => functions}/FetchContent_MakeAvailableExcludeFromAll.cmake (100%) rename CMake/{ => functions}/dependency_options.cmake (100%) rename CMake/{ => functions}/genex.cmake (100%) rename CMake/{ => functions}/git.cmake (100%) delete mode 100644 CMake/out_of_tree.cmake rename CMake/{amiga_defs.cmake => platforms/amiga.cmake} (100%) rename CMake/{android_defs.cmake => platforms/android.cmake} (100%) rename CMake/{cpigamesh_defs.cmake => platforms/cpigamesh.cmake} (100%) rename CMake/{ => platforms}/ctr/Tools3DS.cmake (100%) rename CMake/{ => platforms}/ctr/asio/include/errno.h (100%) rename CMake/{ => platforms}/ctr/asio/include/net/if.h (100%) rename CMake/{ => platforms}/ctr/asio/include/netdb.h (100%) rename CMake/{ => platforms}/ctr/asio/include/netinet/in.h (100%) rename CMake/{ => platforms}/ctr/asio/include/sys/ioctl.h (100%) rename CMake/{ => platforms}/ctr/asio/include/sys/poll.h (100%) rename CMake/{ => platforms}/ctr/asio/include/sys/socket.h (100%) rename CMake/{ => platforms}/ctr/asio/include/sys/uio.h (100%) rename CMake/{ => platforms}/ctr/asio/include/sys/un.h (100%) rename CMake/{ => platforms}/ctr/asio_defs.cmake (100%) rename CMake/{ => platforms}/ctr/bin2s_header.h.in (100%) rename CMake/{ => platforms}/ctr/modules/FindCITRO3D.cmake (100%) rename CMake/{ => platforms}/ctr/modules/FindCTRULIB.cmake (100%) rename CMake/{ => platforms}/ctr/modules/FindPNG.cmake (100%) rename CMake/{ => platforms}/ctr/modules/FindZLIB.cmake (100%) rename CMake/{ => platforms}/ctr/modules/LibFindMacros.cmake (100%) rename CMake/{ => platforms}/ctr/modules/try_add_imported_target.cmake (100%) rename CMake/{gkd350h_defs.cmake => platforms/gkd350h.cmake} (100%) rename CMake/{ios_defs.cmake => platforms/ios.cmake} (100%) rename CMake/{ => platforms}/ios.toolchain.cmake (100%) rename CMake/{lepus_defs.cmake => platforms/lepus.cmake} (100%) rename CMake/{32bit.cmake => platforms/linux_i386.toolchain.cmake} (100%) rename CMake/{mingwcc.cmake => platforms/mingwcc.toolchain.cmake} (100%) rename CMake/{mingwcc64.cmake => platforms/mingwcc64.toolchain.cmake} (100%) rename CMake/{ctr/n3ds_defs.cmake => platforms/n3ds.cmake} (87%) rename CMake/{retrofw_defs.cmake => platforms/retrofw.cmake} (100%) rename CMake/{rg350_defs.cmake => platforms/rg350.cmake} (100%) rename CMake/{switch/switch_defs.cmake => platforms/switch.cmake} (74%) rename CMake/{ => platforms}/switch/asio/include/errno.h (100%) rename CMake/{ => platforms}/switch/asio/include/net/if.h (100%) rename CMake/{ => platforms}/switch/asio/include/netinet/in.h (100%) rename CMake/{ => platforms}/switch/asio/include/sys/uio.h (100%) rename CMake/{ => platforms}/switch/asio/include/sys/un.h (100%) rename CMake/{vita_defs.cmake => platforms/vita.cmake} (100%) delete mode 100644 CMake/switch/asio_defs.cmake diff --git a/.github/workflows/Linux_x86.yml b/.github/workflows/Linux_x86.yml index 774a69755..54e3a1f21 100644 --- a/.github/workflows/Linux_x86.yml +++ b/.github/workflows/Linux_x86.yml @@ -26,13 +26,13 @@ jobs: uses: actions/cache@v2 with: path: build - key: linux-x86-cmake-${{ github.sha }} - restore-keys: linux-x86-cmake- + key: linux-x86-cmake-v2-${{ github.sha }} + restore-keys: linux-x86-cmake-v2- - name: Configure CMake shell: bash working-directory: ${{github.workspace}} - run: cmake -S. -Bbuild -DNIGHTLY_BUILD=ON -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_TOOLCHAIN_FILE=../CMake/32bit.cmake + run: cmake -S. -Bbuild -DNIGHTLY_BUILD=ON -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_TOOLCHAIN_FILE=../CMake/platforms/linux_i386.toolchain.cmake - name: Build working-directory: ${{github.workspace}} diff --git a/.github/workflows/Windows_x64.yml b/.github/workflows/Windows_x64.yml index 8dbd4c0f0..3aa55c8c9 100644 --- a/.github/workflows/Windows_x64.yml +++ b/.github/workflows/Windows_x64.yml @@ -26,13 +26,13 @@ jobs: uses: actions/cache@v2 with: path: build - key: windows-x86_64-cmake-${{ github.sha }} - restore-keys: windows-x86_64-cmake- + key: windows-x86_64-cmake-v2-${{ github.sha }} + restore-keys: windows-x86_64-cmake-v2- - name: Configure CMake shell: bash working-directory: ${{github.workspace}} - run: cmake -S. -Bbuild -DNIGHTLY_BUILD=ON -DCMAKE_TOOLCHAIN_FILE=../CMake/mingwcc64.cmake -DDEVILUTIONX_SYSTEM_BZIP2=OFF + run: cmake -S. -Bbuild -DNIGHTLY_BUILD=ON -DCMAKE_TOOLCHAIN_FILE=../CMake/platforms/mingwcc64.toolchain.cmake -DDEVILUTIONX_SYSTEM_BZIP2=OFF - name: Build working-directory: ${{github.workspace}} diff --git a/.github/workflows/Windows_x86.yml b/.github/workflows/Windows_x86.yml index e33d1f914..2f3e761a7 100644 --- a/.github/workflows/Windows_x86.yml +++ b/.github/workflows/Windows_x86.yml @@ -26,13 +26,13 @@ jobs: uses: actions/cache@v2 with: path: build - key: windows-x86-cmake-${{ github.sha }} - restore-keys: windows-x86-cmake- + key: windows-x86-cmake-v2-${{ github.sha }} + restore-keys: windows-x86-cmake-v2- - name: Configure CMake shell: bash working-directory: ${{github.workspace}} - run: cmake -S. -Bbuild -DNIGHTLY_BUILD=ON -DCMAKE_TOOLCHAIN_FILE=../CMake/mingwcc.cmake -DDEVILUTIONX_SYSTEM_BZIP2=OFF + run: cmake -S. -Bbuild -DNIGHTLY_BUILD=ON -DCMAKE_TOOLCHAIN_FILE=../CMake/platforms/mingwcc.toolchain.cmake -DDEVILUTIONX_SYSTEM_BZIP2=OFF - name: Build working-directory: ${{github.workspace}} diff --git a/.github/workflows/iOS.yml b/.github/workflows/iOS.yml index 31a816f5a..00e4539d9 100644 --- a/.github/workflows/iOS.yml +++ b/.github/workflows/iOS.yml @@ -24,15 +24,15 @@ jobs: uses: actions/cache@v2 with: path: build - key: ios-cmake-${{ github.sha }} - restore-keys: ios-cmake- + key: ios-cmake-v2-${{ github.sha }} + restore-keys: ios-cmake-v2- - name: Configure CMake # Use a bash shell so we can use the same syntax for environment variable # access regardless of the host operating system shell: bash working-directory: ${{github.workspace}} - run: cmake -S. -Bbuild -DCMAKE_TOOLCHAIN_FILE=../CMake/ios.toolchain.cmake -DENABLE_BITCODE=0 -DPLATFORM=OS64 + run: cmake -S. -Bbuild -DCMAKE_TOOLCHAIN_FILE=../CMake/platforms/ios.toolchain.cmake -DENABLE_BITCODE=0 -DPLATFORM=OS64 - name: Build working-directory: ${{github.workspace}} diff --git a/3rdParty/SDL2/CMakeLists.txt b/3rdParty/SDL2/CMakeLists.txt index 965437fac..d3ea5f821 100644 --- a/3rdParty/SDL2/CMakeLists.txt +++ b/3rdParty/SDL2/CMakeLists.txt @@ -11,7 +11,7 @@ else() set(SDL_STATIC OFF) endif() -include(FetchContent_MakeAvailableExcludeFromAll) +include(functions/FetchContent_MakeAvailableExcludeFromAll) include(FetchContent) FetchContent_Declare(SDL2 URL https://github.com/libsdl-org/SDL/archive/5056b29b0f8611b470d8b8bdb313eab628f8bd6e.tar.gz diff --git a/3rdParty/SDL_audiolib/CMakeLists.txt b/3rdParty/SDL_audiolib/CMakeLists.txt index 626e4a6fa..0cafb82fe 100644 --- a/3rdParty/SDL_audiolib/CMakeLists.txt +++ b/3rdParty/SDL_audiolib/CMakeLists.txt @@ -1,4 +1,4 @@ -include(FetchContent_MakeAvailableExcludeFromAll) +include(functions/FetchContent_MakeAvailableExcludeFromAll) if(DEVILUTIONX_STATIC_SDL_AUDIOLIB) set(BUILD_SHARED_LIBS OFF) diff --git a/3rdParty/SDL_image/CMakeLists.txt b/3rdParty/SDL_image/CMakeLists.txt index f5c18ec11..5c67c7c06 100644 --- a/3rdParty/SDL_image/CMakeLists.txt +++ b/3rdParty/SDL_image/CMakeLists.txt @@ -1,4 +1,4 @@ -include(dependency_options) +include(functions/dependency_options) if(NOT DEFINED DEVILUTIONX_SYSTEM_LIBPNG) find_package(PNG QUIET) @@ -26,7 +26,7 @@ else() add_subdirectory(../libpng libpng) endif() -include(FetchContent_MakeAvailableExcludeFromAll) +include(functions/FetchContent_MakeAvailableExcludeFromAll) include(FetchContent) if(USE_SDL1) FetchContent_Declare(SDL_image diff --git a/3rdParty/asio/CMakeLists.txt b/3rdParty/asio/CMakeLists.txt index 0b9e027e4..7bbf81584 100644 --- a/3rdParty/asio/CMakeLists.txt +++ b/3rdParty/asio/CMakeLists.txt @@ -1,4 +1,4 @@ -include(FetchContent_MakeAvailableExcludeFromAll) +include(functions/FetchContent_MakeAvailableExcludeFromAll) include(FetchContent) FetchContent_Declare(asio diff --git a/3rdParty/bzip2/CMakeLists.txt b/3rdParty/bzip2/CMakeLists.txt index b5a331e1e..796856ec3 100644 --- a/3rdParty/bzip2/CMakeLists.txt +++ b/3rdParty/bzip2/CMakeLists.txt @@ -1,4 +1,4 @@ -include(FetchContent_MakeAvailableExcludeFromAll) +include(functions/FetchContent_MakeAvailableExcludeFromAll) include(FetchContent) FetchContent_Declare(bzip2 diff --git a/3rdParty/find_steam_game/CMakeLists.txt b/3rdParty/find_steam_game/CMakeLists.txt index 353f7ab1f..f999534cc 100644 --- a/3rdParty/find_steam_game/CMakeLists.txt +++ b/3rdParty/find_steam_game/CMakeLists.txt @@ -1,11 +1,11 @@ -include(FetchContent_MakeAvailableExcludeFromAll) - -include(FetchContent) -FetchContent_Declare(find_steam_game - URL https://github.com/cxong/find_steam_game/archive/94e9046bcf94a655bdc051b6e6662fabd18e3f30.zip - URL_HASH MD5=c2742aff3d2a2dd162200fdab1b2b4a4 -) -FetchContent_MakeAvailableExcludeFromAll(find_steam_game) - -add_library(find_steam_game INTERFACE) -target_include_directories(find_steam_game INTERFACE ${find_steam_game_SOURCE_DIR}) +include(functions/FetchContent_MakeAvailableExcludeFromAll) + +include(FetchContent) +FetchContent_Declare(find_steam_game + URL https://github.com/cxong/find_steam_game/archive/94e9046bcf94a655bdc051b6e6662fabd18e3f30.zip + URL_HASH MD5=c2742aff3d2a2dd162200fdab1b2b4a4 +) +FetchContent_MakeAvailableExcludeFromAll(find_steam_game) + +add_library(find_steam_game INTERFACE) +target_include_directories(find_steam_game INTERFACE ${find_steam_game_SOURCE_DIR}) diff --git a/3rdParty/libfmt/CMakeLists.txt b/3rdParty/libfmt/CMakeLists.txt index 6116fff24..d5d7fb736 100644 --- a/3rdParty/libfmt/CMakeLists.txt +++ b/3rdParty/libfmt/CMakeLists.txt @@ -1,4 +1,4 @@ -include(FetchContent_MakeAvailableExcludeFromAll) +include(functions/FetchContent_MakeAvailableExcludeFromAll) if(NOT WIN32 AND NOT APPLE AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL FreeBSD) # Enable POSIX extensions such as `readlink` and `ftruncate`. diff --git a/3rdParty/libmpq/CMakeLists.txt b/3rdParty/libmpq/CMakeLists.txt index 13dc6a087..114f133e1 100644 --- a/3rdParty/libmpq/CMakeLists.txt +++ b/3rdParty/libmpq/CMakeLists.txt @@ -4,7 +4,7 @@ if(NOT TARGET BZip2::BZip2) find_package(BZip2 REQUIRED) endif() -include(FetchContent_MakeAvailableExcludeFromAll) +include(functions/FetchContent_MakeAvailableExcludeFromAll) include(FetchContent) FetchContent_Declare(libmpq diff --git a/3rdParty/libpng/CMakeLists.txt b/3rdParty/libpng/CMakeLists.txt index 7a103175b..3ae273cba 100644 --- a/3rdParty/libpng/CMakeLists.txt +++ b/3rdParty/libpng/CMakeLists.txt @@ -1,4 +1,4 @@ -include(FetchContent_MakeAvailableExcludeFromAll) +include(functions/FetchContent_MakeAvailableExcludeFromAll) if(NOT DISABLE_LTO) # Force CMake to raise an error if INTERPROCEDURAL_OPTIMIZATION diff --git a/3rdParty/libsmackerdec/CMakeLists.txt b/3rdParty/libsmackerdec/CMakeLists.txt index 50dd6a087..e91e19dbc 100644 --- a/3rdParty/libsmackerdec/CMakeLists.txt +++ b/3rdParty/libsmackerdec/CMakeLists.txt @@ -1,4 +1,4 @@ -include(FetchContent_MakeAvailableExcludeFromAll) +include(functions/FetchContent_MakeAvailableExcludeFromAll) include(FetchContent) FetchContent_Declare(libsmackerdec diff --git a/3rdParty/libsodium/CMakeLists.txt b/3rdParty/libsodium/CMakeLists.txt index 240f9cbc7..458c4bcde 100644 --- a/3rdParty/libsodium/CMakeLists.txt +++ b/3rdParty/libsodium/CMakeLists.txt @@ -1,5 +1,5 @@ if(NOT DEVILUTIONX_SYSTEM_LIBSODIUM) - include(FetchContent_MakeAvailableExcludeFromAll) + include(functions/FetchContent_MakeAvailableExcludeFromAll) set(SODIUM_MINIMAL ON) set(SODIUM_ENABLE_BLOCKING_RANDOM OFF) diff --git a/3rdParty/libzt/CMakeLists.txt b/3rdParty/libzt/CMakeLists.txt index f235af6b4..33f8d8e3c 100644 --- a/3rdParty/libzt/CMakeLists.txt +++ b/3rdParty/libzt/CMakeLists.txt @@ -1,4 +1,4 @@ -include(FetchContent_MakeAvailableExcludeFromAll) +include(functions/FetchContent_MakeAvailableExcludeFromAll) include(FetchContent) FetchContent_Declare(libzt diff --git a/3rdParty/simpleini/CMakeLists.txt b/3rdParty/simpleini/CMakeLists.txt index a0655d67f..8dd9ee9fd 100644 --- a/3rdParty/simpleini/CMakeLists.txt +++ b/3rdParty/simpleini/CMakeLists.txt @@ -1,4 +1,4 @@ -include(FetchContent_MakeAvailableExcludeFromAll) +include(functions/FetchContent_MakeAvailableExcludeFromAll) include(FetchContent) FetchContent_Declare(simpleini diff --git a/CMake/Dependencies.cmake b/CMake/Dependencies.cmake index 7e740e4a4..29e3a246c 100644 --- a/CMake/Dependencies.cmake +++ b/CMake/Dependencies.cmake @@ -1,6 +1,6 @@ # Options that control whether to use system dependencies or build them from source, # and whether to link them statically. -include(dependency_options) +include(functions/dependency_options) if(USE_SDL1) find_package(SDL REQUIRED) diff --git a/CMake/Platforms.cmake b/CMake/Platforms.cmake index 8045c7beb..b41520268 100644 --- a/CMake/Platforms.cmake +++ b/CMake/Platforms.cmake @@ -1,28 +1,15 @@ -if(NINTENDO_SWITCH) - list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/switch") - include(switch_defs) -endif() - -if(VITA) - include("$ENV{VITASDK}/share/vita.cmake" REQUIRED) - include(vita_defs) +if(WIN32) + set(ASAN OFF) + set(UBSAN OFF) + set(DIST ON) endif() -set(TARGET_PLATFORM host CACHE STRING "Target platform") -set_property(CACHE TARGET_PLATFORM PROPERTY STRINGS host retrofw rg350 gkd350h cpigamesh) -if(TARGET_PLATFORM STREQUAL "lepus") - include(lepus_defs) -elseif(TARGET_PLATFORM STREQUAL "retrofw") - include(retrofw_defs) -elseif(TARGET_PLATFORM STREQUAL "rg350") - include(rg350_defs) -elseif(TARGET_PLATFORM STREQUAL "gkd350h") - include(gkd350h_defs) -elseif(TARGET_PLATFORM STREQUAL "cpigamesh") - include(cpigamesh_defs) +if(HAIKU) + set(ASAN OFF) + set(UBSAN OFF) endif() -if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD|NetBSD|OpenBSD|DragonFly") +if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD|OpenBSD|DragonFly|NetBSD") if(${CMAKE_SYSTEM_NAME} MATCHES "NetBSD") add_definitions(-D_NETBSD_SOURCE) else() @@ -33,30 +20,41 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD|NetBSD|OpenBSD|DragonFly") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DO_LARGEFILE=0 -Dstat64=stat -Dlstat64=lstat -Dlseek64=lseek -Doff64_t=off_t -Dfstat64=fstat -Dftruncate64=ftruncate") endif() -if(WIN32) - set(ASAN OFF) - set(UBSAN OFF) - set(DIST ON) +set(TARGET_PLATFORM host CACHE STRING "Target platform") +set_property(CACHE TARGET_PLATFORM PROPERTY STRINGS host retrofw rg350 gkd350h cpigamesh) +if(TARGET_PLATFORM STREQUAL "retrofw") + include(platforms/retrofw) +elseif(TARGET_PLATFORM STREQUAL "rg350") + include(platforms/rg350) +elseif(TARGET_PLATFORM STREQUAL "gkd350h") + include(platforms/gkd350h) +elseif(TARGET_PLATFORM STREQUAL "cpigamesh") + include(platforms/cpigamesh) +elseif(TARGET_PLATFORM STREQUAL "lepus") + include(platforms/lepus) endif() -if(HAIKU) - set(ASAN OFF) - set(UBSAN OFF) +if(NINTENDO_SWITCH) + include(platforms/switch) endif() if(AMIGA) - include(amiga_defs) + include(platforms/amiga) endif() if(NINTENDO_3DS) - list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake/ctr") - include(n3ds_defs) + include(platforms/n3ds) +endif() + +if(VITA) + include("$ENV{VITASDK}/share/vita.cmake" REQUIRED) + include(platforms/vita) endif() if(ANDROID) - include(android_defs) + include(platforms/android) endif() if(IOS) - include(ios_defs) + include(platforms/ios) endif() diff --git a/CMake/FindGperftools.cmake b/CMake/finders/FindGperftools.cmake similarity index 100% rename from CMake/FindGperftools.cmake rename to CMake/finders/FindGperftools.cmake diff --git a/CMake/FindSDL2_image.cmake b/CMake/finders/FindSDL2_image.cmake similarity index 100% rename from CMake/FindSDL2_image.cmake rename to CMake/finders/FindSDL2_image.cmake diff --git a/CMake/Findsodium.cmake b/CMake/finders/Findsodium.cmake similarity index 100% rename from CMake/Findsodium.cmake rename to CMake/finders/Findsodium.cmake diff --git a/CMake/FetchContent_MakeAvailableExcludeFromAll.cmake b/CMake/functions/FetchContent_MakeAvailableExcludeFromAll.cmake similarity index 100% rename from CMake/FetchContent_MakeAvailableExcludeFromAll.cmake rename to CMake/functions/FetchContent_MakeAvailableExcludeFromAll.cmake diff --git a/CMake/dependency_options.cmake b/CMake/functions/dependency_options.cmake similarity index 100% rename from CMake/dependency_options.cmake rename to CMake/functions/dependency_options.cmake diff --git a/CMake/genex.cmake b/CMake/functions/genex.cmake similarity index 100% rename from CMake/genex.cmake rename to CMake/functions/genex.cmake diff --git a/CMake/git.cmake b/CMake/functions/git.cmake similarity index 100% rename from CMake/git.cmake rename to CMake/functions/git.cmake diff --git a/CMake/out_of_tree.cmake b/CMake/out_of_tree.cmake deleted file mode 100644 index 88b5b25a0..000000000 --- a/CMake/out_of_tree.cmake +++ /dev/null @@ -1,3 +0,0 @@ -if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) - message(WARNING [[In-source build detected, please eg. create a new directory and use `cmake ..`]]) -endif() diff --git a/CMake/amiga_defs.cmake b/CMake/platforms/amiga.cmake similarity index 100% rename from CMake/amiga_defs.cmake rename to CMake/platforms/amiga.cmake diff --git a/CMake/android_defs.cmake b/CMake/platforms/android.cmake similarity index 100% rename from CMake/android_defs.cmake rename to CMake/platforms/android.cmake diff --git a/CMake/cpigamesh_defs.cmake b/CMake/platforms/cpigamesh.cmake similarity index 100% rename from CMake/cpigamesh_defs.cmake rename to CMake/platforms/cpigamesh.cmake diff --git a/CMake/ctr/Tools3DS.cmake b/CMake/platforms/ctr/Tools3DS.cmake similarity index 100% rename from CMake/ctr/Tools3DS.cmake rename to CMake/platforms/ctr/Tools3DS.cmake diff --git a/CMake/ctr/asio/include/errno.h b/CMake/platforms/ctr/asio/include/errno.h similarity index 100% rename from CMake/ctr/asio/include/errno.h rename to CMake/platforms/ctr/asio/include/errno.h diff --git a/CMake/ctr/asio/include/net/if.h b/CMake/platforms/ctr/asio/include/net/if.h similarity index 100% rename from CMake/ctr/asio/include/net/if.h rename to CMake/platforms/ctr/asio/include/net/if.h diff --git a/CMake/ctr/asio/include/netdb.h b/CMake/platforms/ctr/asio/include/netdb.h similarity index 100% rename from CMake/ctr/asio/include/netdb.h rename to CMake/platforms/ctr/asio/include/netdb.h diff --git a/CMake/ctr/asio/include/netinet/in.h b/CMake/platforms/ctr/asio/include/netinet/in.h similarity index 100% rename from CMake/ctr/asio/include/netinet/in.h rename to CMake/platforms/ctr/asio/include/netinet/in.h diff --git a/CMake/ctr/asio/include/sys/ioctl.h b/CMake/platforms/ctr/asio/include/sys/ioctl.h similarity index 100% rename from CMake/ctr/asio/include/sys/ioctl.h rename to CMake/platforms/ctr/asio/include/sys/ioctl.h diff --git a/CMake/ctr/asio/include/sys/poll.h b/CMake/platforms/ctr/asio/include/sys/poll.h similarity index 100% rename from CMake/ctr/asio/include/sys/poll.h rename to CMake/platforms/ctr/asio/include/sys/poll.h diff --git a/CMake/ctr/asio/include/sys/socket.h b/CMake/platforms/ctr/asio/include/sys/socket.h similarity index 100% rename from CMake/ctr/asio/include/sys/socket.h rename to CMake/platforms/ctr/asio/include/sys/socket.h diff --git a/CMake/ctr/asio/include/sys/uio.h b/CMake/platforms/ctr/asio/include/sys/uio.h similarity index 100% rename from CMake/ctr/asio/include/sys/uio.h rename to CMake/platforms/ctr/asio/include/sys/uio.h diff --git a/CMake/ctr/asio/include/sys/un.h b/CMake/platforms/ctr/asio/include/sys/un.h similarity index 100% rename from CMake/ctr/asio/include/sys/un.h rename to CMake/platforms/ctr/asio/include/sys/un.h diff --git a/CMake/ctr/asio_defs.cmake b/CMake/platforms/ctr/asio_defs.cmake similarity index 100% rename from CMake/ctr/asio_defs.cmake rename to CMake/platforms/ctr/asio_defs.cmake diff --git a/CMake/ctr/bin2s_header.h.in b/CMake/platforms/ctr/bin2s_header.h.in similarity index 100% rename from CMake/ctr/bin2s_header.h.in rename to CMake/platforms/ctr/bin2s_header.h.in diff --git a/CMake/ctr/modules/FindCITRO3D.cmake b/CMake/platforms/ctr/modules/FindCITRO3D.cmake similarity index 100% rename from CMake/ctr/modules/FindCITRO3D.cmake rename to CMake/platforms/ctr/modules/FindCITRO3D.cmake diff --git a/CMake/ctr/modules/FindCTRULIB.cmake b/CMake/platforms/ctr/modules/FindCTRULIB.cmake similarity index 100% rename from CMake/ctr/modules/FindCTRULIB.cmake rename to CMake/platforms/ctr/modules/FindCTRULIB.cmake diff --git a/CMake/ctr/modules/FindPNG.cmake b/CMake/platforms/ctr/modules/FindPNG.cmake similarity index 100% rename from CMake/ctr/modules/FindPNG.cmake rename to CMake/platforms/ctr/modules/FindPNG.cmake diff --git a/CMake/ctr/modules/FindZLIB.cmake b/CMake/platforms/ctr/modules/FindZLIB.cmake similarity index 100% rename from CMake/ctr/modules/FindZLIB.cmake rename to CMake/platforms/ctr/modules/FindZLIB.cmake diff --git a/CMake/ctr/modules/LibFindMacros.cmake b/CMake/platforms/ctr/modules/LibFindMacros.cmake similarity index 100% rename from CMake/ctr/modules/LibFindMacros.cmake rename to CMake/platforms/ctr/modules/LibFindMacros.cmake diff --git a/CMake/ctr/modules/try_add_imported_target.cmake b/CMake/platforms/ctr/modules/try_add_imported_target.cmake similarity index 100% rename from CMake/ctr/modules/try_add_imported_target.cmake rename to CMake/platforms/ctr/modules/try_add_imported_target.cmake diff --git a/CMake/gkd350h_defs.cmake b/CMake/platforms/gkd350h.cmake similarity index 100% rename from CMake/gkd350h_defs.cmake rename to CMake/platforms/gkd350h.cmake diff --git a/CMake/ios_defs.cmake b/CMake/platforms/ios.cmake similarity index 100% rename from CMake/ios_defs.cmake rename to CMake/platforms/ios.cmake diff --git a/CMake/ios.toolchain.cmake b/CMake/platforms/ios.toolchain.cmake similarity index 100% rename from CMake/ios.toolchain.cmake rename to CMake/platforms/ios.toolchain.cmake diff --git a/CMake/lepus_defs.cmake b/CMake/platforms/lepus.cmake similarity index 100% rename from CMake/lepus_defs.cmake rename to CMake/platforms/lepus.cmake diff --git a/CMake/32bit.cmake b/CMake/platforms/linux_i386.toolchain.cmake similarity index 100% rename from CMake/32bit.cmake rename to CMake/platforms/linux_i386.toolchain.cmake diff --git a/CMake/mingwcc.cmake b/CMake/platforms/mingwcc.toolchain.cmake similarity index 100% rename from CMake/mingwcc.cmake rename to CMake/platforms/mingwcc.toolchain.cmake diff --git a/CMake/mingwcc64.cmake b/CMake/platforms/mingwcc64.toolchain.cmake similarity index 100% rename from CMake/mingwcc64.cmake rename to CMake/platforms/mingwcc64.toolchain.cmake diff --git a/CMake/ctr/n3ds_defs.cmake b/CMake/platforms/n3ds.cmake similarity index 87% rename from CMake/ctr/n3ds_defs.cmake rename to CMake/platforms/n3ds.cmake index 4cea9f5c6..e4b7ada86 100644 --- a/CMake/ctr/n3ds_defs.cmake +++ b/CMake/platforms/n3ds.cmake @@ -11,7 +11,8 @@ set(USE_SDL1 ON) set(PREFILL_PLAYER_NAME ON) #3DS libraries -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake/ctr/modules") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/ctr") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/ctr/modules") find_package(CITRO3D REQUIRED) #additional compilation definitions diff --git a/CMake/retrofw_defs.cmake b/CMake/platforms/retrofw.cmake similarity index 100% rename from CMake/retrofw_defs.cmake rename to CMake/platforms/retrofw.cmake diff --git a/CMake/rg350_defs.cmake b/CMake/platforms/rg350.cmake similarity index 100% rename from CMake/rg350_defs.cmake rename to CMake/platforms/rg350.cmake diff --git a/CMake/switch/switch_defs.cmake b/CMake/platforms/switch.cmake similarity index 74% rename from CMake/switch/switch_defs.cmake rename to CMake/platforms/switch.cmake index 67aeabb34..e151e9059 100644 --- a/CMake/switch/switch_defs.cmake +++ b/CMake/platforms/switch.cmake @@ -1,3 +1,5 @@ +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/switch") + set(ASAN OFF) set(UBSAN OFF) diff --git a/CMake/switch/asio/include/errno.h b/CMake/platforms/switch/asio/include/errno.h similarity index 100% rename from CMake/switch/asio/include/errno.h rename to CMake/platforms/switch/asio/include/errno.h diff --git a/CMake/switch/asio/include/net/if.h b/CMake/platforms/switch/asio/include/net/if.h similarity index 100% rename from CMake/switch/asio/include/net/if.h rename to CMake/platforms/switch/asio/include/net/if.h diff --git a/CMake/switch/asio/include/netinet/in.h b/CMake/platforms/switch/asio/include/netinet/in.h similarity index 100% rename from CMake/switch/asio/include/netinet/in.h rename to CMake/platforms/switch/asio/include/netinet/in.h diff --git a/CMake/switch/asio/include/sys/uio.h b/CMake/platforms/switch/asio/include/sys/uio.h similarity index 100% rename from CMake/switch/asio/include/sys/uio.h rename to CMake/platforms/switch/asio/include/sys/uio.h diff --git a/CMake/switch/asio/include/sys/un.h b/CMake/platforms/switch/asio/include/sys/un.h similarity index 100% rename from CMake/switch/asio/include/sys/un.h rename to CMake/platforms/switch/asio/include/sys/un.h diff --git a/CMake/vita_defs.cmake b/CMake/platforms/vita.cmake similarity index 100% rename from CMake/vita_defs.cmake rename to CMake/platforms/vita.cmake diff --git a/CMake/switch/asio_defs.cmake b/CMake/switch/asio_defs.cmake deleted file mode 100644 index a96bc496a..000000000 --- a/CMake/switch/asio_defs.cmake +++ /dev/null @@ -1,5 +0,0 @@ -# Enables a number of header file definitions required by ASIO -target_compile_definitions(asio INTERFACE _DEFAULT_SOURCE=ON) - -# Missing headers and declarations provided by DevilutionX -target_include_directories(asio BEFORE INTERFACE ${CMAKE_CURRENT_LIST_DIR}/asio/include) diff --git a/CMakeLists.txt b/CMakeLists.txt index dbb0733a7..225d9ead2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,11 +22,15 @@ if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/dist") add_subdirectory(dist) endif() +if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) + message(WARNING [[In-source build detected, please eg. create a new directory and use `cmake ..`]]) +endif() + include(CMakeDependentOption) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake") -include(out_of_tree) -include(genex) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake/finders") +include(functions/genex) DEBUG_OPTION(ASAN "Enable address sanitizer") DEBUG_OPTION(UBSAN "Enable undefined behaviour sanitizer") @@ -92,7 +96,7 @@ include(VcPkgManifestFeatures) # Set up the `project` early so that properties such as `TARGET_SUPPORTS_SHARED_LIBS` are defined. if(NOT VERSION_NUM) - include(CMake/git.cmake) + include(functions/git) get_git_tag(VERSION_NUM) if (NOT "${VERSION_NUM}" STREQUAL "") string(REGEX MATCH "([0-9]+\\.[0-9]+\\.[0-9]+)" VERSION_NUM ${VERSION_NUM} ) diff --git a/docs/building.md b/docs/building.md index 4028ff7d9..cab2bff68 100644 --- a/docs/building.md +++ b/docs/building.md @@ -132,14 +132,14 @@ sudo apt-get install cmake gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 pkg-config- ### 32-bit ```bash -cmake -S. -Bbuild -DCMAKE_TOOLCHAIN_FILE=../CMake/mingwcc.cmake -DCMAKE_BUILD_TYPE=Release +cmake -S. -Bbuild -DCMAKE_TOOLCHAIN_FILE=../CMake/platforms/mingwcc.toolchain.cmake -DCMAKE_BUILD_TYPE=Release cmake --build build -j $(getconf _NPROCESSORS_ONLN) ``` ### 64-bit ```bash -cmake -S. -Bbuild -DCMAKE_TOOLCHAIN_FILE=../CMake/mingwcc64.cmake -DCMAKE_BUILD_TYPE=Release +cmake -S. -Bbuild -DCMAKE_TOOLCHAIN_FILE=../CMake/mingwcc64.toolchain.cmake -DCMAKE_BUILD_TYPE=Release cmake --build build -j $(getconf _NPROCESSORS_ONLN) ``` @@ -369,7 +369,7 @@ select Icons -> Information in the top menu. - `-DCMAKE_BUILD_TYPE=Release` changed build type to release and optimize for distribution. - `-DNONET=ON` disable network support, this also removes the need for the ASIO and Sodium. - `-DUSE_SDL1=ON` build for SDL v1 instead of v2, not all features are supported under SDL v1, notably upscaling. -- `-DCMAKE_TOOLCHAIN_FILE=../CMake/32bit.cmake` generate 32bit builds on 64bit platforms (remember to use the `linux32` command if on Linux). +- `-DCMAKE_TOOLCHAIN_FILE=../CMake/platforms/linux_i386.toolchain..cmake` generate 32bit builds on 64bit platforms (remember to use the `linux32` command if on Linux). ### Debug builds - `-DDEBUG=OFF` disable debug mode of the Diablo engine.