cmake_minimum_required(VERSION 2.8) project(appname) SET(SRC_LIST main.c xx/xx.c ) # add (.h) address include_directories(${PROJECT_SOURCE_DIR}/xxx ) # add lib address link_directories(${PROJECT_SOURCE_DIR}/xxx ) #编译为可执行文件 add_executable(${PROJECT_NAME} ${SRC_LIST}) #编译为动态库 #add_library(${PROJECT_NAME} SHARED ${SRC_LIST}) #编译为静态库 #add_library(${PROJECT_NAME} STATIC ${SRC_LIST}) add_definitions(-Wall -std=gnu99 -lm -pthread -lstdc++) #添加自定义全局宏:define xxx add_definitions(-Dxxx) # 添加多线程 find_package(Threads) target_link_libraries (${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT}) # math 库 target_link_libraries(${PROJECT_NAME} m) # 添加 libxxx.so target_link_libraries(${PROJECT_NAME} xxx)
c/c++开发分享QT Cmake 示例模板地址:https://blog.csdn.net/weixin_42549534/article/details/108576457
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/c-cdevelopment/597606.html