本文最后更新于:2024年4月25日 上午
安装CMake
本示例使用的开发环境是win11 WSL2
+ vscode
1
| sudo apt install build-essential cmake
|
创建CMakeList.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| cmake_minimum_required(VERSION 3.22) project(data-structure C)
set(CMAKE_C_STANDARD 99) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fexec-charset=GBK") set(CMAKE_BUILD_TYPE Debug)
include_directories(tests source includes)
file(GLOB_RECURSE DATA_STRUCTURE_LIB_SRC source/*.c) add_library(data_structure STATIC ${DATA_STRUCTURE_LIB_SRC})
option(TEST "Whether to enable unit tests" OFF) if (TEST) message(STATUS "Unit tests enabled") enable_testing() endif()
add_executable(test_list tests/list.spec.c)
target_link_libraries(test_list data_structure) add_test(NAME test_list COMMAND test_list 10 24 34)
|