Skip to content

Please add a CMake flag to disable install #721

@alex-tee

Description

@alex-tee

I am using CMake with CPM to fetch my dependencies, and this is my current configuration (simplified):

CPMDeclarePackage(fmt
  NAME fmt
  VERSION 11.2.0
  GIT_TAG 40626af88bd7df9a5fb80be7b25ac85b122d6c21
  GITHUB_REPOSITORY fmtlib/fmt
  SYSTEM YES
  EXCLUDE_FROM_ALL YES
  OPTIONS
    "FMT_INSTALL OFF"
)
CPMDeclarePackage(mp-units
  NAME mp-units
  VERSION 2.4.1
  GIT_TAG 8489cc2299a58cdf603f2521f982359959d907ea
  GITHUB_REPOSITORY mpusz/mp-units
  SOURCE_SUBDIR src
  SYSTEM YES
  EXCLUDE_FROM_ALL YES
  OPTIONS
    "MP_UNITS_BUILD_AS_SYSTEM_HEADERS ON"
    "MP_UNITS_API_STD_FORMAT ON"
    "MP_UNITS_API_NO_CRTP ON"
    "MP_UNITS_API_FREESTANDING OFF"
    "MP_UNITS_API_CONTRACTS NONE"
    "MP_UNITS_BUILD_CXX_MODULES OFF"
    "MP_UNITS_API_NATURAL_UNITS OFF"
)

This works, however as you can see in my project I use libfmt instead of standard formatting, and I want to allow mpunits to use fmt too. However, when setting MP_UNITS_API_STD_FORMAT to OFF, I get a configuration error:

[cmake] CMake Error in .cache/CPM/mp-units/b278/src/CMakeLists.txt:
[cmake]   install(EXPORT "mp-unitsTargets" ...) includes target "mp-units-core" which
[cmake]   requires target "fmt" that is not in any export set.

Normally, CMake-based libraries provide an option to skip the CMake install() commands (for example fmt itself as you can see above). providing such an option and executing those install() commands conditionally would fix this issue (and would also avoid polluting the install artifacts with useless headers). Please provide such an option. I would name it MP_UNITS_INSTALL.

For reference, here are some other widely used libraries I use that provide similar options:

CPMDeclarePackage(spdlog
  NAME spdlog
  VERSION 1.15.3
  GIT_TAG 6fa36017cfd5731d617e1a934f0e5ea9c4445b13
  GITHUB_REPOSITORY gabime/spdlog
  SYSTEM YES
  EXCLUDE_FROM_ALL YES
  OPTIONS
    "SPDLOG_INSTALL OFF"
)
CPMDeclarePackage(GTest
  NAME GTest
  VERSION 1.16.0
  GIT_TAG 6910c9d9165801d8827d628cb72eb7ea9dd538c5
  GITHUB_REPOSITORY google/googletest
  SYSTEM YES
  EXCLUDE_FROM_ALL YES
  OPTIONS
    "INSTALL_GTEST OFF"
)
CPMDeclarePackage(benchmark
  NAME benchmark
  VERSION 1.9.2
  GIT_TAG afa23b7699c17f1e26c88cbf95257b20d78d6247
  GITHUB_REPOSITORY google/benchmark
  SYSTEM YES
  EXCLUDE_FROM_ALL YES
  OPTIONS
    "BENCHMARK_ENABLE_TESTING OFF"
    "BENCHMARK_ENABLE_INSTALL OFF"
    "BENCHMARK_INSTALL_DOCS OFF"
    "CMAKE_BUILD_TYPE Release"
)
CPMDeclarePackage(tbb
  NAME tbb
  GITHUB_REPOSITORY zrythm/oneTBB
  VERSION 2022.2.0
  GIT_TAG fe153f04aebb223d500f27bc3f93374a012273ec
  EXCLUDE_FROM_ALL YES
  SYSTEM YES
  OPTIONS
    "TBB_INSTALL OFF"
)
CPMDeclarePackage(cpp_httplib
  NAME cpp_httplib
  VERSION 0.20.1
  GIT_TAG 3af7f2c16147f3fbc6e4d717032daf505dc1652c
  GITHUB_REPOSITORY yhirose/cpp-httplib
  SYSTEM YES
  EXCLUDE_FROM_ALL YES
  OPTIONS
    "HTTPLIB_USE_OPENSSL_IF_AVAILABLE OFF"
    "HTTPLIB_USE_ZSTD_IF_AVAILABLE OFF"
    "HTTPLIB_USE_BROTLI_IF_AVAILABLE OFF"
    "HTTPLIB_USE_ZLIB_IF_AVAILABLE OFF"
    "HTTPLIB_INSTALL OFF"
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions