Skip to content

Commit

Permalink
Build: Add alias target for dependent project CMake consumption (#143)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Phytolizer committed Jul 5, 2024
1 parent c099aae commit 7020935
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ endif()
# Define the library
add_library(${TARGET_NAME} ${SOURCE_FILES})

# Define alias library to fail early in dependent projects
add_library(${TARGET_NAME}::${TARGET_NAME} ALIAS ${TARGET_NAME})

if (BUILD_SHARED_LIBS)
target_compile_definitions(${TARGET_NAME} PRIVATE NFD_EXPORT INTERFACE NFD_SHARED)
endif ()
Expand Down

0 comments on commit 7020935

Please sign in to comment.