cmake-find_package

https://cmake.org/cmake/help/latest/manual/cmake-modules.7.html

FindBLAS

https://cmake.org/cmake/help/latest/module/FindBLAS.html

BLAS_FOUND - set to true if a library implementing the BLAS interface
  is found
BLAS_LINKER_FLAGS - uncached list of required linker flags (excluding -l
  and -L).
BLAS_LIBRARIES - uncached list of libraries (using full path name) to
  link against to use BLAS
BLAS95_LIBRARIES - uncached list of libraries (using full path name)
  to link against to use BLAS95 interface
BLAS95_FOUND - set to true if a library implementing the BLAS f95 interface
  is found
BLA_STATIC  if set on this determines what kind of linkage we do (static)
BLA_VENDOR  if set checks only the specified vendor, if not set checks
   all the possibilities
BLA_F95     if set on tries to find the f95 interfaces for BLAS/LAPACK

FindBoost

https://cmake.org/cmake/help/latest/module/FindBoost.html

Boost_FOUND            - True if headers and requested libraries were found
Boost_INCLUDE_DIRS     - Boost include directories
Boost_LIBRARY_DIRS     - Link directories for Boost libraries
Boost_LIBRARIES        - Boost component libraries to be linked
Boost_<C>_FOUND        - True if component <C> was found (<C> is upper-case)
Boost_<C>_LIBRARY      - Libraries to link for component <C> (may include
                         target_link_libraries debug/optimized keywords)
Boost_VERSION          - BOOST_VERSION value from boost/version.hpp
Boost_LIB_VERSION      - Version string appended to library filenames
Boost_MAJOR_VERSION    - Boost major version number (X in X.y.z)
Boost_MINOR_VERSION    - Boost minor version number (Y in x.Y.z)
Boost_SUBMINOR_VERSION - Boost subminor version number (Z in x.y.Z)
Boost_LIB_DIAGNOSTIC_DEFINITIONS (Windows)
                       - Pass to add_definitions() to have diagnostic
                         information about Boost's automatic linking
                         displayed during compilation

Example to find Boost headers only:

find_package(Boost 1.36.0)
if(Boost_FOUND)
  include_directories(${Boost_INCLUDE_DIRS})
  add_executable(foo foo.cc)
endif()

Example to find Boost libraries and use imported targets:

find_package(Boost 1.56 REQUIRED COMPONENTS
             date_time filesystem iostreams)
add_executable(foo foo.cc)
target_link_libraries(foo Boost::date_time Boost::filesystem
                          Boost::iostreams)

Example to find Boost headers and some static (release only) libraries:

set(Boost_USE_STATIC_LIBS        ON)  # only find static libs
set(Boost_USE_DEBUG_LIBS         OFF) # ignore debug libs and
set(Boost_USE_RELEASE_LIBS       ON)  # only find release libs
set(Boost_USE_MULTITHREADED      ON)
set(Boost_USE_STATIC_RUNTIME    OFF)
find_package(Boost 1.36.0 COMPONENTS date_time filesystem system ...)
if(Boost_FOUND)
  include_directories(${Boost_INCLUDE_DIRS})
  add_executable(foo foo.cc)
  target_link_libraries(foo ${Boost_LIBRARIES})
endif()

FindGLEW

https://cmake.org/cmake/help/latest/module/FindGLEW.html

IMPORTED Targets

This module defines the IMPORTED target GLEW::GLEW

Result Variables

GLEW_INCLUDE_DIRS - include directories for GLEW
GLEW_LIBRARIES - libraries to link against GLEW
GLEW_FOUND - true if GLEW has been found and can be used

FindGLUT

https://cmake.org/cmake/help/latest/module/FindGLUT.html

IMPORTED Targets

GLUT::GLUT

Result Variables

GLUT_INCLUDE_DIR, where to find GL/glut.h, etc.
GLUT_LIBRARIES, the libraries to link against
GLUT_FOUND, If false, do not try to use GLUT.

This module defines the following IMPORTED targets:

GTest::GTest
The Google Test gtest library, if found; adds Thread::Thread automatically
GTest::Main
The Google Test gtest_main library, if found
GTEST_FOUND
Found the Google Testing framework
GTEST_INCLUDE_DIRS
the directory containing the Google Test headers
The library variables below are set as normal variables. These contain debug/optimized keywords when a debugging library is found.

GTEST_LIBRARIES
The Google Test gtest library; note it also requires linking with an appropriate thread library
GTEST_MAIN_LIBRARIES
The Google Test gtest_main library
GTEST_BOTH_LIBRARIES
Both gtest and gtest_main
enable_testing()
find_package(GTest REQUIRED)

