argtable / argtable3

A single-file, ANSI C, command-line parsing library that parses GNU-style command-line options.
http://www.argtable.org
Other
372 stars 65 forks source link

Missing include install path in CMake config export #84

Closed schdro closed 1 year ago

schdro commented 1 year ago

argtable (3.2.2) exports a CMake config file Argtable3Config.cmakeduring installation. However, it does not export the include path where argtable3.h is installed. Due to this, particularly with nonstandard paths deviating from /usr/include (e.g. some local CI build installing argtable dependency into local directory first) the header file will be poorly accessible. This makes default installation of the header file less useful. I.e., either installation could also be suppresed, or the include path should be exported cleanly.

Sample:

cmake_minimum_required(VERSION 3.23)
project(tst)

find_package(Argtable3 CONFIG REQUIRED)

get_target_property(incpath argtable3::argtable3 INTERFACE_INCLUDE_DIRECTORIES)
message("Incpath=${incpath}")

add_executable(tst main.cpp)

target_link_libraries(tst PRIVATE
    argtable3
)

Prints Incpath=incpath-NOTFOUND because the target property for the include path is unpopulated.

schdro commented 1 year ago

With https://github.com/argtable/argtable3/pull/85 output is like: Incpath=/usr/include (when tested with default include install path)

schdro commented 1 year ago

For the record, had noticed that PR https://github.com/argtable/argtable3/pull/82 point 1 also raises and (partially) addresses issue of missing include. However, abovelinked PR https://github.com/argtable/argtable3/pull/85 with extended approach complies to recommendations of https://cmake.org/cmake/help/latest/prop_tgt/INTERFACE_INCLUDE_DIRECTORIES.html and also aligns install path.