Debian Codegraph @

orocos_kdl/cmake/CheckSTLContainers.cmake

raw
1 # - Macro to check whether the STL containers support incomplete types
2 # The issue at stake is discussed here in depth:
3 # http://www.drdobbs.com/the-standard-librarian-containers-of-inc/184403814
4 #
5 # Empirically libstdc++ and MSVC++ support containers of incomplete types
6 # whereas libc++ does not.
7 #
8 # The result is returned in HAVE_STL_CONTAINER_INCOMPLETE_TYPES
9 #
10 # Copyright 2014 Brian Jensen <Jensen dot J dot Brian at gmail dot com>
11 # Author: Brian Jensen <Jensen dot J dot Brian at gmail dot com>
12 #
13
14 macro(CHECK_STL_CONTAINERS)
15 INCLUDE(CheckCXXSourceCompiles)
16 SET(CMAKE_REQUIRED_FLAGS)
17 CHECK_CXX_SOURCE_COMPILES("
18 #include <string>
19 #include <map>
20 #include <vector>
21
22 class TreeElement;
23 typedef std::map<std::string, TreeElement> SegmentMap;
24
25 class TreeElement
26 {
27 TreeElement(const std::string& name): number(0) {}
28
29 public:
30 int number;
31 SegmentMap::const_iterator parent;
32 std::vector<SegmentMap::const_iterator> children;
33
34 static TreeElement Root(std::string& name)
35 {
36 return TreeElement(name);
37 }
38 };
39
40 int main()
41 {
42 return 0;
43 }
44 "
45 HAVE_STL_CONTAINER_INCOMPLETE_TYPES)
46
47 endmacro(CHECK_STL_CONTAINERS)