cmake添加外部静态,动态库,添加.h文件,搜索.h文件方法
cmake_minimum_required(VERSION 3.19) project(test) if (CMAKE_BUILD_TYPE MATCHES "Debug") set(CMAKE_BUILD_TYPE Release) endif() set(CMAKE_CXX_STANDARD 17) set(TBB_DIR C:\\tbb-2021.5\\oneapi-tbb-2021.5.0\\lib\\cmake\\tbb)#指定cmake路径 find_package(TBB REQUIRED) #aux_source_directory(. sources) #aux_source_directory(include sources)#不好用,搜不到.h文件,只能搜索到.cpp文件 FILE(GLOB_RECURSE sources CONFIGURE_DEPENDS include/*.h )#搜索指定目录下的库 #add_library(test SHARED pod.h test2.cpp) add_executable(test test2.cpp) target_sources(test PUBLIC ${sources})#添加.h文件 target_link_libraries(test TBB::tbb )#添加动态静态库 #find_package(OpenMP REQUIRED) #target_link_libraries(test OpenMP::OpenMP_CXX) message(WARNING "${sources}")