16-cmake语法-OpeCV3.3.1_CMakeLists.txt的部分注释

OpeCV3.3.1 的 CMakeLists.txt 的部分注释。

 

# Disable in-source builds to prevent source tree corruption.
# @ 解说:
# @ 1. in-source 编译就是:不新建build文件夹。那么所有CMAKE生成的东西就都堆在
# @    sources 所在的路径下,这不是很混乱吗。所以禁止。
# @ 2. 合理的 cmake 操作:
# @    mkdir build
# @    cd build
# @    cmake .. 
# @    build/..  就是 ${CMAKE_SOURCE_DIR}, ..表示向外一层目录。
# @    build     就是 ${CMAKE_BINARY_DIR}
# @ 3. STREQUAL  用于比较字符串
# @ 4. message() 输出
if(" ${CMAKE_SOURCE_DIR}" STREQUAL " ${CMAKE_BINARY_DIR}")
  message(FATAL_ERROR "
FATAL: In-source builds are not allowed.
       You should create a separate directory for build files.
")
endif()

# @ 解说:
# @ include 添加xx.cmake模块,或者CMakeLists.txt
include(cmake/OpenCVMinDepVersions.cmake)

# @ 解说:
# @ MATCHes: 表示前面的字符串是否匹配后面的正则表达式。
# @     不是很明白,但是应该是做数据检查。有点相当于 ==
# @ AND 是关系操作符,与
# @ cmake_minimum_required:设置cmake版本要求
# @ CMAKE_SYSTEM_NAME 等:是系统的变量。看blog说明
if(CMAKE_GENERATOR MATCHES Xcode AND XCODE_VERSION VERSION_GREATER 4.3)
  cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
elseif(CMAKE_SYSTEM_NAME MATCHES WindowsPhone OR CMAKE_SYSTEM_NAME MATCHES WindowsStore)
  cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
  #Required to resolve linker error issues due to incompatibility with CMake v3.0+ policies.
  #CMake fails to find _fseeko() which leads to subsequent linker error.
  #See details here: http://www.cmake.org/Wiki/CMake/Policies
  cmake_policy(VERSION 2.8)
else()
  cmake_minimum_required(VERSION "${MIN_VER_CMAKE}" FATAL_ERROR)
endif()

**** 节选 ****

# @ 解说:
# @ OR 是关系操作符,或
if(CMAKE_SYSTEM_NAME MATCHES WindowsPhone OR CMAKE_SYSTEM_NAME MATCHES WindowsStore)
  set(WINRT TRUE)
endif(CMAKE_SYSTEM_NAME MATCHES WindowsPhone OR CMAKE_SYSTEM_NAME MATCHES WindowsStore)

if(WINRT)
  add_definitions(-DWINRT -DNO_GETENV)

  # Making definitions available to other configurations and
  # to filter dependency restrictions at compile time.
  if(CMAKE_SYSTEM_NAME MATCHES WindowsPhone)
    set(WINRT_PHONE TRUE)
    add_definitions(-DWINRT_PHONE)
  elseif(CMAKE_SYSTEM_NAME MATCHES WindowsStore)
    set(WINRT_STORE TRUE)
    add_definitions(-DWINRT_STORE)
  endif()

  if(CMAKE_SYSTEM_VERSION MATCHES 10)
    set(WINRT_10 TRUE)
    add_definitions(-DWINRT_10)
  elseif(CMAKE_SYSTEM_VERSION MATCHES 8.1)
    set(WINRT_8_1 TRUE)
    add_definitions(-DWINRT_8_1)
  elseif(CMAKE_SYSTEM_VERSION MATCHES 8.0)
    set(WINRT_8_0 TRUE)
    add_definitions(-DWINRT_8_0)
  endif()
endif()


include(cmake/OpenCVUtils.cmake)

# must go before the project command

# @ 解说:
# @ ocv_update 函数定义在 cmake/OpenCVUtils.cmake 这个组件中,可以用Notepad++打开看看。
ocv_update(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Configs" FORCE)
if(DEFINED CMAKE_BUILD_TYPE)
  set_property( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${CMAKE_CONFIGURATION_TYPES} )
endif()

# @ 解说:
# @ 使用ctest(),还在研究。
enable_testing()

# @ 解说:
# @ 设置工程名
project(OpenCV CXX C)

if(MSVC)
  set(CMAKE_USE_RELATIVE_PATHS ON CACHE INTERNAL "" FORCE)
endif()

  

posted @ 2018-04-18 21:03  路边的十元钱硬币  阅读(946)  评论(0编辑  收藏  举报