//CmakeLists.txt cmake_minimum_required(VERSION 3.5) # 设置项目名称和语言 project(ToolKitManage LANGUAGES CXX) # 允许包含当前目录 set(CMAKE_INCLUDE_CURRENT_DIR ON) # 设置自动处理UI、MOC和RCC set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) # 设置C++标准 set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) # 查找Qt5 Widgets组件 find_package(Qt5 COMPONENTS Widgets REQUIRED) # 包含目录 include_directories( ${PROJECT_SOURCE_DIR}/include ${CMAKE_CURRENT_BINARY_DIR} ) # 设置AUTOUIC搜索路径以处理UI文件 set(CMAKE_AUTOUIC_SEARCH_PATHS ${CMAKE_SOURCE_DIR}/ui) # 收集源文件、头文件、UI文件和资源文件 file(GLOB PRO_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/ *.cpp) file(GLOB PRO_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/include/ *.h) file(GLOB PRO_UI ${CMAKE_CURRENT_SOURCE_DIR}/ui/ *.ui) file(GLOB PRO_RESOURCES ${CMAKE_CURRENT_SOURCE_DIR}/resource/ *.qrc) # 创建可执行文件 add_executable(ToolKitManage ${PRO_SRC} ${PRO_INCLUDE} ${PRO_UI} ${PRO_RESOURCES} ) # 链接Qt5 Widgets库 target_link_libraries(ToolKitManage PRIVATE Qt5::Widgets) # 设置glog库的包含目录 set(GLOG_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Thirdlib/glog/include ) include_directories(${GLOG_INCLUDE_DIR}) # 设置glog库文件 set(GLOG_LIBRARIES debug ${CMAKE_CURRENT_SOURCE_DIR}/Thirdlib/glog/lib/glogd.lib optimized ${CMAKE_CURRENT_SOURCE_DIR}/Thirdlib/glog/lib/glog.lib ) # 链接glog库 target_link_libraries(ToolKitManage PRIVATE ${GLOG_LIBRARIES})