Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

explore find_package for MSVC CMake #91

Closed
vinniefalco opened this issue Sep 25, 2016 · 3 comments
Closed

explore find_package for MSVC CMake #91

vinniefalco opened this issue Sep 25, 2016 · 3 comments

Comments

@vinniefalco
Copy link
Member

It would be nice to use find_package for Boost when building Visual Studio projects but I couldn't get that to work and support both 32 and 64 bit compiled boost and projects on the same machine.

@e-fominov
Copy link
Contributor

I have tested several ways of solution and found one possible way: do not use "stage" folder for building boos libs

  1. Build boost:
b2 address-model=64 --build-type=minimal stage --stagedir=stage64
b2 address-model=32 --build-type=minimal stage --stagedir=stage32

Its important to keep x86 libraries in "stage32" not "stage" folder
2. Put additional flags to Cmake when building Beast:

cmake .. -G"Visual Studio 14 2015" -DBOOST_ROOT=d:\lib\boost_1_61_0 -DBOOST_LIBRARYDIR=d:\libs\boost_1_61_0\stage32\lib
cmake .. -G"Visual Studio 14 2015 Win64" -DBOOST_ROOT=d:\lib\boost_1_61_0 -DBOOST_LIBRARYDIR=d:\libs\boost_1_61_0\stage64\lib

Now it correctly finds boost and creates correct vsproj files

If machine has only one boost and its installed in default folder - no need in additional flags when running cmake. This solution only when you have two boosts

To check if it finds boost correctly you can try temptorary modifying cmakelists.txt file:

    set(Boost_USE_STATIC_LIBS ON)
    set(Boost_USE_MULTITHREADED ON)
    find_package(Boost REQUIRED COMPONENTS coroutine context thread filesystem program_options system)
    message(${Boost_LIBRARY_DIRS})

add this before "if(MSVC)" and it will print found library path

After boost will be found correctly we need modify CMakeLists.txt to add boost libraries to linker (now it does not have them)

@e-fominov
Copy link
Contributor

and one more way to solve this:

if(CMAKE_SIZEOF_VOID_P EQUAL 8)
    set(Boost_LIBRARY_DIR ${BOOST_ROOT}/stage64/lib)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
    set(Boost_LIBRARY_DIR ${BOOST_ROOT}/stage/lib)
endif()

this code should be called befor find_package(boost) and will initialize library dir automatically based on MSVC version, but require to have BOOST_ROOT set, that can be got from Environment

@vinniefalco
Copy link
Member Author

Beast 1.0.0-b32 now supports finding Boost packages on Windows!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants