Question
I noticed a possible mismatch in the installed CMake package export. I may be missing the intended external usage, so I wanted to ask before proposing a patch.
In current master, the target exports this include directory for installed consumers:
target_include_directories(
${PROJECT_NAME}
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/src/>
$<INSTALL_INTERFACE:include/bacnet/>)
The install rules install the BACnet headers under ${CMAKE_INSTALL_INCLUDEDIR}/bacnet:
install(
DIRECTORY src/bacnet
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT dev
FILES_MATCHING
PATTERN "*.h")
This produces installed headers like:
${prefix}/include/bacnet/bacdef.h
${prefix}/include/bacnet/bacapp.h
${prefix}/include/bacnet/datalink/dlenv.h
Many source files and headers use the bacnet/... include style, for example:
#include "bacnet/bacdef.h"
#include "bacnet/bacapp.h"
#include "bacnet/datalink/dlenv.h"
For that include style, the include root normally needs to be:
However, the installed CMake target currently gives consumers:
That appears to be one level deeper than the installed header layout expects for #include <bacnet/...>.
There is also a related detail: the port headers are installed directly under ${prefix}/include, for example:
${prefix}/include/bacport.h
${prefix}/include/rs485.h
${prefix}/include/dlmstp_port.h
Those headers are not visible through ${prefix}/include/bacnet.
Potential impact
A downstream CMake consumer using the installed package, for example:
find_package(bacnet-stack CONFIG REQUIRED)
target_link_libraries(my_app PRIVATE bacnet-stack::bacnet-stack)
may receive an include path that is one level too deep.
This can make the usual include style fail:
#include <bacnet/bacdef.h>
because the compiler may look for:
${prefix}/include/bacnet/bacnet/bacdef.h
Possible fix
If the intended public include style is #include <bacnet/...>, would changing the installed interface to the following be acceptable?
target_include_directories(
${PROJECT_NAME}
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/src/>
$<INSTALL_INTERFACE:include>)
This would keep the source-tree build behavior unchanged, while making installed CMake consumers use ${prefix}/include, which matches the installed header layout.
Question for maintainers
Is $<INSTALL_INTERFACE:include/bacnet/> intentional for external CMake consumers, or would a small PR changing it to $<INSTALL_INTERFACE:include> be welcome?
I can prepare a minimal PR if this matches the intended installed package usage.
Question
I noticed a possible mismatch in the installed CMake package export. I may be missing the intended external usage, so I wanted to ask before proposing a patch.
In current master, the target exports this include directory for installed consumers:
The install rules install the BACnet headers under ${CMAKE_INSTALL_INCLUDEDIR}/bacnet:
This produces installed headers like:
${prefix}/include/bacnet/bacdef.h ${prefix}/include/bacnet/bacapp.h ${prefix}/include/bacnet/datalink/dlenv.hMany source files and headers use the bacnet/... include style, for example:
For that include style, the include root normally needs to be:
${prefix}/includeHowever, the installed CMake target currently gives consumers:
${prefix}/include/bacnetThat appears to be one level deeper than the installed header layout expects for #include <bacnet/...>.
There is also a related detail: the port headers are installed directly under ${prefix}/include, for example:
${prefix}/include/bacport.h ${prefix}/include/rs485.h ${prefix}/include/dlmstp_port.hThose headers are not visible through ${prefix}/include/bacnet.
Potential impact
A downstream CMake consumer using the installed package, for example:
may receive an include path that is one level too deep.
This can make the usual include style fail:
because the compiler may look for:
${prefix}/include/bacnet/bacnet/bacdef.hPossible fix
If the intended public include style is #include <bacnet/...>, would changing the installed interface to the following be acceptable?
This would keep the source-tree build behavior unchanged, while making installed CMake consumers use ${prefix}/include, which matches the installed header layout.
Question for maintainers
Is $<INSTALL_INTERFACE:include/bacnet/> intentional for external CMake consumers, or would a small PR changing it to $<INSTALL_INTERFACE:include> be welcome?
I can prepare a minimal PR if this matches the intended installed package usage.