add_executable(foo foo.cc)
target_link_libraries(foo GTest::GTest GTest::Main)

add_test(AllTestsInFoo foo)

FindOpenGL

https://cmake.org/cmake/help/latest/module/FindOpenGL.html#cache-variables

Optional COMPONENTS

EGLGLX, and OpenGL

IMPORTED Targets

OpenGL::GL
Defined to the platform-specific OpenGL libraries if the system has OpenGL.
OpenGL::OpenGL
Defined to libOpenGL if the system is GLVND-based. OpenGL::GL
OpenGL::GLU
Defined if the system has GLU.
OpenGL::GLX
Defined if the system has GLX.
OpenGL::EGL
Defined if the system has EGL.

Result Variables

OPENGL_FOUND
True, if the system has OpenGL and all components are found.
OPENGL_XMESA_FOUND
True, if the system has XMESA.
OPENGL_GLU_FOUND
True, if the system has GLU.
OpenGL_OpenGL_FOUND
True, if the system has an OpenGL library.
OpenGL_GLX_FOUND
True, if the system has GLX.
OpenGL_EGL_FOUND
True, if the system has EGL.
OPENGL_INCLUDE_DIR
Path to the OpenGL include directory.
OPENGL_EGL_INCLUDE_DIRS
Path to the EGL include directory.
OPENGL_LIBRARIES
Paths to the OpenGL library, windowing system libraries, and GLU libraries. On Linux, this assumes glX and is never correct for EGL-based targets. Clients are encouraged to use the OpenGL::* import targets instead.

Cache variables

OPENGL_egl_LIBRARY
Path to the EGL library.
OPENGL_glu_LIBRARY
Path to the GLU library.
OPENGL_glx_LIBRARY
Path to the GLVND ‘GLX’ library.
OPENGL_opengl_LIBRARY
Path to the GLVND ‘OpenGL’ library
OPENGL_gl_LIBRARY
Path to the OpenGL library. New code should prefer the OpenGL::* import targets.

FindOpenMP

https://cmake.org/cmake/help/latest/module/FindOpenMP.html

Imported targets

OpenMP::OpenMP_<lang>
Target for using OpenMP from <lang>.
Specifically for Fortran, the module sets the following variables:

OpenMP_Fortran_HAVE_OMPLIB_HEADER
Boolean indicating if OpenMP is accessible through omp_lib.h.
OpenMP_Fortran_HAVE_OMPLIB_MODULE
Boolean indicating if OpenMP is accessible through the omp_lib Fortran module.
The module will also try to provide the OpenMP version variables:

OpenMP_<lang>_SPEC_DATE
Date of the OpenMP specification implemented by the <lang> compiler.
OpenMP_<lang>_VERSION_MAJOR
Major version of OpenMP implemented by the <lang> compiler.
OpenMP_<lang>_VERSION_MINOR
Minor version of OpenMP implemented by the <lang> compiler.
OpenMP_<lang>_VERSION
OpenMP version implemented by the <lang> compiler.

variables

OpenMP_FOUND
Variable indicating that OpenMP flags for all requested languages have been found. If no components are specified, this is true if OpenMP settings for all enabled languages were detected.
OpenMP_VERSION
Minimal version of the OpenMP standard detected among the requested languages, or all enabled languages if no components were specified.
This module will set the following variables per language in your project, where <lang> is one of C, CXX, or Fortran:

OpenMP_<lang>_FOUND
Variable indicating if OpenMP support for <lang> was detected.
OpenMP_<lang>_FLAGS
OpenMP compiler flags for <lang>, separated by spaces.
For linking with OpenMP code written in <lang>, the following variables are provided:

OpenMP_<lang>_LIB_NAMES
;-list of libraries for OpenMP programs for <lang>.
OpenMP_<libname>_LIBRARY
Location of the individual libraries needed for OpenMP support in <lang>.
OpenMP_<lang>_LIBRARIES
A list of libraries needed to link with OpenMP code written in <lang>.

GoogleTest

https://cmake.org/cmake/help/latest/module/GoogleTest.html

include(GoogleTest)
add_executable(FooTest FooUnitTest.cxx)
gtest_add_tests(TARGET      FooTest
                TEST_SUFFIX .noArgs
                TEST_LIST   noArgsTests
)
gtest_add_tests(TARGET      FooTest
                EXTRA_ARGS  --someArg someValue
                TEST_SUFFIX .withArgs
                TEST_LIST   withArgsTests
)
set_tests_properties(${noArgsTests}   PROPERTIES TIMEOUT 10)
set_tests_properties(${withArgsTests} PROPERTIES TIMEOUT 20)
原文地址:https://www.cnblogs.com/freedomabcd/p/7778236.html