>>108115218
>>108115270
Just use FetchContent to get dependencies.
>inb4 but the specific library I want to use doesn't work when I import it with fetchContent cuz they don't use CMake!
That's purely a skill issue on the library author's part, tell them to do better.
cmake_minimum_required(VERSION 3.31)
project(ExampleProject
VERSION 0.1.0
LANGUAGES CXX
)
# ---
# Import 3rd-party libs
# ---
include(FetchContent)
# define where to pull the dependencies from
FetchContent_Declare(
fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt
GIT_TAG 12.1.0
GIT_SHALLOW TRUE
)
FetchContent_Declare(
spdlog
GIT_REPOSITORY https://github.com/gabime/spdlog
GIT_TAG v1.17.0
GIT_SHALLOW TRUE
)
# actually fetch the dependencies from locations defined above
FetchContent_MakeAvailable(fmt spdlog)
# ---
# Foo.exe
# ---
add_executable(Foo)
target_sources(Foo
PRIVATE
src/main.cpp
)
target_compile_features(Foo
PRIVATE
cxx_std_20 # C++20
)
target_link_libraries(Foo
PRIVATE
fmt::fmt
spdlog::spdlog
)
# ---
# Install rules
# ---
include(GNUInstallDirs)
install(TARGETS Foo
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)