Basic Project

The most basic porject is an executable built from source code file.

CMakeLists.txt

cmake_minimum_required (version 2.6)
project (Tutorial)
add_executable(Tutorial tutorial.cxx)

tutorial.cxx

#include <stdio.h>

int main(int argc, char* argv[])
{
fprintf(stdout, "hello world");
return ;
}

Project files:

.
├── CMakeLists.txt
└── tutorial.cxx

Upper, lower, and mixed case cammonds are supported by CMake.

Adding a library

├── CMakeLists.txt
├── MathFunctions
│   ├── CMakeLists.txt
│   ├── MathFunctions.h
│   └── mysqrt.cxx
└── tutorial.cxx

In MathFunctions/CMakeLists.txt

add_library(MathFunctions mysqrt.cxx)

add_library: create a library, static or dynamic library.

In ./CMakeList.txt

cmake_minimum_required (VERSION 2.6)
project (Tutorial) # add the binary tree to the search path for include files
# so that we will find TutorialConfig.h
include_directories ("${PROJECT_BINARY_DIR}")
include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions") add_subdirectory (MathFunctions) # add the executable
add_executable (Tutorial tutorial.cxx)
target_link_libraries (Tutorial MathFunctions)

include_directories: to find the header files

add_executable: to create executable

target_link_libraries: add the library to the executable

Reference:

cmake tutorial, cmake.org

[cmake] Basic Tutorial的更多相关文章

  1. Ogre学习笔记Basic Tutorial 前四课总结

    转自:http://blog.csdn.net/yanonsoftware/article/details/1011195 OGRE Homepage:http://www.ogre3d.org/   ...

  2. Ogre1.8.1 Basic Tutorial 6 - The Ogre Startup Sequence

    原文地址:http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Basic+Tutorial+6&structure=Tutorials 1. ...

  3. [转]Open Data Protocol (OData) Basic Tutorial

    本文转自:http://www.odata.org/getting-started/basic-tutorial/ Basic Tutorial The Open Data Protocol (ODa ...

  4. [转载] CMake Official Tutorial——教程还是官方的好

    CMake官方教程传送门:https://cmake.org/cmake-tutorial/ 以下的内容跟官方教程基本一致,少数地方根据自己的测试有所改动: A Basic Starting Poin ...

  5. Mule ESB-Content-Based Routing Tutorial(2)

    承接 Mule ESB-Content-Based Routing Tutorial(1) 五.执行应用程序  完毕创建,配置.并保存你的新的应用程序,您就能够在嵌入Mule的server上执行(包含 ...

  6. Deep Learning Tutorial - Classifying MNIST digits using Logistic Regression

    Deep Learning Tutorial 由 Montreal大学的LISA实验室所作,基于Theano的深度学习材料.Theano是一个python库,使得写深度模型更容易些,也可以在GPU上训 ...

  7. Windows 下使用 MinGW 和 CMake 进行开发

    CMake 是个非常棒的项目管理工具,这已经是毋庸置疑的. 一些小工具需要在 win 下开发,所以今天探索使用 MinGW 和 CMake 在 win 下的搭配使用.简单做记录. MinGW 使用 Q ...

  8. 【转载】Ogre:Beginner Tutorial 1: SceneNode, Entity,和SceneManager 结构

    原文:Beginner Tutorial 1: SceneNode, Entity,和SceneManager 结构   先决条件 这个教程假设你有C++编程的基础并且可以配置并编译OGRE应用程序 ...

  9. ROS教程

    Learning ROS 学习ROS Depending on your learning style and preferences, you can take two approaches to ...

随机推荐

  1. tuple元组详解

    这次要讲的内容是:c++11中的tuple(元组).tuple看似简单,其实它是简约而不简单,可以说它是c++11中一个既简单又复杂的东东,关于它简单的一面是它很容易使用,复杂的一面是它内部隐藏了太多 ...

  2. 使用rosed编辑ROS中的文件

    使用 rosed rosed是rosbash 的一部分. 利用它可以直接通过package名来获取到待编辑的文件而无需指定该文件的存储路径了. 使用方法: $ rosed [package_name] ...

  3. launch edge 和 latch edge 延迟

    本文转自 http://www.cnblogs.com/inet2012/archive/2012/03/07/2384149.html launch edge和latch edge分别是指一条路径的 ...

  4. P1877 [HAOI2012]音量调节

    题目描述 一个吉他手准备参加一场演出.他不喜欢在演出时始终使用同一个音量,所以他决定每一首歌之前他都需要改变一次音量.在演出开始之前,他已经做好一个列表,里面写着每首歌开始之前他想要改变的音量是多少. ...

  5. HBase的简单java操作

    官方文档:http://hbase.apache.org/book.html java简单操作hbase的表 import org.apache.hadoop.conf.Configuration; ...

  6. Linux Shell常用技巧(二)

    七. grep家族:       1.  grep退出状态:    0: 表示成功:    1: 表示在所提供的文件无法找到匹配的pattern:    2: 表示参数中提供的文件不存在.    见如 ...

  7. centos配置静态ip地址

    1.输入以下命令: vim /etc/sysconfig/network-scripts/ifcfg-eth0 2.注释掉BOOTPROTO=dhcp 3.添加如下内容: ONBOOT=yes 表示开 ...

  8. Linux中两台主机配置互信关系

    服务名:sshd 客户端配置文件:/etc/ssh/ssh_config 服务端配置文件:/etc/ssh/sshd_config sshd服务需要重启才会生效 service sshd restar ...

  9. linux中服务环境的搭建

    一.Samba服务 samba服务的安装及配置: sudo apt-get install samba 二.配置: 1.创建一个需要共享的目录,并修改权限: lpf@ubuntu:~$ mkdir l ...

  10. Linux | GCC如何实现代码编译&&汇编&&链接过程

      正文: 每次我们程序员所写的 代码 是给程序员看的呢?还是给电脑看的?其实我们所写的代码只是我们程序员之间交流的一样特殊语言,电脑是看不懂的.那么我们如何实现人机交流呢?这就不得不请出我们我们今天 ...