-
-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use CMake FetchContent instead of vcpkg #141
Comments
Libtcod should already support being fetched. The CMake scripts themselves are agnostic, with libtcod searching for packages with I don't have enough experience with FetchContent to make an example or template. I'd be interested in libtcod using FetchContent for its own dependencies when it itself is downloaded with FetchContent, but I'm not confident that those dependencies fully support CMake. |
As of CMake version 24, you can add |
I found Trying to figure out examples for libtcod's dependencies: FetchContent_Declare(
SDL2
GIT_REPOSITORY https://github.com/libsdl-org/SDL
GIT_TAG release-2.26.1
OVERRIDE_FIND_PACKAGE
)
FetchContent_Declare(
UTF8PROC
GIT_REPOSITORY https://github.com/JuliaStrings/utf8proc
GIT_TAG v2.8.0
OVERRIDE_FIND_PACKAGE
)
FetchContent_Declare(
ZLIB
GIT_REPOSITORY https://github.com/madler/zlib
GIT_TAG v1.2.13
OVERRIDE_FIND_PACKAGE
) LodePNG is missing a CMakeLists. STB is also not a CMake project. |
I got stb working with FetchContent here: |
Using So for a simple example. Could something like this could be made into FetchContent_Declare(
stb
GIT_REPOSITORY https://github.com/nothings/stb
)
FetchContent_MakeAvailable(stb)
set(Stb_INCLUDE_DIR "${stb_SOURCE_DIR}" CACHE PATH "Stb header directory.") Which would seamlessly integrate with libtcod's current use of the same library from Vcpkg: find_package(Stb REQUIRED)
target_include_directories(${PROJECT_NAME} PRIVATE ${Stb_INCLUDE_DIR}) Then something like this for FetchContent_Declare(
LodePNG
...
)
FetchContent_MakeAvailable(LodePNG)
... # copy lodepng.cpp, lodepng_util.cpp to *.c
add_library(lodepng-c lodepng.c lodepng_util.c)
target_include_directories(lodepng-c LodePNG_SOURCE_DIR) I barely have any idea what I'm talking about. I'll have to re-read the CMake docs on these topics. |
Maybe you could use |
Current attempts are generating errors such as the following:
See https://github.com/libtcod/libtcod/actions/runs/3780000589/jobs/6425717835 |
All of my previous examples can be ignored. harryisgamer pointed out how to solve the install issue and then posted multiple working examples of setting up a libtcod project using FetchContent libtcod, simple/minimal version FetchContent libtcod, with un-vendored dependencies What's next would be to write official instructions on how to setup a project using these. |
FetchContent is a CMake feature that allows you to fetch dependencies directly from online repositories. I have begun integrating it in all of my projects.
For example:
https://github.com/Journeyman-dev/png_wrapper.h
This would make libtcod a lot easier for people to get up and running. Also, this could simplify how you manage your GitHub actions workflows.
The text was updated successfully, but these errors were encountered: