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. Kafka设计解析(十四)Kafka producer介绍

    转载自 huxihx,原文链接 Kafka producer介绍 Kafka 0.9版本正式使用Java版本的producer替换了原Scala版本的producer.本文着重讨论新版本produce ...

  2. KMP算法之从懵逼到入门

    写本文的目的: 1.加深自己的理解,以便自己日后复习 2.给看到此文的人一点启发 KMP算法看懂了就觉得特别简单,思路也好理解,但是看不懂之前,查各种资料看大佬的博客,都很懵逼...... 1.  算 ...

  3. Apache Shiro(一)-登录认证和权限管理初识

    What is Apache Shiro? Apache Shiro是一个功能强大.灵活的,开源的安全框架.它可以干净利落地处理身份验证.授权.企业会话管理和加密. Apache Shiro的首要目标 ...

  4. oracle中的条件语句

    oracle中case when then及decode用法 一.case … when … then 语法:  – 写法一:  case(条件)  when 值1 then 返回值1  when 值 ...

  5. virtualbox虚拟机与物理机windows文件共享

    必须安装virtualbox的增强功能包(VBoxGuestAdditions) 1.打开Linux系统,选择 设备->安装增强增强功能 2.等待其自动安装,当出现press return to ...

  6. PHP分行打印数组-php输出数组方法大全

    我们都知道php有两种方式可以打印数组 $arr = array( "a"=>"orange", "b"=>"bana ...

  7. C++编写DLL动态链接库的步骤与实现方法

    原文:http://www.jb51.net/article/90111.htm 本文实例讲述了C++编写DLL动态链接库的步骤与实现方法.分享给大家供大家参考,具体如下: 在写C++程序时,时常需要 ...

  8. 如何查看PostgreSQL的checkpoint 活动

    磨砺技术珠矶,践行数据之道,追求卓越价值 回到上一级页面:PostgreSQL基础知识与基本操作索引页    回到顶级页面:PostgreSQL索引页 作者:高健@博客园 luckyjackgao@g ...

  9. 【LG3722】[HNOI2017]影魔

    [LG3722][HNOI2017]影魔 题面 洛谷 题解 先使用单调栈求出\(i\)左边第一个比\(i\)大的位置\(lp_i\),和右边第一个比\(i\)大的位置\(rp_i\). 考虑\(i\) ...

  10. IDEA/Git 设置多个push远程仓库或者同时提交多个push仓库

    注:写在最上面的这个提交地址将会是唯一的pull地址 具体解决办法: 在隐藏文件.git 下有个config文件,打开,在最后一行添加以下信息 [remote "all"] url ...