Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何测试cmake中是否存在与glob匹配的文件名?_Cmake_Glob - Fatal编程技术网

如何测试cmake中是否存在与glob匹配的文件名?

如何测试cmake中是否存在与glob匹配的文件名?,cmake,glob,Cmake,Glob,我想创建一个条件,该条件仅在具有指定glob的文件名存在时才为true。 像这样(这不是cmake代码,只是为了表达我的意图): 将所有匹配文件的列表放入cmake_variable,然后您可以测试该文件是否为空 从cmake--help命令文件: ... file(GLOB variable [RELATIVE path] [globbing expressions]...) file(GLOB_RECURSE variable [RELATIVE path]

我想创建一个条件,该条件仅在具有指定glob的文件名存在时才为true。 像这样(这不是cmake代码,只是为了表达我的意图):

将所有匹配文件的列表放入
cmake_variable
,然后您可以测试该文件是否为空

cmake--help命令文件

     ...
     file(GLOB variable [RELATIVE path] [globbing expressions]...)
     file(GLOB_RECURSE variable [RELATIVE path] 
          [FOLLOW_SYMLINKS] [globbing expressions]...)
     ...

   ...

   GLOB will generate a list of all files that match the globbing
   expressions and store it into the variable.  Globbing expressions are
   similar to regular expressions, but much simpler.  If RELATIVE flag is
   specified for an expression, the results will be returned as a
   relative path to the given path.  (We do not recommend using GLOB to
   collect a list of source files from your source tree.  If no
   CMakeLists.txt file changes when a source is added or removed then the
   generated build system cannot know when to ask CMake to regenerate.)

   Examples of globbing expressions include:

      *.cxx      - match all files with extension cxx
      *.vt?      - match all files with extension vta,...,vtz
      f[3-5].txt - match files f3.txt, f4.txt, f5.txt

   GLOB_RECURSE will generate a list similar to the regular GLOB, except
   it will traverse all the subdirectories of the matched directory and
   match the files.  Subdirectories that are symlinks are only traversed
   if FOLLOW_SYMLINKS is given or cmake policy CMP0009 is not set to NEW.
   See cmake --help-policy CMP0009 for more information.

   Examples of recursive globbing include:

      /dir/*.py  - match all python files in /dir and subdirectories

   ...
file( GLOB cmake_varibale ${LIBRARY_PATH}/lib*.a )
     ...
     file(GLOB variable [RELATIVE path] [globbing expressions]...)
     file(GLOB_RECURSE variable [RELATIVE path] 
          [FOLLOW_SYMLINKS] [globbing expressions]...)
     ...

   ...

   GLOB will generate a list of all files that match the globbing
   expressions and store it into the variable.  Globbing expressions are
   similar to regular expressions, but much simpler.  If RELATIVE flag is
   specified for an expression, the results will be returned as a
   relative path to the given path.  (We do not recommend using GLOB to
   collect a list of source files from your source tree.  If no
   CMakeLists.txt file changes when a source is added or removed then the
   generated build system cannot know when to ask CMake to regenerate.)

   Examples of globbing expressions include:

      *.cxx      - match all files with extension cxx
      *.vt?      - match all files with extension vta,...,vtz
      f[3-5].txt - match files f3.txt, f4.txt, f5.txt

   GLOB_RECURSE will generate a list similar to the regular GLOB, except
   it will traverse all the subdirectories of the matched directory and
   match the files.  Subdirectories that are symlinks are only traversed
   if FOLLOW_SYMLINKS is given or cmake policy CMP0009 is not set to NEW.
   See cmake --help-policy CMP0009 for more information.

   Examples of recursive globbing include:

      /dir/*.py  - match all python files in /dir and subdirectories

   ...