需要先构建WinDevice 在查找 lib
This commit is contained in:
parent
b01ab5a972
commit
fde177894a
@ -12,6 +12,38 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|||||||
# 设置源代码文件编码为UTF-8
|
# 设置源代码文件编码为UTF-8
|
||||||
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/source-charset:utf-8>")
|
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/source-charset:utf-8>")
|
||||||
|
|
||||||
|
|
||||||
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
|
set(ARCH_DIR "x64")
|
||||||
|
else()
|
||||||
|
set(ARCH_DIR "x86")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(WinDevice_OUTPUT "../WinDevice/output")
|
||||||
|
message("WinDevice_OUTPUT: ${WinDevice_OUTPUT}")
|
||||||
|
# 获取架构信息
|
||||||
|
|
||||||
|
set(WinDevice_INCLUDE_DIR "${WinDevice_OUTPUT}/include/")
|
||||||
|
message("WinDevice_INCLUDE_DIR: ${WinDevice_INCLUDE_DIR}")
|
||||||
|
set(WinDevice_THIRD_INCLUDE_DIR "${WinDevice_OUTPUT}/third_lib/")
|
||||||
|
message("WinDevice_THIRD_INCLUDE_DIR: ${WinDevice_THIRD_INCLUDE_DIR}")
|
||||||
|
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
set(WinDevice_LIB_DIR "${WinDevice_OUTPUT}/${ARCH_DIR}/debug/")
|
||||||
|
else()
|
||||||
|
set(WinDevice_LIB_DIR "${WinDevice_OUTPUT}/${ARCH_DIR}/release/")
|
||||||
|
endif()
|
||||||
|
message("WinDevice_LIB_DIR: ${WinDevice_LIB_DIR}")
|
||||||
|
|
||||||
|
message("build WinDecie in: ${CMAKE_BUILD_TYPE} mode")
|
||||||
|
|
||||||
|
|
||||||
|
add_custom_target(BuildWinDevice ALL
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E echo "Starting to build WinDevice project..."
|
||||||
|
COMMAND ${CMAKE_COMMAND} -S ../WinDevice -B ../WinDevice/build -G "Visual Studio 17 2022" -A ${ARCH_DIR} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
||||||
|
COMMAND ${CMAKE_COMMAND} --build ../WinDevice/build --config ${CMAKE_BUILD_TYPE}
|
||||||
|
COMMENT "Building WinDevice project in ${CMAKE_BUILD_TYPE} mode"
|
||||||
|
)
|
||||||
|
|
||||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
|
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
|
||||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
|
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
|
||||||
|
|
||||||
@ -47,47 +79,24 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(DeviceManager PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
|
|
||||||
|
|
||||||
|
|
||||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
||||||
set(ARCH_DIR "x64")
|
|
||||||
else()
|
|
||||||
set(ARCH_DIR "x86")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(WinDevice_OUTPUT "../WinDevice/output")
|
|
||||||
message("WinDevice_OUTPUT: ${WinDevice_OUTPUT}")
|
|
||||||
# 获取架构信息
|
|
||||||
set(WinDevice_INCLUDE_DIR "${WinDevice_OUTPUT}/include/")
|
|
||||||
message("WinDevice_INCLUDE_DIR: ${WinDevice_INCLUDE_DIR}")
|
|
||||||
set(WinDevice_THIRD_INCLUDE_DIR "${WinDevice_OUTPUT}/third_lib/")
|
|
||||||
message("WinDevice_THIRD_INCLUDE_DIR: ${WinDevice_THIRD_INCLUDE_DIR}")
|
|
||||||
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
||||||
set(WinDevice_LIB_DIR "${WinDevice_OUTPUT}/${ARCH_DIR}/debug/")
|
|
||||||
else()
|
|
||||||
set(WinDevice_LIB_DIR "${WinDevice_OUTPUT}/${ARCH_DIR}/release/")
|
|
||||||
endif()
|
|
||||||
message("WinDevice_LIB_DIR: ${WinDevice_LIB_DIR}")
|
|
||||||
|
|
||||||
message("build WinDecie in: ${CMAKE_BUILD_TYPE} mode")
|
|
||||||
|
|
||||||
|
|
||||||
add_custom_target(BuildWinDevice ALL
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E echo "Starting to build WinDevice project..."
|
|
||||||
COMMAND ${CMAKE_COMMAND} -S ../WinDevice -B ../WinDevice/build -G "Visual Studio 17 2022" -A ${ARCH_DIR} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
|
||||||
COMMAND ${CMAKE_COMMAND} --build ../WinDevice/build --config ${CMAKE_BUILD_TYPE}
|
|
||||||
COMMENT "Building WinDevice project in ${CMAKE_BUILD_TYPE} mode"
|
|
||||||
)
|
|
||||||
# 将 DeviceManager 目标的构建依赖于 BuildWinDevice 自定义目标
|
# 将 DeviceManager 目标的构建依赖于 BuildWinDevice 自定义目标
|
||||||
add_dependencies(DeviceManager BuildWinDevice)
|
# add_dependencies(DeviceManager BuildWinDevice)
|
||||||
|
|
||||||
|
message("include_directories ${WinDevice_INCLUDE_DIR} ${WinDevice_THIRD_INCLUDE_DIR}")
|
||||||
|
|
||||||
# 添加头文件目录
|
# 添加头文件目录
|
||||||
include_directories(${WinDevice_INCLUDE_DIR} ${WinDevice_THIRD_INCLUDE_DIR})
|
include_directories(${WinDevice_INCLUDE_DIR} ${WinDevice_THIRD_INCLUDE_DIR})
|
||||||
# 使用 find_library 查找动态库文件
|
# 使用 find_library 查找动态库文件
|
||||||
find_library(WinDevice_LIB NAMES WinDevice HINTS ${WinDevice_LIB_DIR})
|
find_library(WinDevice_LIB NAMES WinDevice HINTS ${WinDevice_LIB_DIR})
|
||||||
# Release 模式下,链接 WinDevice 生成的库文件
|
# 如果找到 WinDevice 库,才链接到 DeviceManager
|
||||||
|
if(WinDevice_LIB)
|
||||||
|
message(STATUS "Found WinDevice library: ${WinDevice_LIB}")
|
||||||
target_link_libraries(DeviceManager PRIVATE ${WinDevice_LIB})
|
target_link_libraries(DeviceManager PRIVATE ${WinDevice_LIB})
|
||||||
|
else()
|
||||||
|
message(WARNING "WinDevice library not found in ${WinDevice_LIB_DIR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_link_libraries(DeviceManager PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
|
||||||
|
|
||||||
set_target_properties(DeviceManager PROPERTIES
|
set_target_properties(DeviceManager PROPERTIES
|
||||||
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
|
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
|
||||||
|
Loading…
Reference in New Issue
Block a user