CMake高级用法实例分析(学习paddle官方的CMakeLists)

cmake基础学习教程
https://juejin.cn/post/6844903557183832078

官方完整CMakeLists

cmake_minimum_required(VERSION 3.0)
project(PaddleObjectDetector CXX C)option(WITH_MKL        "Compile demo with MKL/OpenBlas support,defaultuseMKL."          ON)
option(WITH_GPU        "Compile demo with GPU/CPU, default use CPU."                    ON)
option(WITH_TENSORRT   "Compile demo with TensorRT."                                    OFF)option(WITH_KEYPOINT        "Whether to Compile KeyPoint detector"                    OFF)
option(WITH_MOT       "Whether to Compile MOT detector" OFF)SET(PADDLE_DIR "" CACHE PATH "Location of libraries")
SET(PADDLE_LIB_NAME "" CACHE STRING "libpaddle_inference")
SET(OPENCV_DIR "" CACHE PATH "Location of libraries")
SET(CUDA_LIB "" CACHE PATH "Location of libraries")
SET(CUDNN_LIB "" CACHE PATH "Location of libraries")
SET(TENSORRT_INC_DIR "" CACHE PATH "Compile demo with TensorRT")
SET(TENSORRT_LIB_DIR "" CACHE PATH "Compile demo with TensorRT")include(cmake/yaml-cpp.cmake)include_directories("${CMAKE_SOURCE_DIR}/")
include_directories("${CMAKE_CURRENT_BINARY_DIR}/ext/yaml-cpp/src/ext-yaml-cpp/include")
link_directories("${CMAKE_CURRENT_BINARY_DIR}/ext/yaml-cpp/lib")if (WITH_KEYPOINT)set(SRCS src/main_keypoint.cc src/preprocess_op.cc src/object_detector.cc src/picodet_postprocess.cc src/utils.cc src/keypoint_detector.cc src/keypoint_postprocess.cc)
elseif (WITH_MOT)set(SRCS src/main_jde.cc src/preprocess_op.cc src/object_detector.cc src/jde_detector.cc src/tracker.cc src/trajectory.cc src/lapjv.cpp src/picodet_postprocess.cc src/utils.cc)
else ()set(SRCS src/main.cc src/preprocess_op.cc src/object_detector.cc src/picodet_postprocess.cc src/utils.cc)
endif()#这个宏定义的意思是如果这些flag中有MD即动态版本,都要替换成静态版本
macro(safe_set_static_flag)foreach(flag_varCMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASECMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)if(${flag_var} MATCHES "/MD")string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")endif(${flag_var} MATCHES "/MD")endforeach(flag_var)
endmacro()if (WITH_MKL)ADD_DEFINITIONS(-DUSE_MKL)
endif()if (NOT DEFINED PADDLE_DIR OR ${PADDLE_DIR} STREQUAL "")message(FATAL_ERROR "please set PADDLE_DIR with -DPADDLE_DIR=/path/paddle_influence_dir")
endif()
message("PADDLE_DIR IS:" ${PADDLE_DIR})if (NOT DEFINED OPENCV_DIR OR ${OPENCV_DIR} STREQUAL "")message(FATAL_ERROR "please set OPENCV_DIR with -DOPENCV_DIR=/path/opencv")
endif()include_directories("${CMAKE_SOURCE_DIR}/")
include_directories("${PADDLE_DIR}/")
include_directories("${PADDLE_DIR}/third_party/install/protobuf/include")
include_directories("${PADDLE_DIR}/third_party/install/glog/include")
include_directories("${PADDLE_DIR}/third_party/install/gflags/include")
include_directories("${PADDLE_DIR}/third_party/install/xxhash/include")
if (EXISTS "${PADDLE_DIR}/third_party/install/snappy/include")include_directories("${PADDLE_DIR}/third_party/install/snappy/include")
endif()
if(EXISTS "${PADDLE_DIR}/third_party/install/snappystream/include")include_directories("${PADDLE_DIR}/third_party/install/snappystream/include")
endif()
include_directories("${PADDLE_DIR}/third_party/boost")
include_directories("${PADDLE_DIR}/third_party/eigen3")if (EXISTS "${PADDLE_DIR}/third_party/install/snappy/lib")link_directories("${PADDLE_DIR}/third_party/install/snappy/lib")
endif()
if(EXISTS "${PADDLE_DIR}/third_party/install/snappystream/lib")link_directories("${PADDLE_DIR}/third_party/install/snappystream/lib")
endif()link_directories("${PADDLE_DIR}/third_party/install/protobuf/lib")
link_directories("${PADDLE_DIR}/third_party/install/glog/lib")
link_directories("${PADDLE_DIR}/third_party/install/gflags/lib")
link_directories("${PADDLE_DIR}/third_party/install/xxhash/lib")
link_directories("${PADDLE_DIR}/third_party/install/paddle2onnx/lib")
link_directories("${PADDLE_DIR}/third_party/install/onnxruntime/lib")
link_directories("${PADDLE_DIR}/paddle/lib/")
link_directories("${CMAKE_CURRENT_BINARY_DIR}")if (WIN32)include_directories("${PADDLE_DIR}/paddle/fluid/inference")include_directories("${PADDLE_DIR}/paddle/include")link_directories("${PADDLE_DIR}/paddle/fluid/inference")find_package(OpenCV REQUIRED PATHS ${OPENCV_DIR}/build/ NO_DEFAULT_PATH)else ()find_package(OpenCV REQUIRED PATHS ${OPENCV_DIR}/share/OpenCV NO_DEFAULT_PATH)include_directories("${PADDLE_DIR}/paddle/include")link_directories("${PADDLE_DIR}/paddle/lib")
endif ()
include_directories(${OpenCV_INCLUDE_DIRS})if (WIN32)add_definitions("/DGOOGLE_GLOG_DLL_DECL=")set(CMAKE_C_FLAGS_DEBUG   "${CMAKE_C_FLAGS_DEBUG} /bigobj /MTd")set(CMAKE_C_FLAGS_RELEASE  "${CMAKE_C_FLAGS_RELEASE} /bigobj /MT")set(CMAKE_CXX_FLAGS_DEBUG  "${CMAKE_CXX_FLAGS_DEBUG} /bigobj /MTd")set(CMAKE_CXX_FLAGS_RELEASE   "${CMAKE_CXX_FLAGS_RELEASE} /bigobj /MT")
else()set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -o2 -fopenmp -std=c++11")set(CMAKE_STATIC_LIBRARY_PREFIX "")
endif()# TODO let users define cuda lib path
if (WITH_GPU)if (NOT DEFINED CUDA_LIB OR ${CUDA_LIB} STREQUAL "")message(FATAL_ERROR "please set CUDA_LIB with -DCUDA_LIB=/path/cuda-8.0/lib64")endif()if (NOT WIN32)if (NOT DEFINED CUDNN_LIB)message(FATAL_ERROR "please set CUDNN_LIB with -DCUDNN_LIB=/path/cudnn_v7.4/cuda/lib64")endif()endif(NOT WIN32)
endif()if (NOT WIN32)if (WITH_TENSORRT AND WITH_GPU)include_directories("${TENSORRT_INC_DIR}/")link_directories("${TENSORRT_LIB_DIR}/")endif()
endif(NOT WIN32)if (NOT WIN32)set(NGRAPH_PATH "${PADDLE_DIR}/third_party/install/ngraph")if(EXISTS ${NGRAPH_PATH})include(GNUInstallDirs)include_directories("${NGRAPH_PATH}/include")link_directories("${NGRAPH_PATH}/${CMAKE_INSTALL_LIBDIR}")set(NGRAPH_LIB ${NGRAPH_PATH}/${CMAKE_INSTALL_LIBDIR}/libngraph${CMAKE_SHARED_LIBRARY_SUFFIX})endif()
endif()if(WITH_MKL)include_directories("${PADDLE_DIR}/third_party/install/mklml/include")if (WIN32)set(MATH_LIB ${PADDLE_DIR}/third_party/install/mklml/lib/mklml.lib${PADDLE_DIR}/third_party/install/mklml/lib/libiomp5md.lib)else ()set(MATH_LIB ${PADDLE_DIR}/third_party/install/mklml/lib/libmklml_intel${CMAKE_SHARED_LIBRARY_SUFFIX}${PADDLE_DIR}/third_party/install/mklml/lib/libiomp5${CMAKE_SHARED_LIBRARY_SUFFIX})execute_process(COMMAND cp -r ${PADDLE_DIR}/third_party/install/mklml/lib/libmklml_intel${CMAKE_SHARED_LIBRARY_SUFFIX} /usr/lib)endif ()set(MKLDNN_PATH "${PADDLE_DIR}/third_party/install/mkldnn")if(EXISTS ${MKLDNN_PATH})include_directories("${MKLDNN_PATH}/include")if (WIN32)set(MKLDNN_LIB ${MKLDNN_PATH}/lib/mkldnn.lib)else ()set(MKLDNN_LIB ${MKLDNN_PATH}/lib/libmkldnn.so.0)endif ()endif()
else()set(MATH_LIB ${PADDLE_DIR}/third_party/install/openblas/lib/libopenblas${CMAKE_STATIC_LIBRARY_SUFFIX})
endif()if (WIN32)if(EXISTS "${PADDLE_DIR}/paddle/fluid/inference/${PADDLE_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}")set(DEPS${PADDLE_DIR}/paddle/fluid/inference/${PADDLE_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX})else()set(DEPS${PADDLE_DIR}/paddle/lib/${PADDLE_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX})endif()
endif()if (WIN32)set(DEPS ${PADDLE_DIR}/paddle/lib/${PADDLE_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX})
else()set(DEPS ${PADDLE_DIR}/paddle/lib/${PADDLE_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX})
endif()message("PADDLE_LIB_NAME:" ${PADDLE_LIB_NAME})
message("DEPS:" $DEPS)if (NOT WIN32)set(DEPS ${DEPS}${MATH_LIB} ${MKLDNN_LIB}glog gflags protobuf z xxhash yaml-cpp)if(EXISTS "${PADDLE_DIR}/third_party/install/snappystream/lib")set(DEPS ${DEPS} snappystream)endif()if (EXISTS "${PADDLE_DIR}/third_party/install/snappy/lib")set(DEPS ${DEPS} snappy)endif()
else()set(DEPS ${DEPS}${MATH_LIB} ${MKLDNN_LIB}glog gflags_static libprotobuf xxhash libyaml-cppmt)set(DEPS ${DEPS} libcmt shlwapi)if (EXISTS "${PADDLE_DIR}/third_party/install/snappy/lib")set(DEPS ${DEPS} snappy)endif()if(EXISTS "${PADDLE_DIR}/third_party/install/snappystream/lib")set(DEPS ${DEPS} snappystream)endif()
endif(NOT WIN32)if(WITH_GPU)if(NOT WIN32)if (WITH_TENSORRT)set(DEPS ${DEPS} ${TENSORRT_LIB_DIR}/libnvinfer${CMAKE_SHARED_LIBRARY_SUFFIX})set(DEPS ${DEPS} ${TENSORRT_LIB_DIR}/libnvinfer_plugin${CMAKE_SHARED_LIBRARY_SUFFIX})endif()set(DEPS ${DEPS} ${CUDA_LIB}/libcudart${CMAKE_SHARED_LIBRARY_SUFFIX})set(DEPS ${DEPS} ${CUDNN_LIB}/libcudnn${CMAKE_SHARED_LIBRARY_SUFFIX})else()set(DEPS ${DEPS} ${CUDA_LIB}/cudart${CMAKE_STATIC_LIBRARY_SUFFIX} )set(DEPS ${DEPS} ${CUDA_LIB}/cublas${CMAKE_STATIC_LIBRARY_SUFFIX} )set(DEPS ${DEPS} ${CUDNN_LIB}/cudnn${CMAKE_STATIC_LIBRARY_SUFFIX})endif()
endif()if (NOT WIN32)set(EXTERNAL_LIB "-ldl -lrt -lgomp -lz -lm -lpthread")set(DEPS ${DEPS} ${EXTERNAL_LIB})
endif()set(DEPS ${DEPS} ${OpenCV_LIBS})
add_executable(main ${SRCS})
ADD_DEPENDENCIES(main ext-yaml-cpp)
message("DEPS:" $DEPS)
target_link_libraries(main ${DEPS})if (WIN32 AND WITH_MKL)add_custom_command(TARGET main POST_BUILDCOMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_DIR}/third_party/install/mklml/lib/mklml.dll ./mklml.dllCOMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_DIR}/third_party/install/mklml/lib/libiomp5md.dll ./libiomp5md.dllCOMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_DIR}/third_party/install/mkldnn/lib/mkldnn.dll ./mkldnn.dllCOMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_DIR}/third_party/install/mklml/lib/mklml.dll ./release/mklml.dllCOMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_DIR}/third_party/install/mklml/lib/libiomp5md.dll ./release/libiomp5md.dllCOMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_DIR}/third_party/install/mkldnn/lib/mkldnn.dll ./release/mkldnn.dllCOMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_DIR}/paddle/lib/${PADDLE_LIB_NAME}.dll ./release/${PADDLE_LIB_NAME}.dll)
endif()if (WIN32 AND NOT WITH_MKL)add_custom_command(TARGET main POST_BUILDCOMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_DIR}/third_party/install/openblas/lib/openblas.dll ./openblas.dllCOMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_DIR}/third_party/install/openblas/lib/openblas.dll ./release/openblas.dll)
endif()if (WIN32)add_custom_command(TARGET main POST_BUILDCOMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_DIR}/third_party/install/onnxruntime/lib/onnxruntime.dll ./onnxruntime.dllCOMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_DIR}/third_party/install/paddle2onnx/lib/paddle2onnx.dll ./paddle2onnx.dllCOMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_DIR}/third_party/install/onnxruntime/lib/onnxruntime.dll ./release/onnxruntime.dllCOMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_DIR}/third_party/install/paddle2onnx/lib/paddle2onnx.dll ./release/paddle2onnx.dllCOMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_DIR}/paddle/lib/${PADDLE_LIB_NAME}.dll ./release/${PADDLE_LIB_NAME}.dll)
endif()

