cmake语法学习 - 01 Basic - H - third party library

cmake_minimum_required(VERSION 3.5)

# Set the project name
project (third_party_include)

# testing code
find_package(OpenCV)
message("OpenCV_INCLUDE_DIRS = ${OpenCV_INCLUDE_DIRS}")
message("OpenCV_LIBRARIES = ${OpenCV_LIBRARIES}")

if(OpenCV_FOUND)
    message ("OpenCV found")
endif()


# find a boost install with the libraries filesystem and system
find_package(Boost 1.46.1 REQUIRED COMPONENTS filesystem system)

# check if boost was found
if(Boost_FOUND)
    message ("boost found")
else()
    message (FATAL_ERROR "Cannot find Boost")
endif()

# Add an executable
add_executable(third_party_include main.cpp)

# link against the boost libraries
target_link_libraries( third_party_include
    PRIVATE
        Boost::filesystem
)

 

*

find_package(OpenCV)

- OpenCV is ok. Please note that "opencv" or "OPENCV" is not avaliable input.

- XXXX_INCLUDE_DIRS will be defined if XXXX has beed found!

- XXXX_LIBRARIES will be defined if XXXX has beed found!

- XXXX_FOUND will be true, if XXXX has beed found!

As you can see, loads of kept variables will be inner-defined by CMake. It is pretty confusing.

Please check the website of CMake to find out the variables you might need in your CMakeList.txt.

 

 

 

 

XXXX

posted @ 2020-04-26 11:24  路边的十元钱硬币  阅读(394)  评论(0编辑  收藏  举报