【VSCode】CMake开发

张开发
2026/4/18 15:24:28 15 分钟阅读

分享文章

【VSCode】CMake开发
第一次打开eclipse新建的cmake工程后会让你选择工具包选择最后一个GCC编译器cmake_minimum_required(VERSION 3.10) # Set some basic project attributes project (UI_simulator VERSION 0.1 DESCRIPTION A Hello World Project) set(CMAKE_C_STANDARD 99) set(CMAKE_CXX_STANDARD 11) set(CMAKE_C_COMPILER D:/SoftwareBackup/GreenSoftware/RedPandaIDE/MinGW64/bin/gcc.exe) set(CMAKE_CXX_COMPILER D:/SoftwareBackup/GreenSoftware/RedPandaIDE/MinGW64/bin/g.exe) include_directories(${PROJECT_SOURCE_DIR}) include_directories(${PROJECT_SOURCE_DIR}/APP) include_directories(${PROJECT_SOURCE_DIR}/BSP) include_directories(${PROJECT_SOURCE_DIR}/Packages/LGUI) include_directories(${PROJECT_SOURCE_DIR}/Packages/toolkit/inc) include_directories(D:/SoftwareBackup/GreenSoftware/RedPandaIDE/MinGW64/x86_64-w64-mingw32/include/easyx) # This project will output an executable file file(GLOB SRC_FILES APP/*.c BSP/*.cpp Packages/LGUI/*.c Packages/toolkit/src/*.c ) add_executable(${PROJECT_NAME} main.cpp ${SRC_FILES}) # Create a simple configuration header configure_file(config.h.in config.h) # Include the configuration header in the build target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_BINARY_DIR}) link_directories(D:/SoftwareBackup/GreenSoftware/RedPandaIDE/MinGW64/x86_64-w64-mingw32/lib) target_link_libraries(${PROJECT_NAME} easyx)注意点“add_executable”只能有一条“target_link_libraries”增加的静态库不能和项目同名MinGW64下的静态库.a动态库.dllcmake工具链异常时可以重新扫描并选择工具包

更多文章