templight-tools icon indicating copy to clipboard operation
templight-tools copied to clipboard

Finding Boost libraries when building

Open eldiener opened this issue 9 years ago • 6 comments

Attempting to configure cmake for building the tools it cannot find my Boost libraries. Your doc mentions that the Boost headers are off of the main Boost directory as 'include/boost/' but that has never been the case in Boost distributions on Windows. There the Boost headers are in the 'boost' subdirectory and the Boost libraries are in the 'lib' subdirectory. If I have a Boost directory at 'C:\Utilities\Boost\boost_1_57_0' what do I specify to get the tools built in cmake ?

eldiener avatar May 09 '15 02:05 eldiener

Yeah... finding boost on Windows is always a pain in the neck. My cmake code for dealing with custom boost directories dates back quite a while, it's very possible that it doesn't work any more. These days, you only encounter Windows programmers once in a blue moon, so it hasn't been a priority, and Windows programmers are used to having to manually tweak everything to make things work.

The CMake code that takes care of this is found in the BoilerplateMacros.cmake module file, and it reads as follows:

# if a custom path for boost is provided, than use that (and suppress system paths).
if(EXISTS "${CUSTOM_BOOST_PATH}/include/boost")
  set(Boost_INCLUDE_DIR "${CUSTOM_BOOST_PATH}/include")
  set(Boost_LIBRARY_DIR "${CUSTOM_BOOST_PATH}/lib")
  set(Boost_NO_SYSTEM_PATHS TRUE)
endif()

You could just remove the if-statement and replace the three set-commands with hard-coded paths to your particular distribution and build of boost. But I would highly appreciate it if you could suggest (or make a pull request) a replacement for this bit of code that would work with current boost Windows distributions. I just don't have access to a Windows computer to test it out myself, so I'd appreciate it if you could work that out.

mikael-s-persson avatar May 09 '15 03:05 mikael-s-persson

In Windows if the CUSTOM_BOOST_PATH is a top-level Boost installation, then the include directory is CUSTOM_BOOST_PATH/boost and the library directory is CUSTOM_BOOST_PATH/libs. This is true for every Windows Boost distribution. I do not know CMake well enough to know how it distinguishes between Windows and any other OS, which I would have to know to change the code above.

If you make the change based on the information above, since I suspect you know CMake much better than I do, and put it on some git branch of templight-tools, I will be glad to test it for you under Windows.

Otherwise I will search how to ask CMake if it is executing under Windows or not, fork your code, and create a pull request once my testing is complete.

eldiener avatar May 09 '15 04:05 eldiener

These days, you only encounter Windows programmers once in a blue moon

Three active users here, two using Windows :smile:

how to ask CMake if it is executing under Windows or not

http://www.cmake.org/cmake/help/v3.2/variable/CMAKE_HOST_WIN32.html

wmamrak avatar May 09 '15 09:05 wmamrak

The entire CUSTOM_BOOST_PATH will not work at all. This is because you need Boost_LIBRARIES to also be set in your logic.

I manage to get templight_convert.exe built by setting BOOST_ROOT and BOOST_LIBRARYDIR correctly to a Boost 1.49 distribution where I had built the needed libs. BTW your build fails on the latest versions of Boost.

eldiener avatar May 09 '15 15:05 eldiener

It has been some time since I used Boost with CMake under Windows but it worked right out of the box for me back then.

Reading through BoilerplateMacros.cmake I noticed some things that might relate to this issue:

  1. Explicit versions of boost: This list might be a nightmare to maintain/keep up to date. What are the real restrictions on the version? Maybe there should be a simple check after loading that tells the user when the version is not supported and were to turn for help?
  2. On CUSTOM_BOOST_PATH the variables Boost_{INCLUDE, LIBRARY}_DIR are set. I am not sure if these should be actually one of Boost_INCLUDE_DIRS or Boost_INCLUDEDIR (according to documentation) to interact with the rest of cmake's boost finding process.
  3. There are some manual fixes for problems like:

schulmar avatar May 11 '15 08:05 schulmar

See details in Pull Request https://github.com/mikael-s-persson/templight-tools/pull/8 to compile.

Asher- avatar Jul 22 '17 16:07 Asher-