project()

项目名在这里插入图片描述

option(

variable 选项名
help_text 描述、解释、备注
value 选项初始化值(除ON而外全为OFF))
在这里插入图片描述

SET()

这个大写的SET其实和小写的set是一样的,CMake中的命令不区分大小写,CMake中的变量区分大小写
在这里插入图片描述

官方手册

Set a normal, cache, or environment variable to a given value.
See the :ref:`cmake-language(7) variables <CMake Language Variables>`
documentation for the scopes and interaction of normal variables
and cache entries.Signatures of this command that specify a ``<value>...`` placeholder
expect zero or more arguments.  Multiple arguments will be joined as
a :ref:`semicolon-separated list <CMake Language Lists>` to form the actual variable
value to be set.  Zero arguments will cause normal variables to be
unset.  See the ``unset()`` command to unset variables explicitly.Set Normal Variable
^^^^^^^^^^^^^^^^^^^set(<variable> <value>... [PARENT_SCOPE])Sets the given ``<variable>`` in the current function or directory scope.
  • 比较好的案例博客https://blog.csdn.net/Calvin_zhou/article/details/104060927

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

include(cmake/yaml-cpp.cmake)

加载cmake文件的

Load and run CMake code from a file or module.include(<file|module> [OPTIONAL] [RESULT_VARIABLE <var>][NO_POLICY_SCOPE])Loads and runs CMake code from the file given.  Variable reads and
writes access the scope of the caller (dynamic scoping).  If ``OPTIONAL``
is present, then no error is raised if the file does not exist.  If
``RESULT_VARIABLE`` is given the variable ``<var>`` will be set to the
full filename which has been included or ``NOTFOUND`` if it failed.If a module is specified instead of a file, the file with name
``<modulename>.cmake`` is searched first in ``CMAKE_MODULE_PATH``,
then in the CMake module directory.  There is one exception to this: if
the file which calls ``include()`` is located itself in the CMake builtin
module directory, then first the CMake builtin module directory is searched and
``CMAKE_MODULE_PATH`` afterwards.  See also policy ``CMP0017``.

