CMake use specific Boost version

2019-08-30 09:14发布

问题:

I am working on a project where I am linking against a library which was itself linked against boost 1.48. I am looking for a way to specify in my CMakeLists.txt that I want the system to find and only use the boost 1.48 library.

I am not able to update the version the other library was compiled against and so I cannot set a minimum version number I need a way to set the only acceptable boost version. I have not been able to find a method to do this.

回答1:

You should use find_package:

format is as follows:

 find_package(package version EXACT REQUIRED COMPONENTS components…) 

so if you need exactly 1.48 then you should use (example):

 find_package(Boost 1.48 EXACT REQUIRED COMPONENTS system thread date_time) 


标签: boost cmake