当前位置: 首页 > news >正文

CMake官方教程4--使用表达式生成器

1. 使用表达式生成器产生警告

  • CMakeList.txt
cmake_minimum_required(VERSION 3.15)project(Tutorial VERSION 1.0)add_library(tutorial_compiler_flags INTERFACE)
target_compile_features(tutorial_compiler_flags INTERFACE cxx_std_11)set(gcc_like_cxx "$<COMPILE_LANG_AND_ID:CXX,ARMClang,AppleClang,Clang,GNU,LCC>")
set(msvc_cxx "$<COMPILE_LANG_AND_ID:CXX,MSVC>")target_compile_options(tutorial_compiler_flags  INTERFACE "$<${gcc_like_cxx}:$<BUILD_INTERFACE:-Wall;-Wextra;-Wshadow;-Wformat=2;-Wunused>>""$<${msvc_cxx}:$<BUILD_INTERFACE:-W3>>")configure_file(TutorialConfig.h.in TutorialConfig.h)add_subdirectory(MathFunctions)add_executable(Tutorial tutorial.cxx)target_link_libraries(Tutorial PUBLIC MathFunctions tutorial_compiler_flags)target_include_directories(Tutorial PUBLIC
"${PROJECT_BINARY_DIR}"
)
  • MathFunctions/CMakeList.txt

# create the MathFunctions library
add_library(MathFunctions MathFunctions.cxx)# state that anybody linking to us needs to include the current source dir
# to find MathFunctions.h, while we don't.
target_include_directories(MathFunctions
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
)# should we use our own math functions
option(USE_MYMATH "Use tutorial provided math implementation" ON)
if (USE_MYMATH)
target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH")# library that just does sqrt
add_library(SqrtLibrary STATICmysqrt.cxx
)# link SqrtLibrary to tutorial_compiler_flags
target_link_libraries(SqrtLibrary PUBLIC tutorial_compiler_flags)target_link_libraries(MathFunctions PRIVATE SqrtLibrary)
endif()# link MathFunctions to tutorial_compiler_flags
target_link_libraries(MathFunctions PUBLIC tutorial_compiler_flags)
http://www.lryc.cn/news/318608.html

相关文章:

  • git for windows
  • C++实验 面向对象编程
  • VC++ 设置网卡接口MTU大小
  • dpdk-19.11 对向量指令的使用情况分析
  • 使用CIP采集欧姆龙EtherNet/IP从入门到精通
  • 企业如何高效管理微信里的客户?
  • 怎么在windows系统上查看kylinos的md5、sha1、sha256值
  • Windows中在C#中使用Dapper和Mysql.Data库连接MySQL数据库
  • 大一专科,物联网专业,变态成长偏方!
  • MyBatis入门(JDBC规范,MyBatis,连接池,Lombok)【详解】
  • Vue3--数据和方法
  • 网络编程面试题
  • 移动端区分点击和长按
  • 虚拟环境的激活
  • 宏集案例 | 风电滑动轴承齿轮箱内多点温度采集与处理
  • linux 16进制写入
  • 代码随想录算法训练营第60天| Leetcode 84.柱状图中最大的矩形
  • 编写一个简单的cmakelist.txt
  • 基于YOLOv8/YOLOv7/YOLOv6/YOLOv5的零售柜商品检测软件(Python+PySide6界面+训练代码)
  • 数据库的学习
  • matlab去除图片上的噪声
  • C++超详细知识点(五):类的友元函数和友元类
  • SOC设计:关于reset的细节
  • 支小蜜AI校园防欺凌系统可以使用在宿舍吗?
  • 外卖平台订餐流程架构的实践
  • [AIGC] Spring Boot中的切面编程和实例演示
  • 各个类型和Json类型的相互转换
  • C语言:操作符详解(下)
  • 电商场景下 ES 搜索引擎的稳定性治理实践
  • jdk8与jdk17的区别。springboot2.x与springboot3.x的区别