include_directories(“${CMAKE_SOURCE_DIR}/”)

加载头文件文件夹

Add include directories to the build.include_directories([AFTER|BEFORE] [SYSTEM] dir1 [dir2 ...])Add the given directories to those the compiler uses to search for
include files.  Relative paths are interpreted as relative to the
current source directory.The include directories are added to the ``INCLUDE_DIRECTORIES``
directory property for the current ``CMakeLists`` file.  They are also
added to the ``INCLUDE_DIRECTORIES`` target property for each
target in the current ``CMakeLists`` file.  The target property values
are the ones used by the generators.By default the directories specified are appended onto the current list of
directories.  This default behavior can be changed by setting
``CMAKE_INCLUDE_DIRECTORIES_BEFORE`` to ``ON``.  By using

link_directories()

加载库文件夹地址

Add directories in which the linker will look for libraries.link_directories([AFTER|BEFORE] directory1 [directory2 ...])Adds the paths in which the linker should search for libraries.
Relative paths given to this command are interpreted as relative to
the current source directory, see ``CMP0015``.The command will apply only to targets created after it is called... versionadded:: 3.13The directories are added to the ``LINK_DIRECTORIES`` directoryproperty for the current ``CMakeLists.txt`` file, converting relativepaths to absolute as needed.  See the ``cmake-buildsystem(7)``manual for more on defining buildsystem properties... versionadded:: 3.13

