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 26 27 28 29 30 31 32 33 34 35 36 37 38
| cmake_minimum_required(VERSION 3.10) project(temp)
set(CMAKE_C_STANDARD 11) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON)
# 源文件 file(GLOB_RECURSE SOURCES "src/*.c" )
# 头文件路径 include_directories(${SDL2_INCLUDE_DIRS}) include_directories(${PROJECT_SOURCE_DIR})
# 特定头文件 file(GLOB_RECURSE INCLUDES )
# 环境变量 set(LIBS_SYSTEM ws2_32) set(CMAKE_C_FLAGS "-static" ) set(CMAKE_BUILD_TYPE "Debug") # SET(CMAKE_BUILD_TYPE "Release")
# 可执行文件 add_executable(a ${SOURCES} ${INCLUDES})
# 链接库和依赖 # find_package(SDL2 REQUIRED SDL2) # target_link_libraries(a PRIVATE SDL2::SDL2-static paho-mqtt3c-static ws2_32 winpthread)
# 自定义目标 # add_custom_target (run COMMAND ${EXECUTABLE_OUTPUT_PATH}/main)
|