Discussion:
[CMake] How to include Boost in Visual Studio cmake project
Martin Peter Christiansen
2009-11-12 00:41:40 UTC
Permalink
For the last day or so I have tried to compile a project(RobWork) for Visual
Studio 2008 using Cmake.

But my problem is that Cmake claims i can't find Boost dependencies.



I have been googling the problem on the net, but the only answer I could
find was that FindBost.cmake was the problem, but not how to solve it.



When i run the project (RobWork) i get the following error:



*C:\Documents and Settings\Martin>cd
c:\local\workspace\RobWork\build\release*

*C:\local\workspace\RobWork\build\release>cmake -G "Visual Studio 9 2008"
-DCMAKE_BUILD_TYPE=Release
../..
-- RobWork version 0.4.0
-- Build configuration: Release
CMake Warning (dev) at CMakeLists.txt:20 (INCLUDE):
Policy CMP0011 is not set: Included scripts do automatic cmake_policy PUSH
and POP. Run "cmake --help-policy CMP0011" for policy details. Use the
cmake_policy command to set the policy and suppress this warning.*

* The included script*

* C:/local/workspace/RobWork/build/ProjectSetup.cmake*

* affects policy settings. CMake is implying the NO_POLICY_SCOPE option
for
compatibility, so the effects are applied to the including context.
This warning is for project developers. Use -Wno-dev to suppress it.*

*-- RobWork ROOT dir: C:/local/workspace/RobWork
CMake Error at C:/Programmer/CMake
2.8/share/cmake-2.8/Modules/FindBoost.cmake:879 (message):
Unable to find the requested Boost libraries.*

* Boost version: 1.39.0*

* Boost include path: C:/local/boost_1_39_0*

* The following Boost libraries could not be found:*

* boost_thread*

* No Boost libraries were found. You may need to set Boost_LIBRARYDIR to
the
directory containing Boost libraries or BOOST_ROOT to the location of
Boost.
Call Stack (most recent call first):
build/depends.cmake:8 (FIND_PACKAGE)
build/RobWorkSetup.cmake:32 (INCLUDE)
CMakeLists.txt:36 (INCLUDE)*



- I have successfully compiled Boost 1.39.0 to Visual studio 2008, so i get
lib files like "libboost_date_time-vc90-mt-1_39.lib" in
<boost-root>/stage/lib.



- Boost have been placed in “C:\local\boost_1_39_0”



- The following environment variables has been added to Windows BOOST_ROOT =
C:\local\boost_1_39_0 and BOOST_LIBRARYDIR = $BOOST_ROOT\stage\lib



- Both Cmake 2.6 and 2.8r2 have been used to compile the project, with no
success.





What I need is a solution, which can help me compile this project using
Visual Studio 2008

Is there some way I can setup FindBoost.cmake, so it will accept and boost
correctly????



Regards



Martin Peter Christiansen
Mike Jackson
2009-11-12 02:02:11 UTC
Permalink
Usually when I build Boost on Windows I use the
--prefix=C:\Path\To\Boost and the "install" target instead of the
stage target.

Then I set BOOST_ROOT to what ever I set the --prefix argument to.
That seems to always work.

And to try this out you will need a clean RobWork build directory. So,
to sum up, try rebuilding boost by including the --prefix=C:\.... and
"install" arguments to bjam.

Then remove everything from your RobWork build directory and then
reconfigure RobWork using cmake.
_________________________________________________________
Mike Jackson ***@bluequartz.net
BlueQuartz Software www.bluequartz.net
Principal Software Engineer Dayton, Ohio




On Wed, Nov 11, 2009 at 7:41 PM, Martin Peter Christiansen
Post by Martin Peter Christiansen
For the last day or so I have tried to compile a project(RobWork) for Visual
Studio 2008 using Cmake.
But my problem is that Cmake claims i can't find Boost dependencies.
I have been googling the problem on the net, but the only answer I could
find was that FindBost.cmake was the problem, but not how to solve it.
 C:\Documents and Settings\Martin>cd
c:\local\workspace\RobWork\build\release
C:\local\workspace\RobWork\build\release>cmake -G "Visual Studio 9 2008"
-DCMAKE_BUILD_TYPE=Release
../..
-- RobWork version 0.4.0
-- Build configuration: Release
  Policy CMP0011 is not set: Included scripts do automatic cmake_policy PUSH
  and POP.  Run "cmake --help-policy CMP0011" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.
  The included script
    C:/local/workspace/RobWork/build/ProjectSetup.cmake
  affects policy settings.  CMake is implying the NO_POLICY_SCOPE option for
  compatibility, so the effects are applied to the including context.
