cpm-cmake / CPM.cmake

📦 CMake's missing package manager. A small CMake script for setup-free, cross-platform, reproducible dependency management.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Enhancement] SYSTEM include workaround for older cmake versions

poolfeast-420 opened this issue · comments

Cmake versions older than 3.25 do not have the SYSTEM target property.

Entries of INTERFACE_INCLUDE_DIRECTORIES are treated as system include directories when compiling consumers.

Its possible to move all INTERFACE_INCLUDE_DIRECTORIES to INTERFACE_SYSTEM_INCLUDE_DIRECTORIES manually with something like:

    # Grab the public includes from a target
    get_target_property(IID ${TARGET} INTERFACE_INCLUDE_DIRECTORIES)
    # Set the targets public includes as its system includes
    set_target_properties(${TARGET} PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${IID}")

Could CPM do this automatically based on the version?

From my understanding this could be transparent to users.

You can also do:

set_target_properties(${TARGET} PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES $<TARGET_PROPERTY:${TARGET},INTERFACE_INCLUDE_DIRECTORIES>)