templight-tools
templight-tools copied to clipboard
Finding Boost libraries when building
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 ?
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.
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.
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
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.
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:
- 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?
- On
CUSTOM_BOOST_PATH
the variablesBoost_{INCLUDE, LIBRARY}_DIR
are set. I am not sure if these should be actually one ofBoost_INCLUDE_DIRS
orBoost_INCLUDEDIR
(according to documentation) to interact with the rest of cmake's boost finding process. - There are some manual fixes for problems like:
- Some bug in some versions of FindBoost requires that this be set to OFF manually first.
- make sure that the *nix suffixes and prefixes are correct (some cmake installs of findBoost.cmake are wrong with this)
- Did you already hit these with this project or are they there just in case? Anyways the comments could be more specific as to which versions are affected and which bugs occur.
See details in Pull Request https://github.com/mikael-s-persson/templight-tools/pull/8 to compile.