This warning is for project developers.  Use -Wno-dev to suppress it.
-- RobWork ROOT dir: C:/local/workspace/RobWork
CMake Error at C:/Programmer/CMake
  Unable to find the requested Boost libraries.
  Boost version: 1.39.0
  Boost include path: C:/local/boost_1_39_0
          boost_thread
  No Boost libraries were found.  You may need to set Boost_LIBRARYDIR to
the
  directory containing Boost libraries or BOOST_ROOT to the location of
  Boost.
  build/depends.cmake:8 (FIND_PACKAGE)
  build/RobWorkSetup.cmake:32 (INCLUDE)
  CMakeLists.txt:36 (INCLUDE)
- I have successfully compiled Boost 1.39.0 to Visual studio 2008, so i get
lib files like "libboost_date_time-vc90-mt-1_39.lib" in
<boost-root>/stage/lib.
- Boost have been placed in “C:\local\boost_1_39_0”
- The following environment variables has been added to Windows BOOST_ROOT =
C:\local\boost_1_39_0 and BOOST_LIBRARYDIR = $BOOST_ROOT\stage\lib
- Both Cmake 2.6 and 2.8r2 have been used to compile the project, with no
success.
What I need is a solution, which can help me compile this project using
Visual Studio 2008
 Is there some way I can setup FindBoost.cmake, so it will accept and boost
correctly????
Regards
Martin Peter Christiansen
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
http://www.cmake.org/Wiki/CMake_FAQ
http://www.cmake.org/mailman/listinfo/cmake
Martin Peter Christiansen
2009-11-12 10:43:34 UTC
Permalink
I just tried the advise I was given, and the result was the following

C:\local\workspace\RobWork\build\release>cmake -G "Visual Studio 9 2008"
-DCMAKE_BUILD_TYPE=Release ../..
-- RobWork version 0.4.0
-- Build configuration: Release
-- No Default.cmake file loaded, using default settings from
config.cmake.template
CMake Warning (dev) at CMakeLists.txt:20 (INCLUDE):
Policy CMP0011 is not set: Included scripts do automatic cmake_policy PUSH
and POP. Run "cmake --help-policy CMP0011" for policy details. Use the
cmake_policy command to set the policy and suppress this warning.
The included script
C:/local/workspace/RobWork/build/ProjectSetup.cmake
affects policy settings. CMake is implying the NO_POLICY_SCOPE option for
compatibility, so the effects are applied to the including context.
This warning is for project developers. Use -Wno-dev to suppress it.
-- RobWork ROOT dir: C:/local/workspace/RobWork
CMake Error at C:/Programmer/CMake
2.8/share/cmake-2.8/Modules/FindBoost.cmake:879 (message):
Unable to find the requested Boost libraries.
Boost version: 1.39.0
Boost include path: C:/local/boost/include/boost-1_39
The following Boost libraries could not be found:
boost_thread
No Boost libraries were found. You may need to set Boost_LIBRARYDIR to
the
directory containing Boost libraries or BOOST_ROOT to the location of
Boost.
Call Stack (most recent call first):
build/depends.cmake:8 (FIND_PACKAGE)
build/RobWorkSetup.cmake:32 (INCLUDE)
CMakeLists.txt:36 (INCLUDE)


When I was building boost this time, I did ran the following commands:
- "C:\Downloads\boost_1_39_0>bjam.exe --prefix=C:\local\boost -toolset=msvs
define="_SECURE_SCL=0" define="_HAS_ITERATOR_DEBUGGING=0" -d+2"
- "C:\Downloads\boost_1_39_0>bjam.exe install --prefix=C:\local\boost"

I removed all the old enviromental variables for boost and created the
following variable
- BOOST_ROOT = C:\local\boost

In "C:\local\boost\lib" I have
- libboost_thread-vc90-mt.lib
- libboost_thread-vc90-mt-gd-1_39.lib
- libboost_thread-vc90-mt-gd.lib

In "C:\local\boost\include\boost-1_39" I have
- A folder named "boost", but no subfolder or file called "boost_thread"

I must missing some variable or setting, but I can't figure out what...

Regards

