首页 > 其他分享 >cmake多层级目录调用

cmake多层级目录调用

时间:2023-01-07 15:59:18浏览次数:33  
标签:层级 cmake -- app 调用 test Detecting hello compiler

通过多个cmake层级编译
目录树

➜  test_pro6 tree -h
.
├── [ 351]  CMakeLists.txt
├── [4.0K]  app_hello
│   ├── [  97]  CMakeLists.txt
│   ├── [ 280]  app_hello.c
│   └── [ 218]  app_hello.h
├── [ 276]  app_main.c
└── [4.0K]  build

2 directories, 5 files

顶层cmake

cmake_minimum_required(VERSION 3.16.1)
project(test)

set(PROJECT_NAME test)

set(APP_HELLO_DIR ${PROJECT_SOURCE_DIR}/app_hello)

include_directories(${APP_HELLO_DIR})

add_subdirectory(${APP_HELLO_DIR})

link_directories(${APP_HELLO_DIR})

add_executable(${PROJECT_NAME} ${PROJECT_SOURCE_DIR}/app_main.c)
target_link_libraries(${PROJECT_NAME} hello)

子目录cmake

aux_source_directory(. SRC)

message("hello src dir :" ${SRC})

add_library(hello STATIC ${SRC})

测试

➜  build cmake ..
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
hello src dir :./app_hello.c
-- Configuring done
-- Generating done
-- Build files have been written to: /home/zw/test_pro/test_pro6/build
➜  build make clean all
Scanning dependencies of target hello
[ 25%] Building C object app_hello/CMakeFiles/hello.dir/app_hello.c.o
[ 50%] Linking C static library libhello.a
[ 50%] Built target hello
Scanning dependencies of target test
[ 75%] Building C object CMakeFiles/test.dir/app_main.c.o
[100%] Linking C executable test
[100%] Built target test
➜  build ./test 
app_hello in 

标签:层级,cmake,--,app,调用,test,Detecting,hello,compiler
From: https://www.cnblogs.com/tccxy/p/17032791.html

相关文章

  • cmake常用函数
    cmake的常用函数cmake_minimum_required(VERSION3.0)#指定cmake的最小版本project(demo)#设置项目名称add_executable(demodemo.cpp)#生成可执行文件demo.cpp......
  • 在微服务内部,调用另一个微服务,如何保证事务的一致性
    虽然,我们通常建议涉及到事务的情况下,不要在一个微服务里,调用另外一个微服务,但有时也会遇到无法避开的情况,那我们就来看看应该如何保证事务的一致性。我们先来看看微服务A......
  • H5分享调用微信分享界面
    非要在h5页面调用分享。然后分享到微信朋友圈,首先明确一点,微信H5分享是没有自定义分享按钮组件的,只能引导用户去主动触发右上角三个点的按钮。目前只有APP或微信浏览器右上......
  • elementUI Cascader级联选择器组件 获取多层级的对象形式数据
    贴代码<el-cascaderstyle="width:100%"ref="subjectMajorCascaderElem"placeholder="请选择"@change="selectSubjectMajor"filterable......
  • [源码]JS加密:调用JShaman接口,实现JS代码加密
    源码如下,保存为html即可直接使用。免费版:<html><head><scriptsrc="https://code.jquery.com/jquery-1.11.3.js"></script></head><bo......
  • Java调用CMD命令
    ProcessBuilderbuilder= newProcessBuilder(commands);1、在使用ProcessBuilder时,如果commands使用{"java-version"}这种带空格的命令,可能会报文件找不到的错误,最......
  • JAVA调用SAP RFC接口
    java要调用SAPRFC接口时,需要用到sapjco3.jar架包;windows下还需要将文件sapjco3.dll文件放到system32的目录下;linux下同样需要把sapjco3.so放入项目的执行目录下;下载......
  • android之调用webservice实现图片上传
    最近boss要求做android客户端的图片上传和下载,就是调用服务器的webservice接口,实现从android上传图片到服务器,然后从服务器下载图片到android客户端。需求下来......
  • Adobe AIR移动App的互相调用实现方式
    在使用AdobeAIR进行移动应用开发的时候,我们或许会有这样的需求:假如我们开发的是两个应用(A和B),同时安装到手机上,那么能否在A中呼叫B并传递参数呢(或者反过来B操作后,再把参数......
  • Ajax+WCF+MySQL实现数据库部署并调用
    ​         最近的数据库课程要求将MySQL数据库部署在服务器上,参考了大佬们的博客后,总结一下。    先放上参考的大佬们的博客。        【原......