Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bac53a3e45 | ||
|
|
fa1f547e81 | ||
|
|
12e837c941 | ||
|
|
675d01f444 |
+3
-1
@@ -12,6 +12,9 @@ option(DR_COMPILE_CHECK "Build compile-compatibility tests for each Cortex-M va
|
||||
set(DR_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/datarouter.c CACHE INTERNAL "")
|
||||
set(DR_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "")
|
||||
|
||||
# 预编译包使用者可用 find_package(DataRouter CONFIG) 从此路径加载
|
||||
set(DataRouter_CMAKE_CONFIG_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/cmake CACHE INTERNAL "")
|
||||
|
||||
# ── 编译兼容性矩阵 (仅在 host 编译器和 ARM GCC 均可用时生效) ──
|
||||
|
||||
if(DR_COMPILE_CHECK)
|
||||
@@ -58,7 +61,6 @@ endif()
|
||||
add_library(DataRouter STATIC datarouter.c)
|
||||
target_include_directories(DataRouter PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||
)
|
||||
|
||||
if(BUILD_EXAMPLES OR NOT DEFINED BUILD_EXAMPLES)
|
||||
|
||||
@@ -1,11 +1,22 @@
|
||||
@PACKAGE_INIT@
|
||||
|
||||
set(DataRouter_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@")
|
||||
set(DataRouter_LIBRARY_DIR "@PACKAGE_LIB_INSTALL_DIR@")
|
||||
get_filename_component(DataRouter_INCLUDE_DIR
|
||||
"${CMAKE_CURRENT_LIST_DIR}/../../../include" ABSOLUTE)
|
||||
get_filename_component(DataRouter_LIBRARY_DIR
|
||||
"${CMAKE_CURRENT_LIST_DIR}/../../../lib" ABSOLUTE)
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/DataRouterTargets.cmake" OPTIONAL)
|
||||
|
||||
# 无论 targets 文件是否加载,都覆盖 include 路径为正确值
|
||||
# (targets 文件中的 _IMPORT_PREFIX 在某些平台/工具链下可能计算异常)
|
||||
if(TARGET DataRouter)
|
||||
set_target_properties(DataRouter PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${DataRouter_INCLUDE_DIR}"
|
||||
)
|
||||
if(NOT TARGET DataRouter::DataRouter)
|
||||
add_library(DataRouter::DataRouter ALIAS DataRouter)
|
||||
endif()
|
||||
else()
|
||||
add_library(DataRouter::DataRouter STATIC IMPORTED)
|
||||
set_target_properties(DataRouter::DataRouter PROPERTIES
|
||||
IMPORTED_LOCATION "${DataRouter_LIBRARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}DataRouter${CMAKE_STATIC_LIBRARY_SUFFIX}"
|
||||
|
||||
Reference in New Issue
Block a user