Martin Peter Christansen
Post by Mike Jackson
Usually when I build Boost on Windows I use the
--prefix=C:\Path\To\Boost and the "install" target instead of the
stage target.
Then I set BOOST_ROOT to what ever I set the --prefix argument to.
That seems to always work.
And to try this out you will need a clean RobWork build directory. So,
to sum up, try rebuilding boost by including the --prefix=C:\.... and
"install" arguments to bjam.
Then remove everything from your RobWork build directory and then
reconfigure RobWork using cmake.
_________________________________________________________
BlueQuartz Software www.bluequartz.net
Principal Software Engineer Dayton, Ohio
On Wed, Nov 11, 2009 at 7:41 PM, Martin Peter Christiansen
Post by Martin Peter Christiansen
For the last day or so I have tried to compile a project(RobWork) for
Visual
Post by Martin Peter Christiansen
Studio 2008 using Cmake.
But my problem is that Cmake claims i can't find Boost dependencies.
I have been googling the problem on the net, but the only answer I could
find was that FindBost.cmake was the problem, but not how to solve it.
C:\Documents and Settings\Martin>cd
c:\local\workspace\RobWork\build\release
C:\local\workspace\RobWork\build\release>cmake -G "Visual Studio 9 2008"
-DCMAKE_BUILD_TYPE=Release
../..
-- RobWork version 0.4.0
-- Build configuration: Release
Policy CMP0011 is not set: Included scripts do automatic cmake_policy
PUSH
Post by Martin Peter Christiansen
and POP. Run "cmake --help-policy CMP0011" for policy details. Use
the
Post by Martin Peter Christiansen
cmake_policy command to set the policy and suppress this warning.
The included script
C:/local/workspace/RobWork/build/ProjectSetup.cmake
affects policy settings. CMake is implying the NO_POLICY_SCOPE option
for
Post by Martin Peter Christiansen
compatibility, so the effects are applied to the including context.
This warning is for project developers. Use -Wno-dev to suppress it.
-- RobWork ROOT dir: C:/local/workspace/RobWork
CMake Error at C:/Programmer/CMake
Unable to find the requested Boost libraries.
Boost version: 1.39.0
Boost include path: C:/local/boost_1_39_0
boost_thread
No Boost libraries were found. You may need to set Boost_LIBRARYDIR to
the
directory containing Boost libraries or BOOST_ROOT to the location of
Boost.
build/depends.cmake:8 (FIND_PACKAGE)
build/RobWorkSetup.cmake:32 (INCLUDE)
CMakeLists.txt:36 (INCLUDE)
- I have successfully compiled Boost 1.39.0 to Visual studio 2008, so i
get
Post by Martin Peter Christiansen
lib files like "libboost_date_time-vc90-mt-1_39.lib" in
<boost-root>/stage/lib.
- Boost have been placed in “C:\local\boost_1_39_0”
- The following environment variables has been added to Windows
BOOST_ROOT =
Post by Martin Peter Christiansen
C:\local\boost_1_39_0 and BOOST_LIBRARYDIR = $BOOST_ROOT\stage\lib
- Both Cmake 2.6 and 2.8r2 have been used to compile the project, with no
success.
What I need is a solution, which can help me compile this project using
Visual Studio 2008
Is there some way I can setup FindBoost.cmake, so it will accept and
boost
Post by Martin Peter Christiansen
correctly????
Regards
Martin Peter Christiansen
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
http://www.cmake.org/Wiki/CMake_FAQ
http://www.cmake.org/mailman/listinfo/cmake
Hendrik Sattler
2009-11-12 10:55:45 UTC
Permalink
Post by Martin Peter Christiansen
In "C:\local\boost\lib" I have
- libboost_thread-vc90-mt.lib
- libboost_thread-vc90-mt-gd-1_39.lib
- libboost_thread-vc90-mt-gd.lib
MSVC libs usually do not have the lib... prefix. I am not sure if
CMake does find them in this case.

HS
Martin Peter Christiansen
2009-11-12 11:27:30 UTC
Permalink
okay, but is there some way i can convert the files or maybe change a
parameter when I am compiling boost or running Cmake???

