Carlos Hernandez | 79397c2 | 2014-08-07 17:51:38 -0700 | [diff] [blame] | 1 | # Ceres Solver - A fast non-linear least squares minimizer |
| 2 | # Copyright 2014 Google Inc. All rights reserved. |
| 3 | # http://code.google.com/p/ceres-solver/ |
| 4 | # |
| 5 | # Redistribution and use in source and binary forms, with or without |
| 6 | # modification, are permitted provided that the following conditions are met: |
| 7 | # |
| 8 | # * Redistributions of source code must retain the above copyright notice, |
| 9 | # this list of conditions and the following disclaimer. |
| 10 | # * Redistributions in binary form must reproduce the above copyright notice, |
| 11 | # this list of conditions and the following disclaimer in the documentation |
| 12 | # and/or other materials provided with the distribution. |
| 13 | # * Neither the name of Google Inc. nor the names of its contributors may be |
| 14 | # used to endorse or promote products derived from this software without |
| 15 | # specific prior written permission. |
| 16 | # |
| 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 18 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 19 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 20 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 21 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 22 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 23 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 24 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 25 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 26 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 27 | # POSSIBILITY OF SUCH DAMAGE. |
| 28 | # |
| 29 | # Author: sergey.vfx@gmail.com (Sergey Sharybin) |
| 30 | # |
| 31 | |
| 32 | # FindSharedPtr.cmake - Find shared pointer header and namespace. |
| 33 | # |
| 34 | # This module defines the following variables: |
| 35 | # |
| 36 | # SHARED_PTR_FOUND: TRUE if shared_ptr found. |
| 37 | # SHARED_PTR_TR1_MEMORY_HEADER: True if <tr1/memory> header is to be used |
| 38 | # for the shared_ptr object, otherwise use <memory>. |
| 39 | # SHARED_PTR_TR1_NAMESPACE: TRUE if shared_ptr is defined in std::tr1 namespace, |
| 40 | # otherwise it's assumed to be defined in std namespace. |
| 41 | |
| 42 | MACRO(FIND_SHARED_PTR) |
| 43 | SET(SHARED_PTR_FOUND FALSE) |
| 44 | CHECK_INCLUDE_FILE_CXX(memory HAVE_STD_MEMORY_HEADER) |
| 45 | IF (HAVE_STD_MEMORY_HEADER) |
| 46 | # Finding the memory header doesn't mean that shared_ptr is in std |
| 47 | # namespace. |
| 48 | # |
| 49 | # In particular, MSVC 2008 has shared_ptr declared in std::tr1. In |
| 50 | # order to support this, we do an extra check to see which namespace |
| 51 | # should be used. |
| 52 | INCLUDE(CheckCXXSourceCompiles) |
| 53 | CHECK_CXX_SOURCE_COMPILES("#include <memory> |
| 54 | int main() { |
| 55 | std::shared_ptr<int> int_ptr; |
| 56 | return 0; |
| 57 | }" |
| 58 | HAVE_SHARED_PTR_IN_STD_NAMESPACE) |
| 59 | |
| 60 | IF (HAVE_SHARED_PTR_IN_STD_NAMESPACE) |
| 61 | MESSAGE("-- Found shared_ptr in std namespace using <memory> header.") |
| 62 | SET(SHARED_PTR_FOUND TRUE) |
| 63 | ELSE (HAVE_SHARED_PTR_IN_STD_NAMESPACE) |
| 64 | CHECK_CXX_SOURCE_COMPILES("#include <memory> |
| 65 | int main() { |
| 66 | std::tr1::shared_ptr<int> int_ptr; |
| 67 | return 0; |
| 68 | }" |
| 69 | HAVE_SHARED_PTR_IN_TR1_NAMESPACE) |
| 70 | IF (HAVE_SHARED_PTR_IN_TR1_NAMESPACE) |
| 71 | MESSAGE("-- Found shared_ptr in std::tr1 namespace using <memory> header.") |
| 72 | SET(SHARED_PTR_TR1_NAMESPACE TRUE) |
| 73 | SET(SHARED_PTR_FOUND TRUE) |
| 74 | ENDIF (HAVE_SHARED_PTR_IN_TR1_NAMESPACE) |
| 75 | ENDIF (HAVE_SHARED_PTR_IN_STD_NAMESPACE) |
| 76 | ENDIF (HAVE_STD_MEMORY_HEADER) |
| 77 | |
| 78 | IF (NOT SHARED_PTR_FOUND) |
| 79 | # Further, gcc defines shared_ptr in std::tr1 namespace and |
| 80 | # <tr1/memory> is to be included for this. And what makes things |
| 81 | # even more tricky is that gcc does have <memory> header, so |
| 82 | # all the checks above wouldn't find shared_ptr. |
| 83 | CHECK_INCLUDE_FILE_CXX("tr1/memory" HAVE_TR1_MEMORY_HEADER) |
| 84 | IF (HAVE_TR1_MEMORY_HEADER) |
| 85 | CHECK_CXX_SOURCE_COMPILES("#include <tr1/memory> |
| 86 | int main() { |
| 87 | std::tr1::shared_ptr<int> int_ptr; |
| 88 | return 0; |
| 89 | }" |
| 90 | HAVE_SHARED_PTR_IN_TR1_NAMESPACE_FROM_TR1_MEMORY_HEADER) |
| 91 | IF (HAVE_SHARED_PTR_IN_TR1_NAMESPACE_FROM_TR1_MEMORY_HEADER) |
| 92 | MESSAGE("-- Found shared_ptr in std::tr1 namespace using <tr1/memory> header.") |
| 93 | SET(SHARED_PTR_TR1_MEMORY_HEADER TRUE) |
| 94 | SET(SHARED_PTR_TR1_NAMESPACE TRUE) |
| 95 | SET(SHARED_PTR_FOUND TRUE) |
| 96 | ENDIF (HAVE_SHARED_PTR_IN_TR1_NAMESPACE_FROM_TR1_MEMORY_HEADER) |
| 97 | ENDIF (HAVE_TR1_MEMORY_HEADER) |
| 98 | ENDIF (NOT SHARED_PTR_FOUND) |
| 99 | ENDMACRO(FIND_SHARED_PTR) |