A Note on CMake - 4 An example: ESESC
来源:互联网 发布:何处不是白鹿原 知乎 编辑:程序博客网 时间:2024/04/28 14:22
It may be bored to directly introduce the basic knowledge. Here I use an example from ESESC to show how to use CMake. ESECS is a fast multicore simulator using time-based sampling. We can download the source code from GitHub.
Now let us read CMakeLists.txt.
PROJECT(esesc)
set the name of this project as esesc
INCLUDE(“${esesc_SOURCE_DIR}/CMake.common”)
Load and run CMake code from ${esesc_SOURCE_DIR}/CMake.common
. Actually, I don’t know what is ${esesc_SOURCE_DIR}
but it should be the current folder or .
. CMake.common
sets the compiler and qemu options. Later, I will explain it.
SET(CMAKE_MODULE_PATH “${esesc_SOURCE_DIR}/conf/cmake-modules”)
set
Set a normal, cache, or environment variable to a given value. CMAKE_MODULE_PATH
a search path for CMake modules to be loaded by include
or find_package
commands before checking the default modules that come with CMake. By default it is empty, it is intended to be set by the project.
Thus, the above command means set a search path with ${esesc_SOURCE_DIR}/conf/cmake-modules
.
cmake_minimum_required(VERSION 2.7)
check cmake version
IF(ESESC_SYSTEM)
MESSAGE(” -DESESC_SYSTEM=1 Enable esesc/qemu full system simulation”)
ELSE(ESESC_SYSTEM)
MESSAGE(” -DESESC_SYSTEM=0 Enable esesc/qemu user mode simulation”)
ENDIF(ESESC_SYSTEM)
Now I still don’t know what is ESESC_SYSTEM, but we can use MESSAGE
to guess the meaning.
MESSAGE
Display a message to the user.
IF(ENABLE_LIVE)
MESSAGE(” -DESESC_LIVE=1 Enable esesc live sampling support”)
ELSE(ENABLE_LIVE)
MESSAGE(” -DESESC_LIVE=0 Disable esesc live compilation (default)”)
ENDIF(ENABLE_LIVE)
Similarly.
IF(ENABLE_LIVECRIU)
MESSAGE(” -DESESC_LIVECRIU=1 Enable CRIU checkpoints with live sampling support”)
ELSE(ENABLE_LIVECRIU)
MESSAGE(” -DESESC_LIVECRIU=0 Disable CRIU checkpoints with live compilation (default)”)
ENDIF(ENABLE_LIVECRIU)
Similarly.
MESSAGE(” -DCMAKE_HOST_MARCH=${CMAKE_HOST_MARCH} compilation”)
show message
Debug vs Release
IF(CMAKE_BUILD_TYPE MATCHES “Debug”)
MESSAGE(” -DCMAKE_BUILD_TYPE=Debug debug compilation options”)
ELSE(CMAKE_BUILD_TYPE MATCHES “Debug”)
MESSAGE(” -DCMAKE_BUILD_TYPE=Release release compilation options (default)”)
ENDIF(CMAKE_BUILD_TYPE MATCHES “Debug”)
ESESC supports two build types: debug and release. When run cmake, we may use cmake -DDEBUG=1 to activate debugging. Default setting is release.
FIND_PACKAGE(ZLIB)
FIND_PACKAGE(Threads)
FIND_PACKAGE(Curses)
FIND_PACKAGE(FLEX)
FIND_PACKAGE(BISON)
FIND_PACKAGE(X11)
FIND_PACKAGE(UUID)
FIND_PACKAGE(Pixman)
FIND_PACKAGE(Pango)
Find a series of external packages to help build.
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
set cmake policy
IF(
CMAKESYSTEMNAMEMATCHES“Linux”)INCLUDE(FindPkgConfig)PKGSEARCHMODULE(SDL2REQUIREDsdl2)FINDLIBRARY(RTLIBRARIESNAMESrt)ENDIF( {CMAKE_SYSTEM_NAME} MATCHES “Linux”)
SDL package is only used for the linux platform.
FIND_LIBRARY(MLIB_LIBRARIES NAMES m)
FIND_LIBRARY(UTIL_LIBRARIES NAMES util)
Find and load libraries. I’m not sure what MLIB_LIBRARIES and UTIL_LIBRARIES mean.
ADD_SUBDIRECTORY(misc/libsuc)
Add a subdirectory misc/libsuc
to the build. In this folder, there also exists a CMakeLists.txt.
The next codes are to try to set the external projects. I omit them.
include(ExternalProject)
ExternalProject_Add(…)
The ExternalProject_Add
function creates a custom target to drive download, update/patch, configure, build, install and test steps of an external project
set_target_properties(regression PROPERTIES EXCLUDE_FROM_ALL TRUE)
Set how to build. If the EXCLUDE_FROM_ALL
argument is provided then targets in the subdirectory will not be included in the ALL
target of the parent directory by default, and will be excluded from IDE project files.
IF(CMAKE_BUILD_TYPE MATCHES “Debug”)
SET(QEMU_EXTRA –enable-debug –cc=${CMAKE_C_COMPILER})
ELSE(CMAKE_BUILD_TYPE MATCHES “Debug”)
SET(QEMU_EXTRA –cc=${CMAKE_C_COMPILER})
ENDIF(CMAKE_BUILD_TYPE MATCHES “Debug”)IF(ESESC_SYSTEM)
SET(QEMU_TARGET –target-list=mips64el-softmmu)
ELSE(ESESC_SYSTEM)
IF(ESESC_N32)
SET(QEMU_TARGET –target-list=mipsn32el-linux-user)
ELSE(ESESC_N32)
SET(QEMU_TARGET –target-list=mips64el-linux-user)
ENDIF(ESESC_N32)
ENDIF(ESESC_SYSTEM)ADD_SUBDIRECTORY(emul/libemulint)
ADD_SUBDIRECTORY(emul/libqemuint)
#
ADD_SUBDIRECTORY(pwth/libpeq)
ADD_SUBDIRECTORY(pwth/libmcpat)
ADD_SUBDIRECTORY(pwth/libsesctherm)
ADD_SUBDIRECTORY(pwth/libpwrmodel)
#
ADD_SUBDIRECTORY(simu/libcore)
ADD_SUBDIRECTORY(simu/libsampler)
ADD_SUBDIRECTORY(simu/libmem)
ADD_SUBDIRECTORY(simu/libnet)
#
ADD_SUBDIRECTORY(main)
ADD_SUBDIRECTORY(tests/gtest-1.7.0)
ADD_SUBDIRECTORY(tests)
- A Note on CMake - 4 An example: ESESC
- A Note on CMake - 5 An example: ESESC Makefile
- A Note on CMake - 0 Introduction
- A Note on CMake - 2 Interactive Commands
- A Note on CMake - 3 Key words
- CMake - an example
- A note on Cmake - 1 Command-Line Tools
- nodejs : AN EXAMPLE on WEBSERVER
- A Note on Distributed Computing
- Note on a harvard course
- Spring v3.0.2 Learning Note 2 - A Sample Example
- A beginner's note on berkeley db
- Note on A Simple Regular Expression Matcher
- a note on distributed computing 笔记摘录
- A Note On Practice And Persistence
- A Note on Practice and Persistence
- 《A Tutorial on Automated Text Categorisation》NOTE
- A Note on GEM5 - 0 Installation
- 会做饭,擅长烹饪,会给你的工作生活带来怎样的不同?
- [LeetCode 16] 3Sum Closest
- Tez安装
- 磁盘挂载与权限
- ADB Shell学习
- A Note on CMake - 4 An example: ESESC
- iOS的三维透视投影
- JVM -XX:MaxDirectMemorySize
- Caused by: com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.
- 资深首席架构师眼中的架构应该是怎样的?
- 使用ApplicationContext启动standard模式的Activity报错原因解析
- HDU3613 Best Reward - exkmp/Manacher
- PI3体验之无线网AP模式设定及热点分享
- 读书笔记-现代操作系统-6死锁-6.5死锁避免