cmake_minimum_required(VERSION 3.5) project(testName LANGUAGES CXX) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(Qt5 COMPONENTS REQUIRED Widgets Sql Charts Network) set(TEST_DIR test) file(GLOB HEAD_TESTS "${TEST_DIR}/*.h") aux_source_directory(${TEST_DIR} SRC_TESTS) set(RES_QRC res/res.qrc) set(SUB_DIRS utils model view) foreach(subDir ${SUB_DIRS}) include_directories(${subDir}) file(GLOB HEAD_LIST "${subDir}/*.h") aux_source_directory(${subDir} SRC_LIST) set(PROJECT_SOURCES ${PROJECT_SOURCES} ${SRC_LIST} ${HEAD_LIST}) endforeach() #set(BOOST_DIR "/home/wc/work/junke_src/vendor/boost_1_72_0"Qt5::Charts CACHE PATH "boost path") include_directories("/home/wc/work/junke_src/vendor/boost_1_72_0") link_libraries(Qt5::Widgets Qt5::Sql Qt5::Charts Qt5::Network) link_libraries(curl) add_compile_definitions(APP_NAME="${PROJECT_NAME}") add_executable(AutoTest ${PROJECT_SOURCES} ${RES_QRC} ${HEAD_TESTS} ${SRC_TESTS}) target_compile_definitions(AutoTest PUBLIC INCLUDE_TESTS) #target_link_libraries(AutoTest PRIVATE collabrotive) add_executable(SchemeEdit ${PROJECT_SOURCES} ${RES_QRC} main.cpp) #target_link_libraries(TestName PRIVATE collabrotive) macro(SUBDIRLIST result curdir) file(GLOB children RELATIVE ${curdir} ${curdir}/*) set(dirlist "") foreach(child ${children}) if(IS_DIRECTORY ${curdir}/${child}) LIST(APPEND dirlist ${child}) endif() endforeach() set(${result} ${dirlist}) endmacro() #SUBDIRLIST(SRC_DIR_LIST ${CMAKE_CURRENT_SOURCE_DIR}) #FOREACH(src_dir ${SRC_DIR_LIST}) # IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${src_dir}/CMakeLists.txt") # add_subdirectory(${src_dir}) # include_directories(${src_dir}) ## ENDIF() ##ENDFOREACH() SUBDIRLIST(SRC_DIR_LIST ${CMAKE_CURRENT_SOURCE_DIR}) FOREACH(src_dir ${SRC_DIR_LIST}) IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${src_dir}/CMakeLists.txt") add_subdirectory(${src_dir}) include_directories(${src_dir}) ENDIF() ENDFOREACH()
标签:src,CMakeLists,set,CMAKE,Qt,LIST,dir,txt,DIR From: https://www.cnblogs.com/RedWetPlace/p/17842117.html