macro(safe_set_static_flag)函数

内容
**endmacro**()

这个函数属于宏定义,简单的说就是出现宏的地方进行代码替换,
解析的很清楚的博文:
https://blog.csdn.net/qq_21438461/article/details/129729530
在这里插入图片描述
官方文档:

Start recording a macro for later invocation as a commandmacro(<name> [<arg1> ...])<commands>endmacro()Defines a macro named ``<name>`` that takes arguments named
``<arg1>``, ... Commands listed after macro, but before the
matching ``endmacro()``, are not executed until the macro
is invoked.Per legacy, the ``endmacro()`` command admits an optional
``<name>`` argument. If used, it must be a verbatim repeat of the
argument of the opening ``macro`` command.See the ``cmake_policy()`` command documentation for the behavior
of policies inside macros.

foreach(参数,循环列表)函数

用于循环列表中的每一项

在这里插入图片描述
https://blog.csdn.net/wzj_110/article/details/116110014

Evaluate a group of commands for each value in a list.foreach(<loop_var> <items>)<commands>endforeach()where ``<items>`` is a list of items that are separated by
semicolon or whitespace.
All commands between ``foreach`` and the matching ``endforeach`` are recorded
without being invoked.  Once the ``endforeach`` is evaluated, the recorded
list of commands is invoked once for each item in ``<items>``.
At the beginning of each iteration the variable ``<loop_var>`` will be set
to the value of the current item.The scope of ``<loop_var>`` is restricted to the loop scope. See policy
``CMP0124`` for details.

