Boost logo

Boost Interest :

Subject: Re: [Boost-cmake] Building boost "with an uninstalled build" and linking to boost libs
From: Michael Jackson (mike.jackson_at_[hidden])
Date: 2010-03-24 10:50:59


There are going to be some "growing pains" with Boost-cmake as some
new infrastructure is introduced to the Boost build system.

  I still remain "old" school. I build* boost and install it
somewhere. I then use the following in my CMakeLists.txt file.

SET (Boost_FIND_REQUIRED TRUE)
SET (Boost_FIND_QUIETLY TRUE)
set (Boost_USE_MULTITHREADED TRUE)
set (Boost_USE_STATIC_LIBS TRUE)
SET (Boost_ADDITIONAL_VERSIONS "1.36" "1.36.0" "1.41" "1.41.0" "1.39"
"1.39.0")
FIND_PACKAGE(Boost COMPONENTS ${MXA_BOOST_COMPONENTS} )
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})

This probably isn't the latest "best practices" but does work for my
setup on Windows and OS X.

  * I build boost with CMake most of the time. There are some CMake
variables that you need to set to correct create an installation that
mimics the boost.build installation, which FindBoost.cmake REQUIRES to
successfully find boost.

  The issue that I had (raised on this mailing list) with the exports
(at the time) was that you needed to know the exact way boost was
built (boost-filesystem-mt-shared) which was different on each of my
systems. Using an actual installed boost and letting FindBoost.cmake
do its job gave me better results. Your mileage may vary.

___________________________________________________________
Mike Jackson www.bluequartz.net
Principal Software Engineer mike.jackson_at_[hidden]
BlueQuartz Software Dayton, Ohio

On Mar 24, 2010, at 10:31 AM, Brian Davis wrote:

