不想用aux_source_directory,可参考如下:
1 cmake_minimum_required(VERSION 2.6) 2 SET(CMAKE_C_COMPILER "E:/MinGW-W64/mingw64/bin/gcc.exe") 3 project(wdg_autosar_test) 4 SET(EB_OutPut_Src "${CMAKE_CURRENT_SOURCE_DIR}/../Wdg_ZX_K14xM_EB_OutPut/ewdt_direct_service/Src") 5 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../Wdg_ZX_K14xM/Inc 6 ${CMAKE_CURRENT_SOURCE_DIR}/../Base_ZX_K14xM/Inc 7 ${CMAKE_CURRENT_SOURCE_DIR}/../Wdg_ZX_K14xM/Inc/pb_pc_cfg_inc_files 8 ${CMAKE_CURRENT_SOURCE_DIR}/../WdgIf_ZX_K14xM/include 9 ${CMAKE_CURRENT_SOURCE_DIR}/../Wdg_ZX_K14xM_EB_OutPut/ewdt_direct_service/include 10 )#添加头文件路径 11 12 aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/../Wdg_ZX_K14xM/Src SRC_LIST_DRV) 13 aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/../Wdg_ZX_K14xM/Inc/pb_pc_cfg_inc_files SRC_COMMON) 14 add_executable( wdg_autosar_test 15 main.c 16 ${EB_OutPut_Src}/Wdg_Drv_PBcfg.c 17 ${EB_OutPut_Src}/Wdg_Drvw_PBcfg.c 18 ${EB_OutPut_Src}/Wdg_PBcfg.c 19 ${EB_OutPut_Src}/Wdg_PCcfg.c 20 ${SRC_LIST_DRV} 21 ${SRC_COMMON} 22 )#注意添加相应的c文件