Skip to content

Commit

Permalink
Provide namespaced CMake targets (#4737)
Browse files Browse the repository at this point in the history
  • Loading branch information
dg0yt authored Jan 8, 2025
1 parent a4e8c6d commit 39c6b52
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/bin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ endif()

if(BUILD_SHARED_LIBS)
add_library(msquic SHARED ${SOURCES})
add_library(msquic::msquic ALIAS msquic)
target_include_directories(msquic PUBLIC $<INSTALL_INTERFACE:include>)
target_link_libraries(msquic PRIVATE core msquic_platform inc warnings logging base_link main_binary_link_args)
set_target_properties(msquic PROPERTIES OUTPUT_NAME ${QUIC_LIBRARY_NAME})
Expand Down
12 changes: 7 additions & 5 deletions src/bin/msquic-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ include(CMakeFindDependencyMacro)

include("${CMAKE_CURRENT_LIST_DIR}/msquic.cmake")

foreach(_t IN ITEMS msquic msquic_platform)
if(TARGET msquic::${_t} AND NOT TARGET ${_t})
add_library(${_t} ALIAS msquic::${_t})
endif()
endforeach()
# Legacy names
if(NOT TARGET msquic)
add_library(msquic ALIAS msquic::msquic)
endif()
if(NOT TARGET msquic_platform)
add_library(msquic_platform ALIAS msquic::platform)
endif()
1 change: 1 addition & 0 deletions src/inc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ target_compile_features(inc INTERFACE cxx_std_17)
target_compile_features(inc INTERFACE c_std_11)

add_library(base_link INTERFACE)
add_library(msquic::base_link ALIAS base_link)

if (HAS_GUARDCF)
target_link_options(base_link INTERFACE /guard:cf /DYNAMICBASE)
Expand Down
2 changes: 2 additions & 0 deletions src/platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ else()
endif()

add_library(msquic_platform STATIC ${SOURCES})
add_library(msquic::platform ALIAS msquic_platform)
set_target_properties(msquic_platform PROPERTIES EXPORT_NAME platform)

if("${CX_PLATFORM}" STREQUAL "windows")
target_link_libraries(
Expand Down
2 changes: 1 addition & 1 deletion src/platform/unittest/external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ set_target_properties(msquic::inc PROPERTIES INTERFACE_COMPILE_DEFINITIONS "${d

add_executable(msquicplatformtest ${SOURCES})
target_include_directories(msquicplatformtest PRIVATE ${CMAKE_INSTALL_PREFIX}/include)
target_link_libraries(msquicplatformtest PRIVATE gtest msquic::msquic msquic::msquic_platform ws2_32 ntdll ncrypt crypt32 iphlpapi)
target_link_libraries(msquicplatformtest PRIVATE gtest msquic::msquic msquic::platform ws2_32 ntdll ncrypt crypt32 iphlpapi)
target_compile_definitions(msquicplatformtest PRIVATE QUIC_EVENTS_STUB QUIC_LOGS_STUB _DISABLE_VECTOR_ANNOTATION _DISABLE_STRING_ANNOTATION)

0 comments on commit 39c6b52

Please sign in to comment.