# t2/ CMakeLists.txt

cmake_minimum_required(VERSION 2.8)

#1
#PROJECT (HELLO)
#SET(SRC_LIST main.c)
#MESSAGE(STATUS "This is BINARY dir" ${HELLO_BINARY_DIR})
#MESSAGE(STATUS "This is SOURCE dir" ${HELLO_SOURCE_DIR})
#ADD_EXECUTABLE(hello ${SRC_LIST}) #2
#PROJECT(HELLO)
#ADD_EXECUTABLE(hello main.c) PROJECT(HELLO)
ADD_SUBDIRECTORY(src bin)
//main.c

#include <stdio.h>
int main()
{
printf("Hello World from t1 Main!\n "); return ;
}
#  t2/src/CMakeLists.txt

ADD_EXECUTABLE(hello main.c)
u@u160406:~/learn_Cmake/cmake/t2$ ls
build CMakeLists.txt src
u@u160406:~/learn_Cmake/cmake/t2$ tree
.
├── build
├── CMakeLists.txt
└── src
├── CMakeLists.txt
└── main.c directories, files
u@u160406:~/learn_Cmake/cmake/t2$ cd build
u@u160406:~/learn_Cmake/cmake/t2/build$ cmake ..
-- The C compiler identification is GNU 5.4.
-- The CXX compiler identification is GNU 5.4.
-- 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
-- Configuring done
-- Generating done
-- Build files have been written to: /home/u/learn_Cmake/cmake/t2/build
u@u160406:~/learn_Cmake/cmake/t2/build$ make
Scanning dependencies of target hello
[ %] Building C object bin/CMakeFiles/hello.dir/main.c.o
[%] Linking C executable hello
[%] Built target hello
u@u160406:~/learn_Cmake/cmake/t2/build$ cd bin
u@u160406:~/learn_Cmake/cmake/t2/build/bin$ ./hello
Hello World from t1 Main!
u@u160406:~/learn_Cmake/cmake/t2/build/bin$

最新文章

  1. 用HTML5 CANVAS做自定义路径的动态效果图片!
  2. HDU5322 Hope(DP + CDQ分治 + NTT)
  3. 安装恢复Windows10各种坑
  4. GIT(分布式版本控制系统)
  5. Effective C++ 1.让自己习惯C++
  6. windows条件下,Ping加上时间戳,并保存到文件,适用于测试网络
  7. PHP也20岁了
  8. u-boot移植为tiny6410步骤
  9. android中GridView关于间距的属性值介绍
  10. 四校训练 warm up 14
  11. C++调用DLL有两种方法——静态调用和动态调用
  12. 分享5个主流的HTML5开发工具
  13. myeclipse连接hadoop集群编程及问题解决
  14. mybatis系列笔记(1)---mybatis入门
  15. [SinGuLaRiTy] 树形存储结构阶段性测试
  16. 『Asp.Net 组件』Asp.Net 服务器组件 内嵌图片:自己的图片控件
  17. Jquery 在子页面上设置父页面元素的值
  18. 使用Java面向对象单词必备
  19. TopCoder SRM502 Div1 500 贪心 01背包
  20. 为什么用VUE,而不用Jquery了?

热门文章

  1. http响应时长分析
  2. 对spring的简单了解
  3. gitlab 重置密码
  4. SSM-CRUD
  5. MySQL索引工作原理
  6. Apache Rewrite 规则详解知识大全
  7. 数据结构-链式栈c++
  8. go语言实现链式栈
  9. java.lang.AbstractMethodError: null
  10. SQL Server元数据查询