CMake Intro - CMakeLists.txt
Notes: directory structure: cmake, cmake/Tutorial, cmake/Tutorial/MathLibs
1. File lists in cmake/Tutorial
CMakeLists.txt
TutorialConfig.h.in
tutorial.cxx
2. File lists in cmake/Tutorial/MathLibs
CMakeLists.txt
MathLibs.h
mysqrt.cxx
3. cmake/Tutorial/CMakeLists.txt
cmake_minimum_required (VERSION 2.6)
project (Tutorial)
# The version number.
set (Tutorial_VERSION_MAJOR 1)
set (Tutorial_VERSION_MINOR 0)
set(CMAKE_BUILD_TYPE DEBUG)
set(CMAKE_C_FLAGS "-O0 -ggdb")
set(CMAKE_C_FLAGS_DEBUG "-O0 -ggdb")
set(CMAKE_C_FLAGS_RELEASE "-O3")
set(CMAKE_CXX_FLAGS "-O0 -ggdb")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -ggdb")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
# configure a header file to pass some of the CMake settings
# to the source code
configure_file (
"${PROJECT_SOURCE_DIR}/TutorialConfig.h.in"
"${PROJECT_SOURCE_DIR}/TutorialConfig.h"
)
# add the binary tree to the search path for include files
# so that we will find TutorialConfig.h
include_directories("${PROJECT_SOURCE_DIR}")
# should we use our own math functions?
option (USE_MYMATH
"Use tutorial provided math implementation" ON)
# add the MathFunctions library?
#
if (USE_MYMATH)
include_directories ("${PROJECT_SOURCE_DIR}/MathLibs")
add_subdirectory (MathLibs)
set (EXTRA_LIBS ${EXTRA_LIBS} MathLibs)
endif (USE_MYMATH)
# add the executable
add_executable (Tutorial.x tutorial.cxx)
target_link_libraries (Tutorial.x ${EXTRA_LIBS})
4. cmake/Tutorial/MathLibs/CMakeLists.txt
add_library(MathLibs mysqrt.cxx)
5. Configure and Compile
do so in cmake directory as the followings
cmake -DUSE_MYMATH=on Tutorial
make
6. others
add_library (core
OBJECT ${SOURCES})
add_library
(static STATIC
$<TARGET_OBJECTS:core>)
add_library
(shared SHARED
$<TARGET_OBJECTS:core>)
The above will build static and shared library from the same set of object files.
This improves compilation time considerably as source files will be compiled
only once and used in multiple targets.
CMake Intro - CMakeLists.txt的更多相关文章
- CMake之CMakeLists.txt编写入门
自定义变量 主要有隐式定义和显式定义两种. 隐式定义的一个例子是PROJECT指令,它会隐式的定义< projectname >_BINARY_DIR和< projectname & ...
- cmake 学习-cmakelists.txt
#设置库的路径,电脑里有qt4以及qt5,使用qt5时 设置qt5的环境变量(路径). set(CMAKE_PREFIX_PATH $ENV{QTDIR}) #设定工程名称 Project(prona ...
- Cmake知识----编写CMakeLists.txt文件编译C/C++程序
1.CMake编译原理 CMake是一种跨平台编译工具,比make更为高级,使用起来要方便得多.CMake主要是编写CMakeLists.txt文件,然后用cmake命令将CMakeLists.txt ...
- [CMAKE] 详解CMakeLists.txt文件
[快速查询]https://cmake.org/cmake/help/v2.8.8/cmake.html#section_Commands 1 CMake简介 CMake是跨平台编译工具,比make更 ...
- Cmake知识----编写CMakeLists.txt文件编译C/C++程序(转)
1.CMake编译原理 CMake是一种跨平台编译工具,比make更为高级,使用起来要方便得多.CMake主要是编写CMakeLists.txt文件,然后用cmake命令将CMakeLists.txt ...
- CMakeLists.txt使用
背景:C++代码在编译的过程中需要进行文件的包含,该文主要介绍CMakeLists.txt相关语法 CMake之CMakeLists.txt编写入门
- [forward] cmake, CMakeLists.txt梳理
cmake intro 原文请见 cmake使用总结(转)-工程主目录CMakeList文件编写 在 Linux 下进行开发很多人选择编写 makefile 文件进行项目环境搭建,而makefile ...
- CMAKE 生成VS2008静态库工程 与 CMAKE使用,CMakeLists.txt编写总结
cmake -G"Visual Studio 9 2008 Win64" 以上命令得用cd命令切换到顶层CMakeLists.txt的当前目录,才能生效 以下是CMakeLists ...
- make Makefile 与 cmake CMakeLists.txt
make Makefile 与 cmake CMakeLists.txt 大家都知道,写程序大体步骤为: 1.用编辑器编写源代码,如.c文件. 2.用编译器编译代码生成目标文件,如.o. 3.用链接器 ...
随机推荐
- No http handler was found for request type 'GET'
asp.net 运用统计图表的时候,在本地运行,没有问题,发布到服务器上的IIS后,就报这个错误,具体错误 看图 这个图片真恶心,网上找了下,资料不多,但是还是有个能真正解决问题的, 解决方法是,在w ...
- WCF技术剖析之十九:深度剖析消息编码(Encoding)实现(下篇)
原文:WCF技术剖析之十九:深度剖析消息编码(Encoding)实现(下篇) [爱心链接:拯救一个25岁身患急性白血病的女孩[内有苏州电视台经济频道<天天山海经>为此录制的节目视频(苏州话 ...
- perl encode_utf8必须用在utf8环境
[root@wx03 mojo]# cat test.pl use Mojolicious::Lite; use JSON qw/encode_json decode_json/; use Encod ...
- python 读取图片的尺寸、分辨率
#需要安装PIL模块 #encoding=gbk#--------------------------------------------------------------------------- ...
- ASP.NET成员资格与角色管理配置内容
Web.config中进行配置 以便于连接数据库,使用微软提供的Membership类.·····等 <?xml version="1.0" encoding=" ...
- Spring MVC 中采用注解方式 Action中跳转到另一个Action的写法
Spring MVC 中采用注解方式 Action中跳转到另一个Action的写法 在Action中方法的返回值都是字符串行,一般情况是返回某个JSP,如: return "xx" ...
- [置顶] gis海量资源网盘提供VIP账号无广告高速下载 (更新更多资源)
资源网盘下载地址:http://laoheitan.bego.cc/ 城通网盘 vip帐号共享 省去 烦人的 广告 多任务同时下载 独乐乐 不如众乐乐 好人 勿改密码. 获取到 vip下载连接后 请 ...
- 十分钟开发一个调用Activity的PhoneGap插件
在HybridApp开发中,非常多业务我们是没有办法通过HTML5+js实现的,比方调用第三方的包括Activity的jar包,一些必须使用原生代码才干实现的功能,比方复杂的UI的效果,调用通讯相关的 ...
- cPickle.so:: PyUnicodeUCS2_DecodeUTF8
cPickle.so:: PyUnicodeUCS2_DecodeUTF8错误 Python编译的参数,和Python module(mod_wsgi, pymodwsgi)编译参数不一,导致一些un ...
- 基于visual Studio2013解决面试题之0401非递归遍历二叉树
题目