Your configuration looks a bit weird and dirty. Especially things like:
ADD_DEFINITIONS(-DBoost_USE_STATIC_LIBS=ON)
It's not a C/C++ preprocessor definition! It's a CMake variable which is used to control how CMake will define the linkage stage of your project with Boost libraries.
If you properly compiled Boost and didn't mess up anything, then the directory structure usually looks like this:
<boost-dir>
include
boost
accumulators
...
aligned_storage.hpp
...
lib
libboost_atomic-mt-s.a
...
NOTE: The root directory of Boost, <boost-dir>
, appears to be D:/boost_1_54_0
in your case.
If in your case it does not look like above, then I'd suggest to rearrange it manually to the one above since, once again, this is how it should be.
When done, let's do some CMake configuration. I suggest to keep things simple and clean in the first place, and obey the CMake conventions. Test the following:
set(BOOST_INCLUDEDIR D:/boost_1_54_0/include)
set(BOOST_LIBRARYDIR D:/boost_1_54_0/lib)
NOTE: You can find thorough description of both of these variables at the top of FindBoost.cmake
.
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
NOTE: This is how you enforce static linkage by setting the CMake variable properly, but not like you did by setting a non-existent C/C++ preprocessor definition.
find_package(Boost
1.54.0
COMPONENTS thread
system
log
log_setup
program_options
REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(<target_name> ${Boost_LIBRARIES})
NOTE: Instead of <target_name>
, put the name of the target that you wish to build (executable, static/shared library, etc.).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…