[cmake] Basic Tutorial

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 0;
}

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

原文地址:https://www.cnblogs.com/TonyYPZhang/p/8453711.html

时间: 2024-10-08 10:14:14

[cmake] Basic Tutorial的相关文章

[转]Open Data Protocol (OData) Basic Tutorial

本文转自:http://www.odata.org/getting-started/basic-tutorial/ Basic Tutorial The Open Data Protocol (OData) is a data access protocol built on core protocols like HTTP and commonly accepted methodologies like REST for the web. There are various kinds of

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

CMake官方教程传送门:https://cmake.org/cmake-tutorial/ 以下的内容跟官方教程基本一致,少数地方根据自己的测试有所改动: A Basic Starting Point (Step1) The most basic project is an executable built from source code files. For simple projects a two line CMakeLists.txt file is all that is requ

000 Python Basic Tutorial -- Home

Python Tutorial Python is a general-purpose interpreted, interactive, object-oriented and high-level programming language. Python was created by Guido van Rossum in the late eighties and early nineties. Like Perl, Python source code is also now avail

Mule ESB-Content-Based Routing Tutorial(2)

承接 Mule ESB-Content-Based Routing Tutorial(1) 五.运行应用程序 完成创建,配置,并保存你的新的应用程序,您就可以在嵌入Mule的服务器上运行(包括在Mule Studio中,作为捆绑下载的一部分). 1.在Package Explorer窗格中,右键单击Basic Tutorial.mflow文件,然后选择Run As>Mule Application. (如果您还没有保存,Mule会提示您现在保存. 2.Mule会立即显示运行进度齿轮,开始您的应用

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

原文:Beginner Tutorial 1: SceneNode, Entity,和SceneManager 结构 先决条件 这个教程假设你有C++编程的基础并且可以配置并编译OGRE应用程序 (如果你在配置环境方面有问题,请看OGRE + MinGW + Code::Blocks环境的搭建). 除了配置环境之外,你不需要有任何关于OGRE的知识. 介绍 在这个教程中,我会介绍给你OGRE中最基本的结构: SceneManager, SceneNode, 还有Entity 对象.我们不会涉及大

Open vSwitch Advanced Features Tutorial

Open vSwitch Advanced Features Tutorial ======================================= Many tutorials cover the basics of OpenFlow. This is not such a tutorial. Rather, a knowledge of the basics of OpenFlow is a prerequisite. If you do not already understan

Deep Learning Tutorial - Classifying MNIST digits using Logistic Regression

Deep Learning Tutorial 由 Montreal大学的LISA实验室所作,基于Theano的深度学习材料.Theano是一个python库,使得写深度模型更容易些,也可以在GPU上训练深度模型.所以首先得了解python和numpy.其次,阅读Theano basic tutorial. Deep Learning Tutorial 包括: 监督学习算法: Logistic Regression - using Theano for something simple Multi

scikit tutorial note 1 笔记识别 svm

process http://scikit-learn.org/dev/tutorial/basic/tutorial.html code http://scikit-learn.org/dev/auto_examples/classification/plot_digits_classification.html#example-classification-plot-digits-classification-py 基础知识 svm

scikit-learn Quick Start

Time:2017/02/24  21:50  at UTSZ Environment: pyCharm, python2.7 一般来讲,学习是指利用一些已知的样例数据来预测未知数据的属性. 1. 我们可以将学习问题分为如下的类别: 监督学习:样例数据有自己的标签. 分类:要预测的值是离散的 回归:要预测的值是连续的 无监督学习:样例数据没有自己的标签. 2. 机器学习的常用步骤(python): 导入要用的包(sklearn) 加载训练数据 确定要用的训练算法(原例是用的svm) 训练,算法内