>
>
> I am currently trying the boost "With an uninstalled build" variety:
>
>
> # Boost Related
> SET( BOOST_LIB_INSTALL_DIR ${BUILD_DIR}/ouput/lib CACHE STRING ""
> FORCE )
> SET( BOOST_EXPORTS_INSTALL_DIR ${BUILD_DIR}/ouput/lib CACHE STRING
> "" FORCE )
> SET( BOOST_INCLUDE_INSTALL_DIR ${BUILD_DIR}/ouput/include CACHE
> STRING "" FORCE )
> #SET( BUILD_PROJECTS NONE CACHE STRING "" FORCE )
> SET( BUILD_PROJECTS thread filesystem CACHE STRING "" FORCE )
>
> add_subdirectory( ${THIRD_PARTY_SRC_DIR}/boost-cmake-1_41_0 ./boost )
>
> reading: http://sodium.resophonic.com/boost-cmake/current-docs/exported_targets.html
> I find:
>
> --snip--
> Example¶
>
> There is an unpacked boost in /home/troy/boost-1.41.0/src and built
> boost in directory /home/troy/boost/1.41.0/build. I have a program
> that builds from one file, main.cpp and uses boost threads. My
> CMakeLists.txt looks like this:
>
> include_directories(
> /home/troy/boost-1.41.0/src
> /home/troy/boost-1.41.0/build/lib/Exports.cmake
> )
>
> add_executable(my_program main.cpp)
>
> target_link_libraries(my_program boost_thread-mt-shared-debug)
>
> --end snip--
>
> The part I don't like was the boost_thread-mt-shared-debug where -
> share-debug needed to be specified. What if I switch to release?
>
>
> When I try to link some boost libs to a test app:
>
>
> TARGET_LINK_LIBRARIES( ${SQUARE_ME_TEST_APP}
> ${MATLAB_CUDA_MEX_NAME}
> ${Boost_FILESYSTEM_LIBRARY}
> ${Boost_SYSTEM_LIBRARY}
> # boost_filesystem-mt-shared-debug
> # boost_filesystem
> )
>
> 3>Linking...
> 3>LINK : fatal error LNK1104: cannot open file 'libboost_filesystem-
> vc90-mt-sgd-1_41.lib'
>
> Now except for hte 'lib" preceeding 'libboost_filesystem-vc90-mt-
> sgd-1_41.lib' as only:
>
> boost_filesystem-vc90-mt-sgd-1_41.lib
> boost_filesystem-vc90-mt-gd-1_41.lib
>
> are build on my Win64 system which I am sure is a result of $
> {Boost_FILESYSTEM_LIBRARY}
>
> What is the best way to link to boost libs? Except for the point
> what did I miss? :-) I am sure it has something to do with (from http://sodium.resophonic.com/boost-cmake/current-docs/exported_targets.html)
> :
>
>
> -snip-
> The problem here is that the real name of the multithreaded, shared,
> debug library target is boost_thread-mt-shared-debug. I know this is
> confusing; much of this is an attempt to be compatible with
> boost.build.
>
> If you are having trouble, have a look inside that file
> Exports.cmake. For each available target, you’ll see:
>
> # Create imported target boost_thread-mt-shared-debug
> ADD_LIBRARY(boost_thread-mt-shared-debug SHARED IMPORTED)
>
> # Import target "boost_thread-mt-shared-debug" for configuration
> "Release"
> SET_PROPERTY(TARGET boost_thread-mt-shared-debug APPEND PROPERTY
> IMPORTED_CONFIGURATIONS RELEASE)
> SET_TARGET_PROPERTIES(boost_thread-mt-shared-debug PROPERTIES
> IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE "pthread;rt"
> IMPORTED_LOCATION_RELEASE "/home/troy/Projects/boost/cmake/
> cmaketest/build/boost/lib/libboost_thread-mt-d.so.1.41.0"
> IMPORTED_SONAME_RELEASE "libboost_thread-mt-d.so.1.41.0"
> )
>
> it is the name in the ADD_LIBRARY line that you pass to
> target_link_libraries().
>
> -end snip-
>
> my exports.cmake file (in trunk\build\dvip4-Win64\lib) shows:
>
> -snip-
> # Create imported target boost_thread-mt-shared
> ADD_LIBRARY(boost_thread-mt-shared SHARED IMPORTED)
>
> # Import target "boost_thread-mt-shared" for configuration "Debug"
> SET_PROPERTY(TARGET boost_thread-mt-shared APPEND PROPERTY
> IMPORTED_CONFIGURATIONS DEBUG)
> SET_TARGET_PROPERTIES(boost_thread-mt-shared PROPERTIES
> IMPORTED_IMPLIB_DEBUG "C:/projects/NIH2009/source/branches/trunk/
> build/dvip4-Win64/lib/Debug/boost_thread-vc90-mt-1_41.lib"
> IMPORTED_LOCATION_DEBUG "C:/projects/NIH2009/source/branches/trunk/
> build/dvip4-Win64/bin/Debug/boost_thread-vc90-mt-1_41.dll"
> )
>
> # Import target "boost_thread-mt-shared" for configuration "Release"
> SET_PROPERTY(TARGET boost_thread-mt-shared APPEND PROPERTY
> IMPORTED_CONFIGURATIONS RELEASE)
> SET_TARGET_PROPERTIES(boost_thread-mt-shared PROPERTIES
> IMPORTED_IMPLIB_RELEASE "C:/projects/NIH2009/source/branches/trunk/
> build/dvip4-Win64/lib/Release/boost_thread-vc90-mt-1_41.lib"
> IMPORTED_LOCATION_RELEASE "C:/projects/NIH2009/source/branches/
> trunk/build/dvip4-Win64/bin/Release/boost_thread-vc90-mt-1_41.dll"
> )
>
> -end snip-
>
> but NO boost_filesystem which I presume has to do with:
>
> SET( BUILD_PROJECTS thread filesystem CACHE STRING "" FORCE )
>
> and the text:
>
> -snip-
> BUILD_PROJECTS¶
>
> This is a semicolon-separated list of projects to be built, or
> "ALL" (the default) for all projects, or "NONE". Projects not
> appearing in this list (if list not "ALL") are ignored; no targets
> in this project will appear. Example:
>
> BUILD_PROJECTS=thread;python
> -end snip-
>
> I also tried
>
> SET( BUILD_PROJECTS "thread;filesystem" CACHE STRING "" FORCE )
>
> Do I need to even specify BUILD_PROJECTS or is there a way to
> specify the dependency in either add_dependencies or in
> target_link_libraries? This may sound crazy, but a build system
> that supports a syntax of dependency checking and building only what
> I need. From what I can tell at the moment with my current level of
> understanding of CMake... CMake really sucks at this. Let me be clear
>
>
> SET(SQUARE_ME_TEST_APP squaremetest )
> ADD_EXECUTABLE( ${SQUARE_ME_TEST_APP} square_me_test.cpp )
>
>
> SET( BOOST_DEPS system filesystem )
>
> find_package( Boost REQUIRED COMPONENTS system filesystem NO_MODULE )
>
> MESSAGE( "Boost_FILESYSTEM_LIBRARY = " ${Boost_FILESYSTEM_LIBRARY} )
>
> TARGET_LINK_LIBRARIES( ${SQUARE_ME_TEST_APP}
> ${MATLAB_CUDA_MEX_NAME}
> ${Boost_FILESYSTEM_LIBRARY}
> ${Boost_SYSTEM_LIBRARY}
> # boost_filesystem-mt-shared-debug
> # boost_filesystem
> )
>
>
> #ADD_DEPENDENCIES( ${SQUARE_ME_TEST_APP} boost-cmake-1_41_0 )
> ADD_DEPENDENCIES( ${SQUARE_ME_TEST_APP} boost_filesystem )
>
> --
> Brian J. Davis
>
> _______________________________________________
> Boost-cmake mailing list
> Boost-cmake_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-cmake


Boost-cmake list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk