cmake_minimum_required(VERSION 3.0.0)
# specify the C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
#project wmxWS
project(wmxWS VERSION 0.1.0)
#test
include(CTest)
include(CPack)
enable_testing()
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
#--生成配置文件,传入变量 、宏定义
configure_file(
${PROJECT_SOURCE_DIR}/config/config.h.in
${PROJECT_SOURCE_DIR}/config/config.h
)
message(STATUS "PROJECT_SOURCE_DIR " ${PROJECT_SOURCE_DIR})
message(STATUS "PROJECT_BINARY_DIR " ${PROJECT_BINARY_DIR})
# 递归添加头文件
file(GLOB_RECURSE Headers
"*.h"
)
# 递归添加源文件
file(GLOB_RECURSE Sources
"${PROJECT_SOURCE_DIR}/src/*.c"
"${PROJECT_SOURCE_DIR}/src/*.cc"
"${PROJECT_SOURCE_DIR}/src/*.cpp"
)
message(STATUS "${Sources}")
# ----打印
foreach(h ${Headers})
message(STATUS "h : ${h}")
endforeach()
# ----打印
foreach(s ${Sources})
message(STATUS "s : ${s}")
endforeach()
#执行文件
add_executable(testCode ${PROJECT_SOURCE_DIR}/src/main.cpp)
add_executable(promise ${PROJECT_SOURCE_DIR}/src/promise.cpp)
add_executable(test1 ${PROJECT_SOURCE_DIR}/src/test.cpp)
add_executable(treeN ${PROJECT_SOURCE_DIR}/tree/treeNode.cpp)
add_executable(listMain ${PROJECT_SOURCE_DIR}/list/listMain.cpp)
#头文件
target_include_directories(
testCode PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/sort
${CMAKE_CURRENT_SOURCE_DIR}/config
)
target_include_directories(
promise PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/sort
${CMAKE_CURRENT_SOURCE_DIR}/config
)
target_include_directories(
test1 PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/sort
${CMAKE_CURRENT_SOURCE_DIR}/config
)
#链接库文件
target_link_libraries(promise pthread)
target_link_libraries(test1 pthread)