目录:
文件:
main.cpp
#include <iostream>
#include <boost/shared_ptr.hpp>
#include <boost/filesystem.hpp>
int main(int argc, char *argv[])
{
std::cout << "Hello Third Party Include!" << std::endl;
boost::shared_ptr<int> isp(new int(4));
std::cout << isp << std::endl;
boost::filesystem::path path = "/usr/share/cmake/modules";
if (path.is_relative())
{
std::cout << "Path is relative" << std::endl;
}
else{
std::cout << "Path is not relative" << std::endl;
}
return 0;
}
CMakeLists.txt
cmake_minimum_required(VERSION 3.5)
project(third_party_include)
find_package(
Boost 1.76.0 REQUIRED COMPONENTS filesystem system
)
if(Boost_FOUND)
message("boost found")
else()
message(FATAL_ERROR "Cannot find Boost")
endif()
add_executable(third_party_include main.cpp)
target_link_libraries(
third_party_include
PRIVATE
Boost::filesystem
)
运行:
cd build
cmake ..
make
./third_party_include
(base) ➜ build ./third_party_include
Hello Third Party Include!
0x7ffa1d405960
Path is not relative
其他引用:
C++:MAC安装Boost库文件并且使用CLion开发_CHYabc123456hh的博客-CSDN博客
(注意提前装好Boost)