Backport lots of new features from the 1.41.0 branch.
[boost:cmake.git] / tools / CMakeLists.txt
1 #
2 # Copyright Troy D. Straszheim, Doug Gregor
3 #
4 # Distributed under the Boost Software License, Version 1.0.
5 # See http://www.boost.org/LICENSE_1_0.txt
6 #
7
8 macro(boost_collect_lib_dependencies varname filename)
9   #message(STATUS "boost_collect_lib_dependencies.... ${Boost_SOURCE_DIR}/libs")
10   file(GLOB BOOST_LIBRARY_CMAKE_FILES 
11        RELATIVE "${CMAKE_LIBS_SOURCE_DIR}" "${BOOST_LIBS_SOURCE_DIR}/*/${filename}")
12   foreach(BOOST_LIB_CMAKE_FILE ${BOOST_LIBRARY_CMAKE_FILES})
13     #message(STATUS "-- BOOST_LIB_CMAKE_FILE: ${BOOST_LIB_CMAKE_FILE}")
14     get_filename_component(BOOST_LIB_DIR ${BOOST_LIB_CMAKE_FILE} PATH)
15     set(${varname} ${${varname}} ${BOOST_LIB_DIR})
16   endforeach(BOOST_LIB_CMAKE_FILE ${BOOST_LIBRARY_CMAKE_FILES})
17 endmacro(boost_collect_lib_dependencies varname)
18
19
20 # Find all of the subdirectories with .cmake files in them. These are
21 # the libraries with dependencies.
22 boost_collect_lib_dependencies(BOOST_MODULE_DIRS "module.cmake")
23 foreach(subdir ${BOOST_MODULE_DIRS})
24   #message("BOOST_MODULE_DIRS=${BOOST_MODULE_DIRS}")
25   include("${subdir}/module.cmake")
26 endforeach(subdir)
27
28
29 ###############################################################################
30 # This macro is an internal utility macro 
31 # TODO: Document this if it stays around
32 #
33 # example usage:
34 #  boost_tool_dependencies( BOOST_DEPENDS test)
35 #
36 macro(boost_tool_dependencies)
37   parse_arguments(BOOST_TEST 
38     "BOOST_DEPENDS"
39     ""
40     ${ARGN}
41   )
42     set (THIS_TEST_DEPENDS_ALL "")
43     # message (STATUS "BOOST_TEST_BOOST_DEPENDS: ${BOOST_TEST_BOOST_DEPENDS}")
44     foreach(libname ${BOOST_TEST_BOOST_DEPENDS})
45        # message(STATUS "libname: ${libname}")
46         string(TOUPPER "BOOST_${libname}_DEPENDS" THIS_PROJECT_DEPENDS)
47       #  message(STATUS "${THIS_PROJECT_DEPENDS}: ${${THIS_PROJECT_DEPENDS}}")
48        # set(THIS_TEST_DEPENDS_ALL ${libname} ${${THIS_PROJECT_DEPENDS}} )
49       #  message(STATUS "${THIS_TEST_DEPENDS_ALL}: ${${THIS_TEST_DEPENDS_ALL}}")
50         
51        list(FIND THIS_TEST_DEPENDS_ALL ${libname} DEPDEP_INDEX)
52        if (DEPDEP_INDEX EQUAL -1)
53          list(APPEND THIS_TEST_DEPENDS_ALL ${libname})
54          set(ADDED_DEPS TRUE)
55        endif()
56         string(TOUPPER "BOOST_${libname}_DEPENDS" THIS_PROJECT_DEPENDS)
57        # message(STATUS "${additional_lib}: ===> ${${THIS_PROJECT_DEPENDS}}")
58         set(ADDED_DEPS TRUE)
59         while (ADDED_DEPS)
60           set(ADDED_DEPS FALSE)
61           foreach(DEP ${THIS_TEST_DEPENDS_ALL})
62             string(TOUPPER "BOOST_${DEP}_DEPENDS" DEP_DEPENDS)
63             foreach(DEPDEP ${${DEP_DEPENDS}})
64               list(FIND THIS_TEST_DEPENDS_ALL ${DEPDEP} DEPDEP_INDEX)
65               if (DEPDEP_INDEX EQUAL -1)
66                 list(APPEND THIS_TEST_DEPENDS_ALL ${DEPDEP})
67                 set(ADDED_DEPS TRUE)
68               endif()
69             endforeach()
70           endforeach()
71         endwhile()
72       # message(STATUS "->  Dependencies for ${libname}")
73       # message(STATUS "->  THIS_TEST_DEPENDS_ALL: ${THIS_TEST_DEPENDS_ALL}")  
74         
75     endforeach(libname ${BOOST_TEST_BOOST_DEPENDS})
76    foreach (include ${THIS_TEST_DEPENDS_ALL})
77       #
78       # Modularization temporarily disabled
79       #
80       # include_directories("${Boost_SOURCE_DIR}/libs/${include}/include")
81       #
82     endforeach (include ${includes})
83
84 endmacro(boost_tool_dependencies)
85 #
86 ###############################################################################
87
88 set(BUILD_TOOLS "ALL" CACHE STRING "Semicolon-separated list of tools to build")
89
90 message(STATUS "")
91 if (BUILD_TOOLS STREQUAL "NONE")
92
93   message(STATUS "Skipping config of tools since BUILD_TOOLS is \"NONE\"")
94
95 else()
96
97   message(STATUS "Reading tools...")
98   message(STATUS "")
99
100   file(GLOB BOOST_TOOL_CMAKE_FILES 
101        RELATIVE "${CMAKE_TOOLS_PARENT_DIR}" "${BOOST_TOOLS_PARENT_DIR}/*/CMakeLists.txt")
102   foreach(BOOST_TOOL_CMAKE_FILE ${BOOST_TOOL_CMAKE_FILES})
103     get_filename_component(BOOST_TOOL_DIR ${BOOST_TOOL_CMAKE_FILE} PATH)
104     set(tooldirs ${tooldirs} ${BOOST_TOOL_DIR})
105   endforeach()
106
107   foreach(tooldir 
108       ${tooldirs}
109       )
110     get_filename_component(tooldirname ${tooldir} NAME)
111     list(FIND BUILD_TOOLS ${tooldir} THIS_BUILD_TOOLS_INDEX)
112     if ((THIS_BUILD_TOOLS_INDEX GREATER -1) OR (BUILD_TOOLS STREQUAL "ALL"))
113       message(STATUS "+ ${tooldirname}")
114       add_subdirectory(${tooldir})
115     endif()
116
117   endforeach()
118
119 endif()
120   
121 message(STATUS "")
122