MATCHES关键字

条件判断
https://blog.csdn.net/steptoward/article/details/128848733
可用于正则表达式
在这里插入图片描述

  • string(REGEX REPLACE 查找值 替换值 输出 输入)
    REGEX REPLACE指正则替换
    https://blog.csdn.net/weixin_41923935/article/details/122155064
    https://blog.csdn.net/m0_57845572/article/details/118520561
    在这里插入图片描述
String operations.Synopsis
^^^^^^^^Search and Replacestring(FIND <string> <substring> <out-var> [...])string(REPLACE <match-string> <replace-string> <out-var> <input>...)string(REGEX MATCH <match-regex> <out-var> <input>...)string(REGEX MATCHALL <match-regex> <out-var> <input>...)string(REGEX REPLACE <match-regex> <replace-expr> <out-var> <input>...)Manipulationstring(APPEND <string-var> [<input>...])string(PREPEND <string-var> [<input>...])string(CONCAT <out-var> [<input>...])string(JOIN <glue> <out-var> [<input>...])

“/MD” “/MT”

在这里插入图片描述

ADD_DEFINITIONS(-DUSE_MKL)

这种可以在我们更改别人代码做实验时使用,既不对其源码进行破坏,又可以添加自己的功能。有了这个后可以直接在编译的时候进行选择。具体的,在工程CMakeLists.txt 中,使用add_definitions()函数控制代码的开启和关闭:
在这里插入图片描述
https://blog.csdn.net/fb_941219/article/details/107376017
在这里插入图片描述

Add -D define flags to the compilation of source files.add_definitions(-DFOO -DBAR ...)Adds definitions to the compiler command line for targets in the current
directory, whether added before or after this command is invoked, and for
the ones in sub-directories added after. This command can be used to add any
flags, but it is intended to add preprocessor definitions... note::This command has been superseded by alternatives:* Use ``add_compile_definitions()`` to add preprocessor definitions.* Use ``include_directories()`` to add include directories.* Use ``add_compile_options()`` to add other options.

