Files
Lixinzhe_lib/CMakeLists.txt

33 lines
1.0 KiB
CMake
Raw Normal View History

2025-06-16 08:52:40 +08:00
cmake_minimum_required(VERSION 3.28)
project(lxzl)
set(CMAKE_CXX_STANDARD 11)
include_directories(Log)
aux_source_directory(Log LOG_LIST)
include_directories(Serial)
aux_source_directory(Serial SERIAL_LIST)
include_directories(Socket)
aux_source_directory(Socket SOCKET_LIST)
include_directories(Thread)
aux_source_directory(Thread THREAD_LIST)
include_directories(Test)
aux_source_directory(Test TEST_LIST)
add_executable(${PROJECT_NAME} main.cpp ${LOG_LIST} ${SERIAL_LIST} ${SOCKET_LIST} ${THREAD_LIST} ${TEST_LIST})
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
target_link_libraries(${PROJECT_NAME} ws2_32)
else ()
target_link_libraries(${PROJECT_NAME} pthread)
endif ()
#设置配置文件
set(DIST_FILES config.ini)
# 把配置文件复制到构建目录
foreach (file ${DIST_FILES})
# 使用 RELATIVE 配置,这样路径是相对于 CMakeLists.txt 的
set(src_path "${file}")
set(dst_path "${CMAKE_CURRENT_BINARY_DIR}/${file}")
configure_file(${src_path} ${dst_path} COPYONLY)
endforeach ()