Skip to content

Commit 7020935

Browse files
authored
Build: Add alias target for dependent project CMake consumption (#143)
This naming convention is common in other CMake projects. The presence of `::` in the identifier results in fail-fast behavior; when a user calls `target_link_libraries` or similar, `nfd::nfd` MUST be an existing target at configure time, but `nfd` might have been a system library. As a result, the latter would appear to work until the linker fails to find a library by that name. This is not a breaking change - plain `nfd` is still accessible.
1 parent c099aae commit 7020935

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ endif()
6161
# Define the library
6262
add_library(${TARGET_NAME} ${SOURCE_FILES})
6363

64+
# Define alias library to fail early in dependent projects
65+
add_library(${TARGET_NAME}::${TARGET_NAME} ALIAS ${TARGET_NAME})
66+
6467
if (BUILD_SHARED_LIBS)
6568
target_compile_definitions(${TARGET_NAME} PRIVATE NFD_EXPORT INTERFACE NFD_SHARED)
6669
endif ()

0 commit comments

Comments
 (0)