GitHub - scapix-com/cmodule: Non-intrusive CMake dependency management (original) (raw)

cmodule

πŸ‡ΊπŸ‡¦ If you like this project, please consider donating to one of the funds helping victims of russian aggression against Ukraine: ukraine.ua

Non-intrusive CMake dependency management.

Normally CMake's find_package() looks for packages installed on host system (and compiled for host system). When using cmodule, find_package() downloads packages and compiles them using current CMake toolchain. This allows using C/C++ libraries (like boost) whether you are building for host system or cross-compiling for Android, iOS, WebAssembly, etc.

CMake integration

After initializing cmodule, regular find_package() calls will work in top level CMake project and all subprojects:

include(FetchContent) FetchContent_Declare( cmodule URL "https://github.com/scapix-com/cmodule/archive/refs/tags/v2.0.1.tar.gz" URL_HASH SHA256=a9477bbefb43b6fabdc2dc044207fe42cca63999c60b6baf06ba0c62fa116ec5 ) FetchContent_MakeAvailable(cmodule)

find_package(Boost REQUIRED COMPONENTS filesystem) target_link_libraries(mytarget PUBLIC Boost::filesystem)

find_package(Boost REQUIRED COMPONENTS iostreams) target_link_libraries(mytarget PUBLIC Boost::iostreams)

find_package(ZLIB REQUIRED) target_link_libraries(mytarget PRIVATE ZLIB::ZLIB)

find_package(BZip2 REQUIRED) target_link_libraries(mytarget PRIVATE BZip2::BZip2)

find_package(CURL REQUIRED) target_link_libraries(mytarget PRIVATE CURL::libcurl)

How cmodule differs from other package managers?

Instead of providing compiled binaries, cmodule builds libraries as part of your project build.

This has multiple advantages:

More info

Documentation
Example