17 lines
362 B
CMake
17 lines
362 B
CMake
cmake_minimum_required(VERSION 3.29)
|
|
project(main C)
|
|
|
|
set(CMAKE_C_STANDARD 23)
|
|
|
|
# 静态链接
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
|
|
|
|
# 或者使用以下方式(更推荐)
|
|
add_executable(main main.c)
|
|
|
|
if(WIN32)
|
|
target_link_libraries(main ws2_32)
|
|
# 静态链接所有库
|
|
target_link_options(main PRIVATE -static)
|
|
endif()
|