cmake关系操作符号

在这里插入图片描述

find_package(OpenCV REQUIRED PATHS ${OPENCV_DIR}/build/ NO_DEFAULT_PATH)函数

简单的说就是用这个如果找到了.cmake文件,就不用专门写link_directories,include_directories等函数来找头文件和库文件

Find a package (usually provided by something external to the project),
and load its package-specific details.Search Modes
^^^^^^^^^^^^The command has two very distinct ways of conducting the search:**Module mode**In this mode, CMake searches for a file called ``Find<PackageName>.cmake``,looking first in the locations listed in the ``CMAKE_MODULE_PATH``,then among the :ref:`Find Modules` provided by the CMake installation.If the file is found, it is read and processed by CMake.  It is responsiblefor finding the package, checking the version, and producing any neededmessages.  Some Find modules provide limited or no support for versioning;check the Find module's documentation.

写的最好的关于find_package的博文
https://blog.csdn.net/zhanghm1995/article/details/105466372
在这里插入图片描述

在这里插入图片描述

${CMAKE_SHARED_LIBRARY_SUFFIX}关键字

${CMAKE_STATIC_LIBRARY_SUFFIX}关键字

这个关键字能根据平台不同,自动为动态库静态库安排后缀,比如windows端的动态库后缀为dll,静态库为.lib,linux端的动态库后缀为.so,静态库后缀为.a
在这里插入图片描述

The suffix for shared libraries that you link to.The suffix to use for the end of a shared library filename, ``.dll`` on
Windows.

add_dependencies()

大致意思是在同时生成可执行文件a和库b时,恰好可执行文件a的生成需要依赖b这个库时需要用这个函数来指定先生成库b再生成可执行文件a,如果不指定会报错找不到b依赖库
在这里插入图片描述

有案例的博文http://t.csdn.cn/FZdWN

Add a dependency between top-level targets.add_dependencies(<target> [<target-dependency>]...)Makes a top-level ``<target>`` depend on other top-level targets to
ensure that they build before ``<target>`` does.  A top-level target
is one created by one of the ``add_executable()``,
``add_library()``, or ``add_custom_target()`` commands
(but not targets generated by CMake like ``install``).Dependencies added to an :ref:`imported target <Imported Targets>`
or an :ref:`interface library <Interface Libraries>` are followed
transitively in its place since the target itself does not build... versionadded:: 3.3Allow adding dependencies to interface libraries.

target_link_libraries

后面加具体依赖库的库名字,不需要加后缀
在这里插入图片描述

Specify libraries or flags to use when linking a given target and/or
its dependents.  :ref:`Usage requirements <Target Usage Requirements>`
from linked library targets will be propagated.  Usage requirements
of a target's dependencies affect compilation of its own sources.Overview
^^^^^^^^This command has several signatures as detailed in subsections below.
All of them have the general formtarget_link_libraries(<target> ... <item>... ...)The named ``<target>`` must have been created by a command such as
``add_executable()`` or ``add_library()`` and must not be an
:ref:`ALIAS target <Alias Targets>`.  If policy ``CMP0079`` is not
set to ``NEW`` then the target must have been created in the current

add_custom_command

在这里插入图片描述
在这里插入图片描述

