daixtrose / cplusplus-primer

A short introduction to C++ which was quickly hacked together
MIT License
0 stars 0 forks source link

Add insulation of packaging definitions to library examples #8

Open daixtrose opened 2 months ago

daixtrose commented 2 months ago

See https://alexreinking.com/blog/building-a-dual-shared-and-static-library-with-cmake.html

Finally, we'll add some packaging logic, but include it by default only if we're the top-level project. That insulates FetchContent users from our install rules if they don't want them, but keeps them available in case they do:

string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}" is_top_level)
option(SomeLib_INCLUDE_PACKAGING "Include packaging rules for SomeLib" "${is_top_level}")
if (SomeLib_INCLUDE_PACKAGING)
    add_subdirectory(packaging)
endif ()