cmake学习
最外层CMakeist.txt
cmake_minimum_required(VERSION 3.21)
project(项目名称)
set(CMAKE_CXX_STANDARD 11)
FIND_PACKAGE(Boost COMPONENTS program_options unit_test_framework atomic system REQUIRED)
link_libraries(/usr/lib/x86_64-linux-gnu/libz.so.1)
add_subdirectory(tile)
add_subdirectory(src)
add_subdirectory(test)
tile文件夹CMakeist.txt
target_include_directories
project(名称)
add_library(${PROJECT_NAME}
xxx.cc
)
add_library(名称::lib ALIAS ${PROJECT_NAME})
target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_SOURCE_DIR})
src文件夹CMakeist.txt
project(名称)
add_library(${PROJECT_NAME}
xxx.cc
)
add_library(名称::lib ALIAS ${PROJECT_NAME})
target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_SOURCE_DIR})
target_link_libraries(${PROJECT_NAME}
名称::lib)
test文件夹CMakeist.txt
project(名称)
add_executable(test xx.cc)
add_executable(unit_test xxx.cc)
target_link_libraries(test
xxx::lib
xxx::lib
)
target_link_libraries(unit_test
xxx::lib
xxx::lib
)
中文学习
|