Martin Peter Christiansen
Post by Martin Peter Christiansen
In "C:\local\boost\lib" I have
Post by Martin Peter Christiansen
- libboost_thread-vc90-mt.lib
- libboost_thread-vc90-mt-gd-1_39.lib
- libboost_thread-vc90-mt-gd.lib
MSVC libs usually do not have the lib... prefix. I am not sure if CMake
does find them in this case.
HS
Philip Lowman
2009-11-12 12:44:59 UTC
Permalink
Post by Martin Peter Christiansen
In "C:\local\boost\lib" I have
Post by Martin Peter Christiansen
- libboost_thread-vc90-mt.lib
- libboost_thread-vc90-mt-gd-1_39.lib
- libboost_thread-vc90-mt-gd.lib
MSVC libs usually do not have the lib... prefix. I am not sure if CMake
does find them in this case.
The static MSVC libraries always have the lib prefix on Windows, the dynamic
MSVC libraries do not.

You have to set this variable to enable searching for static libraries.

set(Boost_USE_STATIC_LIBS ON)
--
Philip Lowman
Philip Lowman
2009-11-12 12:54:07 UTC
Permalink
On Thu, Nov 12, 2009 at 5:43 AM, Martin Peter Christiansen <
Post by Martin Peter Christiansen
I just tried the advise I was given, and the result was the following
C:\local\workspace\RobWork\build\release>cmake -G "Visual Studio 9 2008"
-DCMAKE_BUILD_TYPE=Release ../..
-- RobWork version 0.4.0
-- Build configuration: Release
-- No Default.cmake file loaded, using default settings from
config.cmake.template
Policy CMP0011 is not set: Included scripts do automatic cmake_policy PUSH
and POP. Run "cmake --help-policy CMP0011" for policy details. Use the
cmake_policy command to set the policy and suppress this warning.
The included script
C:/local/workspace/RobWork/build/ProjectSetup.cmake
affects policy settings. CMake is implying the NO_POLICY_SCOPE option for
compatibility, so the effects are applied to the including context.
This warning is for project developers. Use -Wno-dev to suppress it.
-- RobWork ROOT dir: C:/local/workspace/RobWork
CMake Error at C:/Programmer/CMake
Unable to find the requested Boost libraries.
Boost version: 1.39.0
Boost include path: C:/local/boost/include/boost-1_39
boost_thread
No Boost libraries were found. You may need to set Boost_LIBRARYDIR to
the
directory containing Boost libraries or BOOST_ROOT to the location of
Boost.
build/depends.cmake:8 (FIND_PACKAGE)
build/RobWorkSetup.cmake:32 (INCLUDE)
CMakeLists.txt:36 (INCLUDE)
- "C:\Downloads\boost_1_39_0>bjam.exe --prefix=C:\local\boost -toolset=msvs
define="_SECURE_SCL=0" define="_HAS_ITERATOR_DEBUGGING=0" -d+2"
- "C:\Downloads\boost_1_39_0>bjam.exe install --prefix=C:\local\boost"
I removed all the old enviromental variables for boost and created the
following variable
- BOOST_ROOT = C:\local\boost
In "C:\local\boost\lib" I have
- libboost_thread-vc90-mt.lib
- libboost_thread-vc90-mt-gd-1_39.lib
- libboost_thread-vc90-mt-gd.lib
In "C:\local\boost\include\boost-1_39" I have
- A folder named "boost", but no subfolder or file called "boost_thread"
I must missing some variable or setting, but I can't figure out what...
Your directory structure sounds good to me.

Here are a couple of suggestions...

Check the documentation to FindBoost.cmake. Have you specified
Boost_USE_STATIC_LIBS and Boost_USE_MULTITHREADED appropriately? These
affect which libraries are detected and certain ones like boost_thread can't
be found if Boost_USE_MULTITHREADED is not true.

If this doesn't help, delete your build tree, then add this line prior to
calling find_package(Boost...)

set(Boost_DEBUG TRUE)

Paste the output here and the relevant portions of your CMakeLists.txt when
you call find_package(Boost...).
--
Philip Lowman
Michael Jackson
2009-11-12 13:53:17 UTC
Permalink
Just to follow up a bit more, here is my recipe for getting Boost up
and running with CMake and Visual Studio.

1: Compile Boost:
From the "Visual Studio Command Prompt I use the following:

bjam.exe toolset=msvc-9.0 --with-test --with-filesystem --with-
program_options --with-date_time --with-thread --prefix=C:\Developer
\VS9\boost_1_39 variant=release,debug threading=multi link=static
runtime-link=shared install

