RandyGaul / cute_framework

The *cutest* framework out there for creating 2D games in C++!
https://randygaul.github.io/cute_framework/#/
Other
522 stars 30 forks source link

build(cmake): FetchContent_Populate deprecation #170

Closed alexlnkp closed 2 weeks ago

alexlnkp commented 1 month ago

As of cmake 3.30.1, the main CMakeLists.txt causes a deprecation warning for every call of FetchContent_Populate. CMake advises to use FetchContent_MakeAvailable instead, however it would appear that this ultimately breaks the build.

There's a quick patch available for this however

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b7c92f8c..fdf2c159 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,6 +4,8 @@ project(cute_framework)
 # Must have at least C++17.
 set(CMAKE_CXX_STANDARD 20)

+cmake_policy(SET CMP0169 OLD)
+
 # These are needed for how we use FetchContent.
 include(FetchContent)
 Set(FETCHCONTENT_QUIET FALSE)
@@ -115,7 +117,7 @@ set(CF_SRCS
    src/internal/yyjson.c

    libraries/cimgui/imgui/backends/imgui_impl_sdl.cpp
-   
+
    libraries/cimgui/imgui/imgui.cpp
    libraries/cimgui/imgui/imgui_demo.cpp
    libraries/cimgui/imgui/imgui_draw.cpp

Don't mind the second hunk, my editor decided to remove a single whitespace.

This is not an ideal solution, but this will suppress this warning for now.

RandyGaul commented 1 month ago

Any insights on how MakeAvailable breaks the build? I'm not super partial to the current CMake file and am open to discussion and suggestions here! :)

alexlnkp commented 1 month ago

Any insights on how MakeAvailable breaks the build? I'm not super partial to the current CMake file and am open to discussion and suggestions here! :)

Well, it does this with FetchContent_MakeAvailable():

$ cmake -B build -DCMAKE_BUILD_TYPE=Release
-- Populating s2n
-- Configuring done (0.0s)
-- Generating done (0.0s)
-- Build files have been written to: /home/alex/Desktop/cute_framework/build/_deps/s2n-subbuild
[ 11%] Performing update step for 's2n-populate'
-- Already at requested tag: v1.3.46
[ 22%] No patch step for 's2n-populate'
[ 33%] No configure step for 's2n-populate'
[ 44%] No build step for 's2n-populate'
[ 55%] No install step for 's2n-populate'
[ 66%] No test step for 's2n-populate'
[ 77%] Completed 's2n-populate'
[100%] Built target s2n-populate
CMake Deprecation Warning at build/_deps/s2n-src/CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- Detected CMAKE_SYSTEM_PROCESSOR as x86_64
-- Detected 64-Bit system
-- LibCrypto Include Dir: /usr/include
-- LibCrypto Shared Lib:  /usr/lib/libcrypto.so
-- LibCrypto Static Lib:  crypto_STATIC_LIBRARY-NOTFOUND
-- Using libcrypto from the cmake path
-- CMAKE_AR found: /usr/bin/ar
-- CMAKE_RANLIB found: /usr/bin/ranlib
-- CMAKE_OBJCOPY found: /usr/bin/objcopy
-- feature S2N_ATOMIC_SUPPORTED: TRUE
-- feature S2N_CLONE_SUPPORTED: TRUE
-- feature S2N_CPUID_AVAILABLE: TRUE
-- feature S2N_DIAGNOSTICS_POP_SUPPORTED: TRUE
-- feature S2N_DIAGNOSTICS_PUSH_SUPPORTED: TRUE
-- feature S2N_EXECINFO_AVAILABLE: TRUE
-- feature S2N_FALL_THROUGH_SUPPORTED: TRUE
-- feature S2N_FEATURES_AVAILABLE: TRUE
-- feature S2N_KYBER512R3_AVX2_BMI2_SUPPORTED: TRUE
-- feature S2N_KYBER512R3_M256_INTRINSICS_SUPPORTED: TRUE
-- feature S2N_LIBCRYPTO_SUPPORTS_EVP_MD5_SHA1_HASH: TRUE
-- feature S2N_LIBCRYPTO_SUPPORTS_EVP_MD_CTX_SET_PKEY_CTX: TRUE
-- feature S2N_LIBCRYPTO_SUPPORTS_EVP_RC4: TRUE
-- feature S2N_LIBCRYPTO_SUPPORTS_HKDF: FALSE
-- feature S2N_LIBCRYPTO_SUPPORTS_KYBER512: FALSE
-- feature S2N_MADVISE_SUPPORTED: TRUE
-- feature S2N_MINHERIT_SUPPORTED: FALSE
-- feature S2N___RESTRICT__SUPPORTED: TRUE
-- feature S2N_STACKTRACE: TRUE
-- feature S2N_KYBER512R3_AVX2_BMI2: TRUE
-- Running tests with environment: S2N_DONT_MLOCK=1
CMake Error at CMakeLists.txt:26 (add_subdirectory):
  The binary directory

    /home/alex/Desktop/cute_framework/build/_deps/s2n-build

  is already used to build a source directory.  It cannot be used to build
  source directory

    /home/alex/Desktop/cute_framework/build/_deps/s2n-src

  Specify a unique binary directory name.
Call Stack (most recent call first):
  CMakeLists.txt:295 (fetch_content_with_folder)

# . . .

I'm not sure myself why that is the case honestly It's probably the dependency which is at fault here, SDL2 for example is quite old and it depended on some old CMake stuff, hence it could be why it too errors out in the same way

RandyGaul commented 2 weeks ago

I think this has since been fixed.