Giter Site home page Giter Site logo

scapix-com / cmodule Goto Github PK

View Code? Open in Web Editor NEW
21.0 3.0 7.0 92 KB

Non-intrusive CMake dependency management

Home Page: https://www.scapix.com

License: MIT License

CMake 100.00%
cmake package package-manager package-management cpp cplusplus boost

cmodule's Introduction

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.0.tar.gz"
  URL_HASH SHA256=58695a9d73dc95a2c214097729917c7d9c366bf511e162d566cf55dd2b9cd7be
)
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:

  • libraries seamlessly build for any target, including cross-compiling targets (iOS, Android, etc.)
  • libraries build using the same settings (compiler options) as the rest of the project
  • non intrusive syntax: automatically works for projects with regular find_package() calls
  • downloaded and extracted sources are cached by cmodule to speedup builds for different targets and builds of different projects

More info

Documentation
Example

cmodule's People

Contributors

boris-rasin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cmodule's Issues

Unknown arguments specified

CMakeLists.txt

cmake_minimum_required(VERSION 3.24)
project(mytarget LANGUAGES NONE)

include(FetchContent)
FetchContent_Declare(
  cmodule
  URL "https://github.com/scapix-com/cmodule/archive/refs/tags/v1.0.37.tar.gz"
  URL_HASH SHA256=c2a4df7f824e4460c23be8d1bd3d6aaa3f7b86f8bceae2eb7b78fa47d765c57f
)
FetchContent_MakeAvailable(cmodule)
find_package(CURL REQUIRED)
target_link_libraries(mytarget PRIVATE CURL::libcurl)

mkdir build && cd build/ && cmake ..

CMake Error at build/_deps/cmodule-src/cmake/cmodule.cmake:27 (if):
  if given arguments:

    "STREQUAL" "MSVC"

  Unknown arguments specified
Call Stack (most recent call first):
  build/_deps/cmodule-src/cmake/cmodule.cmake:84 (cmodule_set_local_options)
  build/_deps/cmodule-src/cmake/FindCURL.cmake:6 (cmodule_add)
  CMakeLists.txt:12 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/bincat/coding/cmake/third_libs_fetch/cmodule/build/CMakeFiles/CMakeOutput.log".

cat /home/bincat/coding/cmake/third_libs_fetch/cmodule/build/CMakeFiles/CMakeOutput.log
The system is: Linux - 5.17.7-gentoo - x86_64

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.