2: I then set the Boost_ROOT environment variable to "C:\Developer
\VS9\boost_1_39"

3: CMakeLists.txt File:

# ---------- Find Boost Headers/Libraries -----------------------
SET (Boost_FIND_REQUIRED TRUE)
SET (Boost_FIND_QUIETLY TRUE)
SET (Boost_DEBUG FALSE)
set (Boost_USE_MULTITHREADED TRUE)
set (Boost_USE_STATIC_LIBS TRUE)
SET (Boost_ADDITIONAL_VERSIONS "1.39" "1.39.0")

FIND_PACKAGE(Boost COMPONENTS program_options )
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})

4: Remove Everything from the current build directory

5: CMake: From a brand new "Visual Studio Command Prompt" I verify
that Boost_ROOT is set correctly then running "CMake-Gui.exe". Click
"Configure" then Generate.

That usually allows CMake to find Boost. Hope that helps.

_________________________________________________________
Mike Jackson ***@bluequartz.net
BlueQuartz Software www.bluequartz.net
Principal Software Engineer Dayton, Ohio
Post by Martin Peter Christiansen
For the last day or so I have tried to compile a project(RobWork)
for Visual Studio 2008 using Cmake.
But my problem is that Cmake claims i can't find Boost dependencies.
I have been googling the problem on the net, but the only answer I
could find was that FindBost.cmake was the problem, but not how to
solve it.
C:\Documents and Settings\Martin>cd c:\local\workspace\RobWork\build
\release
C:\local\workspace\RobWork\build\release>cmake -G "Visual Studio 9
2008" -DCMAKE_BUILD_TYPE=Release
../..
-- RobWork version 0.4.0
-- Build configuration: Release
Policy CMP0011 is not set: Included scripts do automatic
cmake_policy PUSH
and POP. Run "cmake --help-policy CMP0011" for policy details.
Use the
cmake_policy command to set the policy and suppress this warning.
The included script
C:/local/workspace/RobWork/build/ProjectSetup.cmake
affects policy settings. CMake is implying the NO_POLICY_SCOPE
option for
compatibility, so the effects are applied to the including context.
This warning is for project developers. Use -Wno-dev to suppress it.
-- RobWork ROOT dir: C:/local/workspace/RobWork
CMake Error at C:/Programmer/CMake 2.8/share/cmake-2.8/Modules/
Unable to find the requested Boost libraries.
Boost version: 1.39.0
Boost include path: C:/local/boost_1_39_0
boost_thread
No Boost libraries were found. You may need to set
Boost_LIBRARYDIR to the
directory containing Boost libraries or BOOST_ROOT to the location of
Boost.
build/depends.cmake:8 (FIND_PACKAGE)
build/RobWorkSetup.cmake:32 (INCLUDE)
CMakeLists.txt:36 (INCLUDE)
- I have successfully compiled Boost 1.39.0 to Visual studio 2008,
so i get lib files like "libboost_date_time-vc90-mt-1_39.lib" in
<boost-root>/stage/lib.
- Boost have been placed in “C:\local\boost_1_39_0”
- The following environment variables has been added to Windows
BOOST_ROOT = C:\local\boost_1_39_0 and BOOST_LIBRARYDIR = $BOOST_ROOT
\stage\lib
- Both Cmake 2.6 and 2.8r2 have been used to compile the project,
with no success.
What I need is a solution, which can help me compile this project
using Visual Studio 2008
Is there some way I can setup FindBoost.cmake, so it will accept
and boost correctly????
Regards
Martin Peter Christiansen
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
http://www.cmake.org/mailman/listinfo/cmake
troy d. straszheim
2009-11-19 00:53:51 UTC
Permalink
Just to follow up a bit more, here is my recipe for getting Boost up and
running with CMake and Visual Studio.
Another option is to build boost with Boost.CMake, today's 1.41.0
release is here:

http://sodium.resophonic.com/boost-cmake/1.41.0.cmake0/

Docs on building are in the 'doc' subdirectory. Then follow these
directions for building against it:

http://sodium.resophonic.com/boost-cmake/1.41.0.cmake0/doc/exported_targets.html

I'd be glad to see more of you cmake-boosties over on the boost-cmake
list as well, it'd be good to put these assorted FindBoost issues to bed
permanently, we need your testing. If anybody tries that out and finds
it lacking, please let me know, I'm sure there are scenarios|bugs we
haven't worked out yet.

-t

Loading...