Andreas Pakulat wrote:
Ok, I give in. Do you mind separating the loop into two so its easier to
see whats going on and we don't have two use-less cache variables? Then
I'll apply what you send to kdevplatform and add a new version to the
cmake bugreport.
Done. I was resisting that because... well, you can look at the patch
(and see where I had to add redundant code) :-). Although this has the
elegance of not adding new variables. I decided to wrap the insides of
both FOREACH's in "IF(NOT Boost_INCLUDE_DIR)" in the theory that an
empty FOREACH is cheaper than the conditional string manipulation, and
that it's not worth having said IF twice to avoid an empty FOREACH. Of
course it would be easy to change this around.
Anyway, patch attached.
--
Matthew
> pinotree uses the large trout on tsdgeos and PutHuhn :)
> PutHuhn runs
> tsdgeos lights a fire and eats the trout
(with apologies to Pino Toscano, PutHuhn and Albert Astals Cid, who came
up with this entirely on their own)
Index: cmake/modules/FindBoost.cmake
===================================================================
--- cmake/modules/FindBoost.cmake (revision 793035)
+++ cmake/modules/FindBoost.cmake (working copy)
@@ -129,7 +129,7 @@
SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_DEBUG})
SET(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_DEBUG})
ENDIF (Boost_${basename}_LIBRARY_DEBUG AND NOT Boost_${basename}_LIBRARY_RELEASE)
-
+
IF (Boost_${basename}_LIBRARY)
SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY} CACHE FILEPATH "The Boost ${basename} library")
GET_FILENAME_COMPONENT(Boost_LIBRARY_DIRS "${Boost_${basename}_LIBRARY}" PATH)
@@ -234,9 +234,9 @@
ENDIF( Boost_MINIMUM_VERSION )
-
+ # Try first in our own include search paths (e.g. BOOST_ROOT)
FOREACH(_boost_VER ${_boost_TEST_VERSIONS})
- IF( NOT Boost_INCLUDE_DIR )
+ IF(NOT Boost_INCLUDE_DIR)
# Add in a path suffix, based on the required version, ideally we could
# read this from version.hpp, but for that to work we'd need to know the include
@@ -251,45 +251,62 @@
STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1_\\2" _boost_PATH_SUFFIX ${_boost_PATH_SUFFIX})
ENDIF(_boost_PATH_SUFFIX MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
-
- #Prefer our include search paths
FIND_PATH(Boost_INCLUDE_DIR
NAMES boost/config.hpp
PATHS ${_boost_INCLUDE_SEARCH_DIRS}
PATH_SUFFIXES ${_boost_PATH_SUFFIX}
NO_DEFAULT_PATH
)
- #If nothing is found search again using system default paths
- FIND_PATH(Boost_INCLUDE_DIR
- NAMES boost/config.hpp
- PATH_SUFFIXES ${_boost_PATH_SUFFIX}
- )
-
- IF(Boost_INCLUDE_DIR)
- # Extract Boost_VERSION and Boost_LIB_VERSION from version.hpp
- # Read the whole file:
- #
- SET(BOOST_VERSION 0)
- SET(BOOST_LIB_VERSION "")
- FILE(READ "${Boost_INCLUDE_DIR}/boost/version.hpp" _boost_VERSION_HPP_CONTENTS)
-
- STRING(REGEX REPLACE ".*#define BOOST_VERSION ([0-9]+).*" "\\1" Boost_VERSION "${_boost_VERSION_HPP_CONTENTS}")
- STRING(REGEX REPLACE ".*#define BOOST_LIB_VERSION \"([0-9_]+)\".*" "\\1" Boost_LIB_VERSION "${_boost_VERSION_HPP_CONTENTS}")
-
- SET(Boost_LIB_VERSION ${Boost_LIB_VERSION} CACHE STRING "The library version string for boost libraries")
- SET(Boost_VERSION ${Boost_VERSION} CACHE STRING "The version number for boost libraries")
-
- IF(NOT "${Boost_VERSION}" STREQUAL "0")
- MATH(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000")
- MATH(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000")
- MATH(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100")
- ENDIF(NOT "${Boost_VERSION}" STREQUAL "0")
- ENDIF(Boost_INCLUDE_DIR)
+ ENDIF(NOT Boost_INCLUDE_DIR)
+ ENDFOREACH(_boost_VER)
- ENDIF( NOT Boost_INCLUDE_DIR )
+ # If nothing is found search again using system default paths
+ FOREACH(_boost_VER ${_boost_TEST_VERSIONS})
+ IF(NOT Boost_INCLUDE_DIR)
+
+ # Add in a path suffix, based on the required version, ideally we could
+ # read this from version.hpp, but for that to work we'd need to know the include
+ # dir already
+ SET(_boost_PATH_SUFFIX
+ boost-${_boost_VER}
+ )
+
+ IF(_boost_PATH_SUFFIX MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
+ STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1_\\2_\\3" _boost_PATH_SUFFIX ${_boost_PATH_SUFFIX})
+ ELSEIF(_boost_PATH_SUFFIX MATCHES "[0-9]+\\.[0-9]+")
+ STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1_\\2" _boost_PATH_SUFFIX ${_boost_PATH_SUFFIX})
+ ENDIF(_boost_PATH_SUFFIX MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
+
+ FIND_PATH(Boost_INCLUDE_DIR
+ NAMES boost/config.hpp
+ PATH_SUFFIXES ${_boost_PATH_SUFFIX}
+ )
+
+ ENDIF(NOT Boost_INCLUDE_DIR)
ENDFOREACH(_boost_VER)
+ IF(Boost_INCLUDE_DIR)
+ # Extract Boost_VERSION and Boost_LIB_VERSION from version.hpp
+ # Read the whole file:
+ #
+ SET(BOOST_VERSION 0)
+ SET(BOOST_LIB_VERSION "")
+ FILE(READ "${Boost_INCLUDE_DIR}/boost/version.hpp" _boost_VERSION_HPP_CONTENTS)
+
+ STRING(REGEX REPLACE ".*#define BOOST_VERSION ([0-9]+).*" "\\1" Boost_VERSION "${_boost_VERSION_HPP_CONTENTS}")
+ STRING(REGEX REPLACE ".*#define BOOST_LIB_VERSION \"([0-9_]+)\".*" "\\1" Boost_LIB_VERSION "${_boost_VERSION_HPP_CONTENTS}")
+
+ SET(Boost_LIB_VERSION ${Boost_LIB_VERSION} CACHE STRING "The library version string for boost libraries")
+ SET(Boost_VERSION ${Boost_VERSION} CACHE STRING "The version number for boost libraries")
+
+ IF(NOT "${Boost_VERSION}" STREQUAL "0")
+ MATH(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000")
+ MATH(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000")
+ MATH(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100")
+ ENDIF(NOT "${Boost_VERSION}" STREQUAL "0")
+ ENDIF(Boost_INCLUDE_DIR)
+
#Setting some more suffixes for the library
SET (Boost_LIB_PREFIX "")
IF ( WIN32 )
_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake