Comments (8)
Libtcod should already support being fetched. The CMake scripts themselves are agnostic, with libtcod searching for packages with find_package
and will pick packages gotten with FetchContent, as far as I know.
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.
from libtcod.
As of CMake version 24, you can add FIND_PACKAGE_ARGS
as an argument to FetchContent_Declare
and it will first attempt to use find_package
. In this case, it only fetches the content if no package was found.
from libtcod.
I found OVERRIDE_FIND_PACKAGE
which seems to make them work seamlessly with find_package
.
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.
from libtcod.
I got stb working with FetchContent here:
https://github.com/Journeyman-dev/roguelike.h/blob/0e1994082e8f6f06486a9bb404e1a47314e97eb9/example/CMakeLists.txt#L32
from libtcod.
Using stb_SOURCE_DIR
makes sense in hindsight. With this it should be possible to build the library for LodePNG too, but I want these to export an alias matching the ones provided by Vcpkg and make them into a portable script which can be copied across projects with similar requirements.
So for a simple example. Could something like this could be made into FindStb.cmake
:
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 FindLodePNG-c.cmake
:
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.
from libtcod.
Maybe you could use check_variable_exists
to see if Stb_INCLUDE_DIR
was defined when you called FetchContent_Declare
. If not, set the variable manually.
from libtcod.
Current attempts are generating errors such as the following:
-- Configuring done
CMake Error: install(EXPORT "libtcodTargets" ...) includes target "libtcod" which requires target "SDL2-static" that is not in any export set.
CMake Error: install(EXPORT "libtcodTargets" ...) includes target "libtcod" which requires target "utf8proc" that is not in any export set.
-- Generating done
CMake Generate step failed. Build files cannot be regenerated correctly.
See https://github.com/libtcod/libtcod/actions/runs/3780000589/jobs/6425717835
from libtcod.
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
in issue #153:
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.
from libtcod.
Related Issues (20)
- Error when configuring project with CMake -> Fatal: path 'versions/baseline.json' exists on disk, but not in <commit> HOT 3
- Missing stdc++fs library for older g++'es HOT 3
- Bitmap font question HOT 1
- Libtcod parser regression: expects identifiers then crashes when given a type.
- Generic ndarray types.
- Update Sphinx docs to cover the API. HOT 3
- Add the roguelike.h renderer HOT 3
- Printing API needs a rework. HOT 10
- Problem with a 64 by 64 pixel font HOT 4
- `TCODImage` is not default constructable.
- How to use libtcod from vcpkg in 64bit MSVC project? HOT 2
- Create a libtcod Discord community channel HOT 4
- Libtcod blanks the first glyph of tilesets without warning.
- How to access screen from ITCODSDLRenderer::render HOT 2
- Vcpkg should be updated HOT 5
- Confusing names of [l|m|r]button_pressed TCOD_mouse_t properties HOT 2
- Split libtcod into multiple libraries.
- #include Header is incorrect in docs/guides/getting-started.md for the example main.cpp file. HOT 2
- Allow disabling CMake install targets HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libtcod.