cmake_minimum_required(VERSION 3.12) #设置可执行文件名称 set(execName1 show1) #包含源文件 file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/*.ui ${CMAKE_CURRENT_SOURCE_DIR}/*.qrc ${CMAKE_CURRENT_SOURCE_DIR}/StyleManager/*.cpp ${CMAKE_SOURCE_DIR}/External/common/Thread/*.cpp ${CMAKE_SOURCE_DIR}/TransmitterSwitch/*.cpp ${CMAKE_SOURCE_DIR}/TransmitterSwitch/WebAPI/*.cpp ${CMAKE_SOURCE_DIR}/TransmitterSwitch/Resource/*.qrc ${CMAKE_SOURCE_DIR}/TransmitterSwitch/WidgetItems/*.cpp ${CMAKE_SOURCE_DIR}/TransmitterSwitch/UserData/*.cpp ${CMAKE_SOURCE_DIR}/TransmitterSwitch/AddItem/*.cpp ${CMAKE_SOURCE_DIR}/TransmitterSwitch/ItemData/*.cpp ${CMAKE_SOURCE_DIR}/TransmitterSwitch/Template/*.cpp ${CMAKE_SOURCE_DIR}/TransmitterSwitch/warnning/*.cpp ${CMAKE_SOURCE_DIR}/TransmitterSwitch/common/Shadow/*.cpp ${CMAKE_SOURCE_DIR}/TransmitterSwitch/common/ImageBlur/*.cpp ${CMAKE_SOURCE_DIR}/TransmitterSwitch/common/combobox/*.cpp ${CMAKE_SOURCE_DIR}/TransmitterSwitch/common/SelectTime/*.cpp ${CMAKE_SOURCE_DIR}/TransmitterSwitch/common/date/*.cpp ${CMAKE_SOURCE_DIR}/TransmitterSwitch/common/date/*.qrc ${CMAKE_SOURCE_DIR}/TransmitterSwitch/common/DropShadow/*.cpp ${CMAKE_SOURCE_DIR}/TransmitterSwitch/common/PaintHelper/*.cpp ${CMAKE_SOURCE_DIR}/TransmitterSwitch/common/warning/*.cpp # ${LHQLog_SOURCE_DIRS}/*.cpp ${LHHTTPAPI_SOURCE_DIRS}/*.cpp ) # message(STATUS "LHQLog_SOURCE_DIRS: ${LHQLog_SOURCE_DIRS}") # message(STATUS "LHHTTPAPI_SOURCE_DIRS: ${LHHTTPAPI_SOURCE_DIRS}") #生成可执行程序 add_executable(${execName1} ${LOCAL_SRC}) #添加头文件 target_include_directories(${execName1} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/LHLog ${CMAKE_CURRENT_SOURCE_DIR}/StyleManager ${CMAKE_SOURCE_DIR}/External/common/Thread ${CMAKE_SOURCE_DIR}/TransmitterSwitch ${CMAKE_SOURCE_DIR}/TransmitterSwitch/WebAPI ${CMAKE_SOURCE_DIR}/TransmitterSwitch/WidgetItems ${CMAKE_SOURCE_DIR}/TransmitterSwitch/UserData ${CMAKE_SOURCE_DIR}/TransmitterSwitch/AddItem ${CMAKE_SOURCE_DIR}/TransmitterSwitch/ItemData ${CMAKE_SOURCE_DIR}/TransmitterSwitch/Template ${CMAKE_SOURCE_DIR}/TransmitterSwitch/warnning ${CMAKE_SOURCE_DIR}/TransmitterSwitch/common ${CMAKE_SOURCE_DIR}/TransmitterSwitch/common/nlohmann ${CMAKE_SOURCE_DIR}/TransmitterSwitch/common/Shadow ${CMAKE_SOURCE_DIR}/TransmitterSwitch/common/ImageBlur ${CMAKE_SOURCE_DIR}/TransmitterSwitch/common/combobox ${CMAKE_SOURCE_DIR}/TransmitterSwitch/common/SelectTime ${CMAKE_SOURCE_DIR}/TransmitterSwitch/common/date ${CMAKE_SOURCE_DIR}/TransmitterSwitch/common/warning # ${LHQLog_INCLUDE_DIRS} ${LHHTTPAPI_INCLUDE_DIRS} ${spdlog_INCLUDE_DIR} ) #链接Qt库 target_link_libraries(${execName1} PRIVATE Qt5::Widgets Qt5::Core Qt5::Network ) #链接外部库 target_link_libraries(${execName1} PRIVATE ${spdlog_LIBRARY} ) #连接stdc++fs库,如果编译器版本低于GCC9.0,则需要连接这个库 #GCC9.0以上包含进了标准库 # if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) # target_link_libraries(${execName1} PRIVATE stdc++fs) # endif() # endif()