|
Boost Interest : |
Subject: Re: [Boost-cmake] CMake modularization update
From: Michael Jackson (mike.jackson_at_[hidden])
Date: 2008-11-01 17:57:32
On Oct 31, 2008, at 8:55 PM, Doug Gregor wrote:
> On Fri, Oct 31, 2008 at 6:13 PM, Michael Jackson
> <mike.jackson_at_[hidden]> wrote:
>> macro(boost_test_add_dependent_includes includes)
>> foreach (include ${includes})
>> #message(STATUS "include: ${include}")
>> include_directories("${Boost_SOURCE_DIR}/libs/${include}/include")
>> endforeach (include ${includes})
>> endmacro(boost_test_add_dependent_includes includes)
>>
>> Which for some of the testing cmake files is being invoked like this:
>>
>> #-------------------------------------------------------------------------
>> #-- Needed include directories for the tests
>> boost_test_add_dependent_includes("utility;detail;config;test;mpl;\
>> bind
>> ;type_traits
>> ;static_assert;preprocessor;array;iterator;exception;range;timer")
>> #-------------------------------------------------------------------------
>>
>> Which is getting ugly quick. I was wanting to do something like is
>> done with
>> the "module.cmake" file to just list the upper dependencies and let
>> cmake
>> figure out all the rest.
>
> The issue here is that we need to describe some dependencies that are
> only needed for testing, but not for the actual library build? It
> seems like there should just be another dependency argument
> (TEST_DEPENDS or something) in each module.cmake for each library, so
> that the direct dependencies are expressed for tests as well as for
> the library build. Then we can use logic like what
> boost_library_project has, to compute all of dependencies
> (transitively) and then add each of those include directories. The
> code I'm talking about is:
>
> 77 # Set THIS_PROJECT_DEPENDS_ALL to the set of all of its
> 78 # dependencies, its dependencies' dependencies, etc.,
> transitively.
> 79 string(TOUPPER "BOOST_${LIBNAME}_DEPENDS" THIS_PROJECT_DEPENDS)
> 80 set(THIS_PROJECT_DEPENDS_ALL ${${THIS_PROJECT_DEPENDS}})
> 81 set(ADDED_DEPS TRUE)
> 82 while (ADDED_DEPS)
> 83 set(ADDED_DEPS FALSE)
> 84 foreach(DEP ${THIS_PROJECT_DEPENDS_ALL})
> 85 string(TOUPPER "BOOST_${DEP}_DEPENDS" DEP_DEPENDS)
> 86 foreach(DEPDEP ${${DEP_DEPENDS}})
> 87 list(FIND THIS_PROJECT_DEPENDS_ALL ${DEPDEP} DEPDEP_INDEX)
> 88 if (DEPDEP_INDEX EQUAL -1)
> 89 list(APPEND THIS_PROJECT_DEPENDS_ALL ${DEPDEP})
> 90 set(ADDED_DEPS TRUE)
> 91 endif()
> 92 endforeach()
> 93 endforeach()
> 94 endwhile()
>
> - Doug
OK I think I got it figured out. I added a new function
boost_additional_test_dependencies() that takes the name of the
library that is being tested in addition to a BOOST_DEPENDS optional
arguments which you list the other libraries (such as test) that the
test will need. So for libs/spirit/test/CMakeLists.txt I have:
boost_additional_test_dependencies(spirit BOOST_DEPENDS test)
which needs to go BEFORE any of the boost_test_* methods are used. The
function is located in BoostTesting.cmake
###############################################################################
# This macro is an internal utility macro
# TODO: Document this if it stays around
#
#
# example usage:
# boost_additional_test_dependencies(spirit BOOST_DEPENDS test)
#
macro(boost_additional_test_dependencies libname)
parse_arguments(BOOST_TEST
"BOOST_DEPENDS"
""
${ARGN}
)
# message (STATUS "BOOST_TEST_BOOST_DEPENDS: $
{BOOST_TEST_BOOST_DEPENDS}")
# Get the list of libraries that this library depends on
# Set THIS_PROJECT_DEPENDS_ALL to the set of all of its
# dependencies, its dependencies' dependencies, etc., transitively.
string(TOUPPER "BOOST_${libname}_DEPENDS" THIS_PROJECT_DEPENDS)
set(THIS_TEST_DEPENDS_ALL ${libname} ${${THIS_PROJECT_DEPENDS}} )
set(ADDED_DEPS TRUE)
while (ADDED_DEPS)
set(ADDED_DEPS FALSE)
foreach(DEP ${THIS_TEST_DEPENDS_ALL})
string(TOUPPER "BOOST_${DEP}_DEPENDS" DEP_DEPENDS)
foreach(DEPDEP ${${DEP_DEPENDS}})
list(FIND THIS_TEST_DEPENDS_ALL ${DEPDEP} DEPDEP_INDEX)
if (DEPDEP_INDEX EQUAL -1)
list(APPEND THIS_TEST_DEPENDS_ALL ${DEPDEP})
set(ADDED_DEPS TRUE)
endif()
endforeach()
endforeach()
endwhile()
# message(STATUS "-> Dependencies for ${libname}")
# message(STATUS "-> THIS_TEST_DEPENDS_ALL: $
{THIS_TEST_DEPENDS_ALL}")
# Get the list of dependencies for the additional libraries arguments
foreach(additional_lib ${BOOST_TEST_BOOST_DEPENDS})
# message(STATUS
"----------------------------------------------------")
list(FIND THIS_TEST_DEPENDS_ALL ${additional_lib} DEPDEP_INDEX)
if (DEPDEP_INDEX EQUAL -1)
list(APPEND THIS_TEST_DEPENDS_ALL ${additional_lib})
set(ADDED_DEPS TRUE)
endif()
string(TOUPPER "BOOST_${additional_lib}_DEPENDS"
THIS_PROJECT_DEPENDS)
# message(STATUS "${additional_lib}: ===> ${$
{THIS_PROJECT_DEPENDS}}")
set(ADDED_DEPS TRUE)
while (ADDED_DEPS)
set(ADDED_DEPS FALSE)
foreach(DEP ${THIS_TEST_DEPENDS_ALL})
string(TOUPPER "BOOST_${DEP}_DEPENDS" DEP_DEPENDS)
foreach(DEPDEP ${${DEP_DEPENDS}})
list(FIND THIS_TEST_DEPENDS_ALL ${DEPDEP} DEPDEP_INDEX)
if (DEPDEP_INDEX EQUAL -1)
list(APPEND THIS_TEST_DEPENDS_ALL ${DEPDEP})
set(ADDED_DEPS TRUE)
endif()
endforeach()
endforeach()
endwhile()
# message(STATUS "-> Dependencies for ${additional_lib}")
# message(STATUS "-> THIS_TEST_DEPENDS_ALL: $
{THIS_TEST_DEPENDS_ALL}")
endforeach()
# message(STATUS " ========================")
# message(STATUS " ALL DEPENDENCIES for ${libname}: $
{THIS_TEST_DEPENDS_ALL}")
# message(STATUS "::>Add include_directories here")
foreach (include ${THIS_TEST_DEPENDS_ALL})
# message(STATUS "include: ${include}")
include_directories("${Boost_SOURCE_DIR}/libs/${include}/
include")
endforeach (include ${includes})
endmacro(boost_additional_test_dependencies libname)
I'll get this stuff committed later this weekend.
_________________________________________________________
Mike Jackson mike.jackson_at_[hidden]
BlueQuartz Software www.bluequartz.net
Principal Software Engineer Dayton, Ohio