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. java中的对象和类

    1.类:类是一个模板,它描述一类对象的行为和状态. 一个类可以包含以下类型变量: 局部变量:在方法.构造方法或者语句块中定义的变量被称为局部变量.变量声明和初始化都是在方法中,方法结束后,变量就会自动 ...

  2. docker - kubernetes 网络(转)+ 架构图

    1.host网络 连接到 host 网络的容器共享 Docker host 的网络栈,容器的网络配置与 host 完全一样.可以通过--network=host指定使用 host 网络.docker ...

  3. 轻量级IOC容器:Ninject

    Ninject是一个快如闪电.超轻量级的基于.Net平台的依赖注入框架.它能够帮助你把应用程序分离成一个个松耦合.高内聚的模块,然后用一种灵活的方式组装起来.通过使用Ninject配套你的软件架构,那 ...

  4. N项阶乘累加求和新算法

    pdf原版链接

  5. #leetcode刷题之路34-在排序数组中查找元素的第一个和最后一个位置

    给定一个按照升序排列的整数数组 nums,和一个目标值 target.找出给定目标值在数组中的开始位置和结束位置.你的算法时间复杂度必须是 O(log n) 级别.如果数组中不存在目标值,返回 [-1 ...

  6. 记录一下安装 mysql 的踩坑之路

    坑点: 1.旧的mysql没有删除干净.在安装mysql的时候,没有注意到,在输入 “mysqld install” 指令时跳出来 exits,存在于另一个文件夹之中,这影响了后来的很多操作,包括ro ...

  7. html移动应用 input 标签 清除按钮功能如何实现(不触发键盘)

    有个需求是:输入框有文本的时候就显示清除按钮,没有文本则隐藏清除按钮,点击清除按钮不能影响键盘弹出的状态. 网上有css实现自动显示和隐藏清除按钮的方案,但是考虑到兼容性,我们还是使用js来实现. c ...

  8. Delphi泛型动态数组的扩展--转贴

    此文章转载于http://www.raysoftware.cn/?p=278&tdsourcetag=s_pcqq_aiomsg的博客 从Delphi支持泛型的第一天起就有了一种新的动态数组类 ...

  9. 如何防止网页被植入广告,内容被监控-HTTPS

    前几天一朋友说访问网站页面底部怎么出现小广告了呢,内容有点不雅,朋友截图发给我,调侃我说怎么放这种广告,我一听纳闷,网站运行伊始,从来没有投放过任何广告,更别说不雅广告了. 最近还遇到一个问题就是,网 ...

  10. 4 jdngo vue-rotue

    . 执行linux命令 与mac命令   git base 3 初始化操作  页面加载完成,发起请求  window.onload