首页 > 其他分享 >Tool-CMake-A Simple CMake Example

Tool-CMake-A Simple CMake Example

时间:2023-04-29 10:22:59浏览次数:47  
标签:CMake Simple Demo Tool library cxx directory Hello

Tool-CMake-A Simple CMake Example

https://cmake.org/examples/

There are three directories involved. The top level directory has two subdirectories called ./Demo and ./Hello. In the directory ./Hello, a library is built. In the directory ./Demo, an executable is built by linking to the library. A total of three CMakeLists.txt files are created: one for each directory.

./
./Demo
./Hello

top-level directory

./CMakeLists.txt

# CMakeLists files in this project can
# refer to the root source directory of the project as ${HELLO_SOURCE_DIR} and
# to the root binary directory of the project as ${HELLO_BINARY_DIR}.
cmake_minimum_required (VERSION 2.8.11)
project (HELLO)

# Recurse into the "Hello" and "Demo" subdirectories. This does not actually
# cause another cmake executable to run. The same process will walk through
# the project's entire directory structure.
add_subdirectory (Hello)
add_subdirectory (Demo)

subdirectory specified

./Hello

./Hello/CMakeLists.txt

# Create a library called "Hello" which includes the source file "hello.cxx".
# The extension is already found. Any number of sources could be listed here.
add_library (Hello hello.cxx)

# Make sure the compiler can find include files for our Hello library
# when other libraries or executables link to Hello
target_include_directories (Hello PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

./Demo

./Demo/CMakeLists.txt

# Add executable called "helloDemo" that is built from the source files
# "demo.cxx" and "demo_b.cxx". The extensions are automatically found.
add_executable (helloDemo demo.cxx demo_b.cxx)

# Link the executable to the Hello library. Since the Hello library has
# public include directories we will use those link directories when building
# helloDemo
target_link_libraries (helloDemo LINK_PUBLIC Hello)

标签:CMake,Simple,Demo,Tool,library,cxx,directory,Hello
From: https://www.cnblogs.com/yongchao/p/17363653.html

相关文章

  • CMakeLists---自定义变量-add_definitions()函数
    转载:https://blog.csdn.net/qq_35699473/article/details/115837708引言其实这个函数在安装一些库的时候,它的CMakeLists里面就有这样的函数。典型的就是opencv了。opencv安装时候有一些指令也是针对这个函数的,比如安装命令(随便搜索的):cmake ../opencv-3.4.1-DWITH_GTK_2......
  • CLion远程调试CMake项目
    cmake项目的远程调试。CLion安装在本地Windows系统,cmake项目部署在远程的Linux系统。配置远程调试可以比较方便地进行Linux端的cmake项目开发。点击setting。主要配置这三个:Toolchains点击+号,添加RemoteHost。然后先点击Credentials的设置按钮,添加远程连接。配置SSHCon......
  • The principle of uploading files with command line tools All In One
    TheprincipleofuploadingfileswithcommandlinetoolsAllInOne命令行工具文件上传的原理/TheprincipleofcommandlinetoolfileuploaddemospipgitCDNOSS{"name":"xui","version":"1.0.0","main&q......
  • NC50454 A Simple Problem with Integers
    题目链接题目题目描述给定数列\(a[1],a[2],\dots,a[n]\),你需要依次进行q个操作,操作有两类:1lrx:给定l,r,x,对于所有\(i\in[l,r]\),将a[i]加上x(换言之,将\(a[l],a[l+1],\dots,a[r]\)分别加上x);2lr:给定l,r,求\(\sum_{i=l}^ra[i]\)的值(换言之,求\(a[l]+a[l+1]+\dots+a......
  • Chrome devTools--节点监听
    节点监听dombreakpoints:子节点修改/属性修改/节点移除子节点修改适用场景:当鼠标移入下拉框时,下拉选项出现,想要选中下拉选项dom,修改下拉选项的dom时,却又消失了解决方案:选中body节点,监听dom字节点的修改,Breakon---》subtreemodifications,下拉选项触发时进入debugger 节......
  • 使用ethtool排查网卡速率问题
    今天去现场帮一个客户排查备份网络速率问题。用户期望是万兆的速率,但实际上目前只有千兆,因为目前上面运行着数据库,且数据量较大,千兆的备份网络速率不能满足用户备份数据库的时长要求。首先,确认备份网络是由两块网卡(eth3,eth4)做了bonding,起名为bondeth1。使用ethtool查看底层的et......
  • NC51100 A Simple Problem with Integers
    题目链接题目题目描述YouhaveNintegers,\(A_1,A_2,...,A_N\).Youneedtodealwithtwokindsofoperations.Onetypeofoperationistoaddsomegivennumbertoeachnumberinagiveninterval.Theotheristoaskforthesumofnumbersinagivenint......
  • hutool 日期转换
    DateTime转LocalDateDateTimeuseTimeDate=DateUtil.offsetMonth(date,12);LocalDateTimeuseTime=DateUtil.toLocalDateTime(useTimeDate);Java8日期时间API,新增了LocalDate、LocalDateTime、LocalTime等线程安全类:LocalDate:只有日期,诸如:2019-07-13LocalTime:只有时间,诸......
  • 解决VMware Workstation安装VMware Tools显示灰色的办法
    想在VMwareWorkstation中安装VMwareTools,方便文件的复制粘贴。但是如下图,总是灰色按照网上教程设置方法一:1.关闭虚拟机;2.在虚拟机设置分别设置CD/DVD、CD/DVD2和软盘为自动检测三个步骤;3.再重启虚拟机,灰色字即点亮。灰色没有点亮。 接着尝试了方法二:1.关闭虚......
  • Apk签名_自签名_命令行_四字节对齐_apktool_apksigner_keytool
    生成秘钥库keytool-genkey-alias别名-keyalgRSA-validity证书有效天数-keystore名称.keystore如需查看:keytool-list-keystore"antma.keystore"注意使用jarsigner签名为v1无法安装在新的设备上以下工具都在Androidstudio的SDK中apksigner签名代码:apksigner......