Add a custom build rule to the generated build system.There are two main signatures for ``add_custom_command``.Generating Files
^^^^^^^^^^^^^^^^The first signature is for adding a custom command to produce an output:add_custom_command(OUTPUT output1 [output2 ...]COMMAND command1 [ARGS] [args1...][COMMAND command2 [ARGS] [args2...] ...][MAIN_DEPENDENCY depend][DEPENDS [depends...]][BYPRODUCTS [files...]][IMPLICIT_DEPENDS <lang1> depend1[<lang2> depend2] ...]

相关博文:
https://www.jianshu.com/p/47370c584356
https://blog.csdn.net/weixin_39766005/article/details/122866375
在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/133460.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

GaussDB(DWS)云原生数仓技术解析:湖仓一体,体验与大数据互联互通

文章目录 前言一、关于数据仓库需求场景分类二、数据仓库线下部署场景2.1、线下部署场景介绍及优劣势说明2.2、线下部署场景对应的客户需求 三、数据仓库公有云部署场景3.1、公有云部署场景介绍及优劣势说明3.2、公有云部署场景对应的客户需求 四、为何重视数据共享&#xff08…

postgresql-视图

postgresql-视图 视图概述使用视图的好处 创建视图修改视图删除视图递归视图可更新视图WITH CHECK OPTION 视图概述 视图&#xff08;View&#xff09;本质上是一个存储在数据库中的查询语句。视图本身不包含数据&#xff0c;也被称为 虚拟表。我们在创建视图时给它指定了一个…

IAM、EIAM、CIAM、RAM、IDaaS 都是什么?

后端程序员在做 ToB 产品或者后台系统时&#xff0c;都不可避免的会遇到账号系统、登录系统、权限系统、日志系统等这些核心功能。这些功能一般都是以 SSO 系统、RBAC 权限管理系统等方式命名&#xff0c;但这些系统合起来有一个专有名词&#xff1a;IAM。 IAM IAM 是 Identi…

数学建模__线性规划Python实现

我使用到的是python库中scipy。 线性规划 #目标函数的系数 # min z 2x13x2-5x3 c np.array([-2,-3,5])#不等式限制条件的系数&#xff0c;转化为小于等于 # 2x1-5x2x3 < 10, x13x2x3<12 Aup np.array([[-2,5,-1],[-1,-3,-1]]) #必须是二维 #右侧系数 bup np.array(…

论文管理系统设计与实现

毕业论文管理系统的设计与实现 学生&#xff1a; 指导教师&#xff1a; 内容摘要&#xff1a;毕业论文管理系统是典型的MIS信息管理系统,其开发主要包括后台数据库的建立和维护以及前端应用程序的开发两个方面。对于前者要求建立起数据一致性和完整性强、数据安全性好的库。而…

如何将一个字符串转换为驼峰命名法(camel case)?

聚沙成塔每天进步一点点 ⭐ 专栏简介⭐ 思路⭐ 示例⭐ 写在最后 ⭐ 专栏简介 前端入门之旅&#xff1a;探索Web开发的奇妙世界 记得点击上方或者右侧链接订阅本专栏哦 几何带你启航前端之旅 欢迎来到前端入门之旅&#xff01;这个专栏是为那些对Web开发感兴趣、刚刚踏入前端领…

【毕设选题】flink大数据淘宝用户行为数据实时分析与可视化

文章目录 0 前言1、环境准备1.1 flink 下载相关 jar 包1.2 生成 kafka 数据1.3 开发前的三个小 tip 2、flink-sql 客户端编写运行 sql2.1 创建 kafka 数据源表2.2 指标统计&#xff1a;每小时成交量2.2.1 创建 es 结果表&#xff0c; 存放每小时的成交量2.2.2 执行 sql &#x…

康耐视读码器DataMan软件详细使用步骤

1、 点击桌面已经安装好的 dataman 软件并打开 2、 打开之后,点击刷新,刷出来读码器的图标,双击进行连接,或者选中后,点击右下角 的连接。(也可先进行第 9—(2)步更改读码器的 IP,对应的连接对象也更改到同一网 段)如图 3、 连接之后,在设置 快速设置下面把实时显…

【栈与队列面试题】有效的括号(动图演示)

leetcode20.括号匹配问题 前言&#xff1a; &#x1f4a5;&#x1f388;个人主页:​​​​​​Dream_Chaser&#xff5e; &#x1f388;&#x1f4a5; ✨✨刷题专栏:http://t.csdn.cn/UlvTc ⛳⛳本篇内容:力扣上栈与队列的面试OJ题目 目录 leetcode20.括号匹配问题 1.问题描…

msvcp120.dll怎么修复?msvcp120.dll丢失的解决方法

在当今这个信息化的时代&#xff0c;电脑已经成为我们生活和工作中不可或缺的一部分。然而&#xff0c;随着电脑技术的不断发展&#xff0c;我们也会遇到各种各样的问题。其中&#xff0c;msvcp120.dll丢失是一个常见的问题。一、msvcp120.dll 文件介绍 1 msvcp120.dll 文件的定…

关于 firefox 不能访问 http 的解决

情景&#xff1a; 我在虚拟机 192.168.x.111 上配置了 DNS 服务器&#xff0c;在 kali 上设置 192.168.x.111 为 DNS 服务器后&#xff0c;使用 firefox 地址栏搜索域名 www.xxx.com &#xff0c;访问在 192.168.x.111 搭建的网站&#xff0c;本来经 192.168.x.111 DNS 服务器解…

MATLAB入门-数据的导入和导出

MATLAB入门-数据的导入和导出 注&#xff1a;本篇文章是课程学习笔记&#xff0c;课程链接为&#xff1a;头歌 常见的几个导入数据的方法 load函数 load函数专门用于引入MATLAB的.mat格式数据&#xff0c;十分的简单方便。 例如&#xff1a;一个-ASCII编码形式存储的数据文件…

VMware启用共享文件夹

1. 启用 编辑虚拟机设置 - 选项 - 共享文件夹 - 总是启用 - 添加 2. 启动Ubuntu查看 正常情况/mnt目录会出现文件夹hgfs 如果不存在&#xff0c;可参考 这篇文章 操作 如果安装VMWare tools后/mnt中有hgfs但没共享文件&#xff0c;可参考 这篇文章 如果出现 mount: unkno…

【Unity每日一记】资源加载相关和检测相关

&#x1f468;‍&#x1f4bb;个人主页&#xff1a;元宇宙-秩沅 &#x1f468;‍&#x1f4bb; hallo 欢迎 点赞&#x1f44d; 收藏⭐ 留言&#x1f4dd; 加关注✅! &#x1f468;‍&#x1f4bb; 本文由 秩沅 原创 &#x1f468;‍&#x1f4bb; 收录于专栏&#xff1a;uni…

ROS学习笔记(四)---使用 VScode 启动launch文件运行多个节点

ROS学习笔记文章目录 01. ROS学习笔记(一)—Linux安装VScode 02. ROS学习笔记(二)—使用 VScode 开发 ROS 的Python程序&#xff08;简例&#xff09; 03. ROS学习笔记(三)—好用的终端Terminator 一、什么是launch文件 虽然说Terminator终端是能够比较方便直观的看运行的节点…

查看视频文件关键帧间隔

一、Elecard StreamEye Tools拖放视频文件查看。 红的是I帧&#xff1b;蓝的是P帧&#xff1b;绿的是B帧。 二、ffprobe -show_streams统计。 1、统计视频关键帧、非关键帧 ffprobe.exe -i 1.mp4 -show_streams v -show_packets -print_format json > d:\1.json 再统计1.j…

SQL8 查找某个年龄段的用户信息

描述 题目&#xff1a;现在运营想要针对20岁及以上且23岁及以下的用户开展分析&#xff0c;请你取出满足条件的设备ID、性别、年龄。 用户信息表&#xff1a;user_profile iddevice_idgenderageuniversityprovince12138male21北京大学Beijing23214male复旦大学Shanghai36543…

徐亦达机器学习:Kalman Filter 卡尔曼滤波笔记 (一)

P ( x t P(x_t P(xt​| x t − 1 ) x_{t-1}) xt−1​) P ( y t P(y_t P(yt​| x t ) x_t) xt​) P ( x 1 ) P(x_1) P(x1​)Discrete State DM A X t − 1 , X t A_{X_{t-1},X_t} AXt−1​,Xt​​Any π \pi πLinear Gassian Kalman DM N ( A X t − 1 B , Q ) N(AX_{t-1}B,Q)…

Git多人开发解决冲突案例

准备工作&#xff1a; 1.创建一个gitee远程仓库https://gitee.com/xxxxxxx.git 2.初始化两个本地git仓库用户&#xff0c;目的是模拟多人协作开发时提交代码发生冲突的场景 3.解决冲突并提交。 进入正题&#xff1a; lisi 通过vim指令修改readme.md文件内容&#xff0c;推送到…

正则表达式使用总结

一、字符匹配 普通字符&#xff1a;普通字符按照字面意义进行匹配&#xff0c;例如匹配字母 "a" 将匹配到文本中的 "a" 字符。 元字符&#xff1a;元字符具有特殊的含义&#xff0c;例如 \d 匹配任意数字字符&#xff0c;\w 匹配任意字母数字字符&#xf…