Added cmake subdirectory without history (at SVN r20364)
parent
f8bb2cf371
commit
395b8a2f48
|
@ -0,0 +1,23 @@
|
|||
# - Config file for @CMAKE_PROJECT_NAME@
|
||||
# It defines the following variables
|
||||
# @PACKAGE_NAME@_INCLUDE_DIR - include directories for @CMAKE_PROJECT_NAME@
|
||||
|
||||
# Compute paths
|
||||
get_filename_component(OUR_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||
if(EXISTS "${OUR_CMAKE_DIR}/CMakeCache.txt")
|
||||
# In build tree
|
||||
set(@PACKAGE_NAME@_INCLUDE_DIR @CMAKE_SOURCE_DIR@ CACHE PATH "@PACKAGE_NAME@ include directory")
|
||||
else()
|
||||
# Find installed library
|
||||
set(@PACKAGE_NAME@_INCLUDE_DIR "${OUR_CMAKE_DIR}/@CONF_REL_INCLUDE_DIR@" CACHE PATH "@PACKAGE_NAME@ include directory")
|
||||
endif()
|
||||
|
||||
# Load exports
|
||||
include(${OUR_CMAKE_DIR}/@PACKAGE_NAME@-exports.cmake)
|
||||
|
||||
# Load project-specific flags, if present
|
||||
if(EXISTS "${OUR_CMAKE_DIR}/@EXTRA_FILE@")
|
||||
include("${OUR_CMAKE_DIR}/@EXTRA_FILE@")
|
||||
endif()
|
||||
|
||||
message(STATUS "@CMAKE_PROJECT_NAME@ include directory: ${@CMAKE_PROJECT_NAME@_INCLUDE_DIR}")
|
|
@ -0,0 +1,81 @@
|
|||
# - Try to find Eigen3 lib
|
||||
#
|
||||
# This module supports requiring a minimum version, e.g. you can do
|
||||
# find_package(Eigen3 3.1.2)
|
||||
# to require version 3.1.2 or newer of Eigen3.
|
||||
#
|
||||
# Once done this will define
|
||||
#
|
||||
# EIGEN3_FOUND - system has eigen lib with correct version
|
||||
# EIGEN3_INCLUDE_DIR - the eigen include directory
|
||||
# EIGEN3_VERSION - eigen version
|
||||
|
||||
# Copyright (c) 2006, 2007 Montel Laurent, <montel@kde.org>
|
||||
# Copyright (c) 2008, 2009 Gael Guennebaud, <g.gael@free.fr>
|
||||
# Copyright (c) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
|
||||
# Redistribution and use is allowed according to the terms of the 2-clause BSD license.
|
||||
|
||||
if(NOT Eigen3_FIND_VERSION)
|
||||
if(NOT Eigen3_FIND_VERSION_MAJOR)
|
||||
set(Eigen3_FIND_VERSION_MAJOR 2)
|
||||
endif(NOT Eigen3_FIND_VERSION_MAJOR)
|
||||
if(NOT Eigen3_FIND_VERSION_MINOR)
|
||||
set(Eigen3_FIND_VERSION_MINOR 91)
|
||||
endif(NOT Eigen3_FIND_VERSION_MINOR)
|
||||
if(NOT Eigen3_FIND_VERSION_PATCH)
|
||||
set(Eigen3_FIND_VERSION_PATCH 0)
|
||||
endif(NOT Eigen3_FIND_VERSION_PATCH)
|
||||
|
||||
set(Eigen3_FIND_VERSION "${Eigen3_FIND_VERSION_MAJOR}.${Eigen3_FIND_VERSION_MINOR}.${Eigen3_FIND_VERSION_PATCH}")
|
||||
endif(NOT Eigen3_FIND_VERSION)
|
||||
|
||||
macro(_eigen3_check_version)
|
||||
file(READ "${EIGEN3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _eigen3_version_header)
|
||||
|
||||
string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match "${_eigen3_version_header}")
|
||||
set(EIGEN3_WORLD_VERSION "${CMAKE_MATCH_1}")
|
||||
string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen3_major_version_match "${_eigen3_version_header}")
|
||||
set(EIGEN3_MAJOR_VERSION "${CMAKE_MATCH_1}")
|
||||
string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen3_minor_version_match "${_eigen3_version_header}")
|
||||
set(EIGEN3_MINOR_VERSION "${CMAKE_MATCH_1}")
|
||||
|
||||
set(EIGEN3_VERSION ${EIGEN3_WORLD_VERSION}.${EIGEN3_MAJOR_VERSION}.${EIGEN3_MINOR_VERSION})
|
||||
if(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
|
||||
set(EIGEN3_VERSION_OK FALSE)
|
||||
else(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
|
||||
set(EIGEN3_VERSION_OK TRUE)
|
||||
endif(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
|
||||
|
||||
if(NOT EIGEN3_VERSION_OK)
|
||||
|
||||
message(STATUS "Eigen3 version ${EIGEN3_VERSION} found in ${EIGEN3_INCLUDE_DIR}, "
|
||||
"but at least version ${Eigen3_FIND_VERSION} is required")
|
||||
endif(NOT EIGEN3_VERSION_OK)
|
||||
endmacro(_eigen3_check_version)
|
||||
|
||||
if (EIGEN3_INCLUDE_DIR)
|
||||
|
||||
# in cache already
|
||||
_eigen3_check_version()
|
||||
set(EIGEN3_FOUND ${EIGEN3_VERSION_OK})
|
||||
|
||||
else (EIGEN3_INCLUDE_DIR)
|
||||
|
||||
find_path(EIGEN3_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library
|
||||
PATHS
|
||||
${CMAKE_INSTALL_PREFIX}/include
|
||||
${KDE4_INCLUDE_DIR}
|
||||
PATH_SUFFIXES eigen3 eigen
|
||||
)
|
||||
|
||||
if(EIGEN3_INCLUDE_DIR)
|
||||
_eigen3_check_version()
|
||||
endif(EIGEN3_INCLUDE_DIR)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Eigen3 DEFAULT_MSG EIGEN3_INCLUDE_DIR EIGEN3_VERSION_OK)
|
||||
|
||||
mark_as_advanced(EIGEN3_INCLUDE_DIR)
|
||||
|
||||
endif(EIGEN3_INCLUDE_DIR)
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
# -*- cmake -*-
|
||||
|
||||
# - Find Google perftools
|
||||
# Find the Google perftools includes and libraries
|
||||
# This module defines
|
||||
# GOOGLE_PERFTOOLS_INCLUDE_DIR, where to find heap-profiler.h, etc.
|
||||
# GOOGLE_PERFTOOLS_FOUND, If false, do not try to use Google perftools.
|
||||
# also defined for general use are
|
||||
# TCMALLOC_LIBRARY, where to find the tcmalloc library.
|
||||
|
||||
FIND_PATH(GOOGLE_PERFTOOLS_INCLUDE_DIR google/heap-profiler.h
|
||||
/usr/local/include
|
||||
/usr/include
|
||||
)
|
||||
|
||||
SET(TCMALLOC_NAMES ${TCMALLOC_NAMES} tcmalloc)
|
||||
FIND_LIBRARY(TCMALLOC_LIBRARY
|
||||
NAMES ${TCMALLOC_NAMES}
|
||||
PATHS /usr/lib /usr/local/lib
|
||||
)
|
||||
|
||||
IF (TCMALLOC_LIBRARY AND GOOGLE_PERFTOOLS_INCLUDE_DIR)
|
||||
SET(TCMALLOC_LIBRARIES ${TCMALLOC_LIBRARY})
|
||||
SET(GOOGLE_PERFTOOLS_FOUND "YES")
|
||||
ELSE (TCMALLOC_LIBRARY AND GOOGLE_PERFTOOLS_INCLUDE_DIR)
|
||||
SET(GOOGLE_PERFTOOLS_FOUND "NO")
|
||||
ENDIF (TCMALLOC_LIBRARY AND GOOGLE_PERFTOOLS_INCLUDE_DIR)
|
||||
|
||||
IF (GOOGLE_PERFTOOLS_FOUND)
|
||||
IF (NOT GOOGLE_PERFTOOLS_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Found Google perftools: ${GOOGLE_PERFTOOLS_LIBRARIES}")
|
||||
ENDIF (NOT GOOGLE_PERFTOOLS_FIND_QUIETLY)
|
||||
ELSE (GOOGLE_PERFTOOLS_FOUND)
|
||||
IF (GOOGLE_PERFTOOLS_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "Could not find Google perftools library")
|
||||
ENDIF (GOOGLE_PERFTOOLS_FIND_REQUIRED)
|
||||
ENDIF (GOOGLE_PERFTOOLS_FOUND)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
TCMALLOC_LIBRARY
|
||||
GOOGLE_PERFTOOLS_INCLUDE_DIR
|
||||
)
|
|
@ -0,0 +1,241 @@
|
|||
# This file is adapted from the one in OpenMEEG: http://www-sop.inria.fr/athena/software/OpenMEEG/
|
||||
# - Try to find the Intel Math Kernel Library
|
||||
# Once done this will define
|
||||
#
|
||||
# MKL_FOUND - system has MKL
|
||||
# MKL_ROOT_DIR - path to the MKL base directory
|
||||
# MKL_INCLUDE_DIR - the MKL include directory
|
||||
# MKL_LIBRARIES - MKL libraries
|
||||
#
|
||||
# There are few sets of libraries:
|
||||
# Array indexes modes:
|
||||
# LP - 32 bit indexes of arrays
|
||||
# ILP - 64 bit indexes of arrays
|
||||
# Threading:
|
||||
# SEQUENTIAL - no threading
|
||||
# INTEL - Intel threading library
|
||||
# GNU - GNU threading library
|
||||
# MPI support
|
||||
# NOMPI - no MPI support
|
||||
# INTEL - Intel MPI library
|
||||
# OPEN - Open MPI library
|
||||
# SGI - SGI MPT Library
|
||||
|
||||
# linux
|
||||
IF(UNIX AND NOT APPLE)
|
||||
IF(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64")
|
||||
SET(MKL_ARCH_DIR "intel64")
|
||||
ELSE()
|
||||
SET(MKL_ARCH_DIR "32")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
# macos
|
||||
IF(APPLE)
|
||||
SET(MKL_ARCH_DIR "intel64")
|
||||
ENDIF()
|
||||
|
||||
IF(FORCE_BUILD_32BITS)
|
||||
set(MKL_ARCH_DIR "32")
|
||||
ENDIF()
|
||||
# windows
|
||||
IF(WIN32)
|
||||
IF(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
|
||||
SET(MKL_ARCH_DIR "intel64")
|
||||
ELSE()
|
||||
SET(MKL_ARCH_DIR "ia32")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
SET(MKL_THREAD_VARIANTS SEQUENTIAL GNUTHREAD INTELTHREAD)
|
||||
SET(MKL_MODE_VARIANTS ILP LP)
|
||||
SET(MKL_MPI_VARIANTS NOMPI INTELMPI OPENMPI SGIMPT)
|
||||
|
||||
FIND_PATH(MKL_ROOT_DIR
|
||||
include/mkl_cblas.h
|
||||
PATHS
|
||||
$ENV{MKLDIR}
|
||||
/opt/intel/mkl/
|
||||
/opt/intel/mkl/*/
|
||||
/opt/intel/cmkl/
|
||||
/opt/intel/cmkl/*/
|
||||
/Library/Frameworks/Intel_MKL.framework/Versions/Current/lib/universal
|
||||
"C:/Program Files (x86)/Intel/ComposerXE-2011/mkl"
|
||||
"C:/Program Files (x86)/Intel/Composer XE 2013/mkl"
|
||||
"C:/Program Files/Intel/MKL/*/"
|
||||
"C:/Program Files/Intel/ComposerXE-2011/mkl"
|
||||
"C:/Program Files/Intel/Composer XE 2013/mkl"
|
||||
)
|
||||
|
||||
FIND_PATH(MKL_INCLUDE_DIR
|
||||
mkl_cblas.h
|
||||
PATHS
|
||||
${MKL_ROOT_DIR}/include
|
||||
${INCLUDE_INSTALL_DIR}
|
||||
)
|
||||
|
||||
FIND_PATH(MKL_FFTW_INCLUDE_DIR
|
||||
fftw3.h
|
||||
PATH_SUFFIXES fftw
|
||||
PATHS
|
||||
${MKL_ROOT_DIR}/include
|
||||
${INCLUDE_INSTALL_DIR}
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
||||
IF(WIN32)
|
||||
SET(MKL_LIB_SEARCHPATH $ENV{ICC_LIB_DIR} $ENV{MKL_LIB_DIR} "${MKL_ROOT_DIR}/lib/${MKL_ARCH_DIR}" "${MKL_ROOT_DIR}/../compiler" "${MKL_ROOT_DIR}/../compiler/lib/${MKL_ARCH_DIR}")
|
||||
|
||||
IF (MKL_INCLUDE_DIR MATCHES "10.")
|
||||
IF(CMAKE_CL_64)
|
||||
SET(MKL_LIBS mkl_solver_lp64 mkl_core mkl_intel_lp64 mkl_intel_thread libguide mkl_lapack95_lp64 mkl_blas95_lp64)
|
||||
ELSE()
|
||||
SET(MKL_LIBS mkl_solver mkl_core mkl_intel_c mkl_intel_s mkl_intel_thread libguide mkl_lapack95 mkl_blas95)
|
||||
ENDIF()
|
||||
ELSEIF(MKL_INCLUDE_DIR MATCHES "2013") # version 11 ...
|
||||
IF(CMAKE_CL_64)
|
||||
SET(MKL_LIBS mkl_core mkl_intel_lp64 mkl_intel_thread libiomp5md mkl_lapack95_lp64 mkl_blas95_lp64)
|
||||
ELSE()
|
||||
SET(MKL_LIBS mkl_core mkl_intel_c mkl_intel_s mkl_intel_thread libiomp5md mkl_lapack95 mkl_blas95)
|
||||
ENDIF()
|
||||
ELSE() # old MKL 9
|
||||
SET(MKL_LIBS mkl_solver mkl_c libguide mkl_lapack mkl_ia32)
|
||||
ENDIF()
|
||||
|
||||
IF (MKL_INCLUDE_DIR MATCHES "10.3")
|
||||
SET(MKL_LIBS ${MKL_LIBS} libiomp5md)
|
||||
ENDIF()
|
||||
|
||||
FOREACH (LIB ${MKL_LIBS})
|
||||
FIND_LIBRARY(${LIB}_PATH ${LIB} PATHS ${MKL_LIB_SEARCHPATH} ENV LIBRARY_PATH)
|
||||
IF(${LIB}_PATH)
|
||||
SET(MKL_LIBRARIES ${MKL_LIBRARIES} ${${LIB}_PATH})
|
||||
ELSE()
|
||||
MESSAGE(STATUS "Could not find ${LIB}: disabling MKL")
|
||||
ENDIF()
|
||||
ENDFOREACH()
|
||||
SET(MKL_FOUND ON)
|
||||
ELSE() # UNIX and macOS
|
||||
FIND_LIBRARY(MKL_CORE_LIBRARY
|
||||
mkl_core
|
||||
PATHS
|
||||
${MKL_ROOT_DIR}/lib/${MKL_ARCH_DIR}
|
||||
${MKL_ROOT_DIR}/lib/
|
||||
)
|
||||
|
||||
# Threading libraries
|
||||
FIND_LIBRARY(MKL_SEQUENTIAL_LIBRARY
|
||||
mkl_sequential
|
||||
PATHS
|
||||
${MKL_ROOT_DIR}/lib/${MKL_ARCH_DIR}
|
||||
${MKL_ROOT_DIR}/lib/
|
||||
)
|
||||
|
||||
FIND_LIBRARY(MKL_INTELTHREAD_LIBRARY
|
||||
mkl_intel_thread
|
||||
PATHS
|
||||
${MKL_ROOT_DIR}/lib/${MKL_ARCH_DIR}
|
||||
${MKL_ROOT_DIR}/lib/
|
||||
)
|
||||
|
||||
FIND_LIBRARY(MKL_GNUTHREAD_LIBRARY
|
||||
mkl_gnu_thread
|
||||
PATHS
|
||||
${MKL_ROOT_DIR}/lib/${MKL_ARCH_DIR}
|
||||
${MKL_ROOT_DIR}/lib/
|
||||
)
|
||||
|
||||
# Intel Libraries
|
||||
IF("${MKL_ARCH_DIR}" STREQUAL "32")
|
||||
FIND_LIBRARY(MKL_LP_LIBRARY
|
||||
mkl_intel
|
||||
PATHS
|
||||
${MKL_ROOT_DIR}/lib/${MKL_ARCH_DIR}
|
||||
${MKL_ROOT_DIR}/lib/
|
||||
)
|
||||
|
||||
FIND_LIBRARY(MKL_ILP_LIBRARY
|
||||
mkl_intel
|
||||
PATHS
|
||||
${MKL_ROOT_DIR}/lib/${MKL_ARCH_DIR}
|
||||
${MKL_ROOT_DIR}/lib/
|
||||
)
|
||||
else()
|
||||
FIND_LIBRARY(MKL_LP_LIBRARY
|
||||
mkl_intel_lp64
|
||||
PATHS
|
||||
${MKL_ROOT_DIR}/lib/${MKL_ARCH_DIR}
|
||||
${MKL_ROOT_DIR}/lib/
|
||||
)
|
||||
|
||||
FIND_LIBRARY(MKL_ILP_LIBRARY
|
||||
mkl_intel_ilp64
|
||||
PATHS
|
||||
${MKL_ROOT_DIR}/lib/${MKL_ARCH_DIR}
|
||||
${MKL_ROOT_DIR}/lib/
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
# Lapack
|
||||
FIND_LIBRARY(MKL_LAPACK_LIBRARY
|
||||
mkl_lapack
|
||||
PATHS
|
||||
${MKL_ROOT_DIR}/lib/${MKL_ARCH_DIR}
|
||||
${MKL_ROOT_DIR}/lib/
|
||||
)
|
||||
|
||||
IF(NOT MKL_LAPACK_LIBRARY)
|
||||
FIND_LIBRARY(MKL_LAPACK_LIBRARY
|
||||
mkl_lapack95_lp64
|
||||
PATHS
|
||||
${MKL_ROOT_DIR}/lib/${MKL_ARCH_DIR}
|
||||
${MKL_ROOT_DIR}/lib/
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
# iomp5
|
||||
IF("${MKL_ARCH_DIR}" STREQUAL "32")
|
||||
IF(UNIX AND NOT APPLE)
|
||||
FIND_LIBRARY(MKL_IOMP5_LIBRARY
|
||||
iomp5
|
||||
PATHS
|
||||
${MKL_ROOT_DIR}/../lib/ia32
|
||||
)
|
||||
ELSE()
|
||||
SET(MKL_IOMP5_LIBRARY "") # no need for mac
|
||||
ENDIF()
|
||||
else()
|
||||
IF(UNIX AND NOT APPLE)
|
||||
FIND_LIBRARY(MKL_IOMP5_LIBRARY
|
||||
iomp5
|
||||
PATHS
|
||||
${MKL_ROOT_DIR}/../lib/intel64
|
||||
)
|
||||
ELSE()
|
||||
SET(MKL_IOMP5_LIBRARY "") # no need for mac
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
foreach (MODEVAR ${MKL_MODE_VARIANTS})
|
||||
foreach (THREADVAR ${MKL_THREAD_VARIANTS})
|
||||
if (MKL_CORE_LIBRARY AND MKL_${MODEVAR}_LIBRARY AND MKL_${THREADVAR}_LIBRARY)
|
||||
set(MKL_${MODEVAR}_${THREADVAR}_LIBRARIES
|
||||
${MKL_${MODEVAR}_LIBRARY} ${MKL_${THREADVAR}_LIBRARY} ${MKL_CORE_LIBRARY}
|
||||
${MKL_LAPACK_LIBRARY} ${MKL_IOMP5_LIBRARY})
|
||||
# message("${MODEVAR} ${THREADVAR} ${MKL_${MODEVAR}_${THREADVAR}_LIBRARIES}") # for debug
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
SET(MKL_LIBRARIES ${MKL_LP_GNUTHREAD_LIBRARIES})
|
||||
MARK_AS_ADVANCED(MKL_CORE_LIBRARY MKL_LP_LIBRARY MKL_ILP_LIBRARY
|
||||
MKL_SEQUENTIAL_LIBRARY MKL_INTELTHREAD_LIBRARY MKL_GNUTHREAD_LIBRARY)
|
||||
ENDIF()
|
||||
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(MKL DEFAULT_MSG MKL_INCLUDE_DIR MKL_LIBRARIES)
|
||||
|
||||
#if(MKL_FOUND)
|
||||
# LINK_DIRECTORIES(${MKL_ROOT_DIR}/lib/${MKL_ARCH_DIR}) # hack
|
||||
#endif()
|
||||
|
||||
MARK_AS_ADVANCED(MKL_INCLUDE_DIR MKL_LIBRARIES)
|
|
@ -0,0 +1,306 @@
|
|||
# Locate Intel Threading Building Blocks include paths and libraries
|
||||
# FindTBB.cmake can be found at https://code.google.com/p/findtbb/
|
||||
# Written by Hannes Hofmann <hannes.hofmann _at_ informatik.uni-erlangen.de>
|
||||
# Improvements by Gino van den Bergen <gino _at_ dtecta.com>,
|
||||
# Florian Uhlig <F.Uhlig _at_ gsi.de>,
|
||||
# Jiri Marsik <jiri.marsik89 _at_ gmail.com>
|
||||
|
||||
# The MIT License
|
||||
#
|
||||
# Copyright (c) 2011 Hannes Hofmann
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
|
||||
# GvdB: This module uses the environment variable TBB_ARCH_PLATFORM which defines architecture and compiler.
|
||||
# e.g. "ia32/vc8" or "em64t/cc4.1.0_libc2.4_kernel2.6.16.21"
|
||||
# TBB_ARCH_PLATFORM is set by the build script tbbvars[.bat|.sh|.csh], which can be found
|
||||
# in the TBB installation directory (TBB_INSTALL_DIR).
|
||||
#
|
||||
# GvdB: Mac OS X distribution places libraries directly in lib directory.
|
||||
#
|
||||
# For backwards compatibility, you may explicitely set the CMake variables TBB_ARCHITECTURE and TBB_COMPILER.
|
||||
# TBB_ARCHITECTURE [ ia32 | em64t | itanium ]
|
||||
# which architecture to use
|
||||
# TBB_COMPILER e.g. vc9 or cc3.2.3_libc2.3.2_kernel2.4.21 or cc4.0.1_os10.4.9
|
||||
# which compiler to use (detected automatically on Windows)
|
||||
|
||||
# This module respects
|
||||
# TBB_INSTALL_DIR or $ENV{TBB21_INSTALL_DIR} or $ENV{TBB_INSTALL_DIR}
|
||||
|
||||
# This module defines
|
||||
# TBB_INCLUDE_DIRS, where to find task_scheduler_init.h, etc.
|
||||
# TBB_LIBRARY_DIRS, where to find libtbb, libtbbmalloc
|
||||
# TBB_DEBUG_LIBRARY_DIRS, where to find libtbb_debug, libtbbmalloc_debug
|
||||
# TBB_INSTALL_DIR, the base TBB install directory
|
||||
# TBB_LIBRARIES, the libraries to link against to use TBB.
|
||||
# TBB_DEBUG_LIBRARIES, the libraries to link against to use TBB with debug symbols.
|
||||
# TBB_FOUND, If false, don't try to use TBB.
|
||||
# TBB_INTERFACE_VERSION, as defined in tbb/tbb_stddef.h
|
||||
|
||||
|
||||
if (WIN32)
|
||||
# has em64t/vc8 em64t/vc9
|
||||
# has ia32/vc7.1 ia32/vc8 ia32/vc9
|
||||
set(_TBB_DEFAULT_INSTALL_DIR "C:/Program Files/Intel/TBB")
|
||||
set(_TBB_LIB_NAME "tbb")
|
||||
set(_TBB_LIB_MALLOC_NAME "${_TBB_LIB_NAME}malloc")
|
||||
set(_TBB_LIB_DEBUG_NAME "${_TBB_LIB_NAME}_debug")
|
||||
set(_TBB_LIB_MALLOC_DEBUG_NAME "${_TBB_LIB_MALLOC_NAME}_debug")
|
||||
if (MSVC71)
|
||||
set (_TBB_COMPILER "vc7.1")
|
||||
set (TBB_COMPILER "vc7.1")
|
||||
endif(MSVC71)
|
||||
if (MSVC80)
|
||||
set(_TBB_COMPILER "vc8")
|
||||
set(TBB_COMPILER "vc8")
|
||||
endif(MSVC80)
|
||||
if (MSVC90)
|
||||
set(_TBB_COMPILER "vc9")
|
||||
set(TBB_COMPILER "vc9")
|
||||
endif(MSVC90)
|
||||
if(MSVC10)
|
||||
set(_TBB_COMPILER "vc10")
|
||||
set(TBB_COMPILER "vc10")
|
||||
endif(MSVC10)
|
||||
if(MSVC11)
|
||||
set(_TBB_COMPILER "vc11")
|
||||
set(TBB_COMPILER "vc11")
|
||||
endif(MSVC11)
|
||||
# Todo: add other Windows compilers such as ICL.
|
||||
if(TBB_ARCHITECTURE)
|
||||
set(_TBB_ARCHITECTURE ${TBB_ARCHITECTURE})
|
||||
elseif("$ENV{TBB_ARCH_PLATFORM}" STREQUAL "")
|
||||
# Try to guess the architecture
|
||||
if(CMAKE_CL_64)
|
||||
set(_TBB_ARCHITECTURE intel64)
|
||||
set(TBB_ARCHITECTURE intel64)
|
||||
else()
|
||||
set(_TBB_ARCHITECTURE ia32)
|
||||
set(TBB_ARCHITECTURE ia32)
|
||||
endif()
|
||||
endif()
|
||||
endif (WIN32)
|
||||
|
||||
if (UNIX)
|
||||
if (APPLE)
|
||||
# MAC
|
||||
set(_TBB_DEFAULT_INSTALL_DIR "/Library/Frameworks/Intel_TBB.framework/Versions")
|
||||
# libs: libtbb.dylib, libtbbmalloc.dylib, *_debug
|
||||
set(_TBB_LIB_NAME "tbb")
|
||||
set(_TBB_LIB_MALLOC_NAME "${_TBB_LIB_NAME}malloc")
|
||||
set(_TBB_LIB_DEBUG_NAME "${_TBB_LIB_NAME}_debug")
|
||||
set(_TBB_LIB_MALLOC_DEBUG_NAME "${_TBB_LIB_MALLOC_NAME}_debug")
|
||||
# default flavor on apple: ia32/cc4.0.1_os10.4.9
|
||||
# Jiri: There is no reason to presume there is only one flavor and
|
||||
# that user's setting of variables should be ignored.
|
||||
if(NOT TBB_COMPILER)
|
||||
set(_TBB_COMPILER "cc4.0.1_os10.4.9")
|
||||
elseif (NOT TBB_COMPILER)
|
||||
set(_TBB_COMPILER ${TBB_COMPILER})
|
||||
endif(NOT TBB_COMPILER)
|
||||
if(NOT TBB_ARCHITECTURE)
|
||||
set(_TBB_ARCHITECTURE "ia32")
|
||||
elseif(NOT TBB_ARCHITECTURE)
|
||||
set(_TBB_ARCHITECTURE ${TBB_ARCHITECTURE})
|
||||
endif(NOT TBB_ARCHITECTURE)
|
||||
else (APPLE)
|
||||
# LINUX
|
||||
set(_TBB_DEFAULT_INSTALL_DIR "/opt/intel/tbb" "/usr/local/include" "/usr/include")
|
||||
set(_TBB_LIB_NAME "tbb")
|
||||
set(_TBB_LIB_MALLOC_NAME "${_TBB_LIB_NAME}malloc")
|
||||
set(_TBB_LIB_DEBUG_NAME "${_TBB_LIB_NAME}_debug")
|
||||
set(_TBB_LIB_MALLOC_DEBUG_NAME "${_TBB_LIB_MALLOC_NAME}_debug")
|
||||
# has em64t/cc3.2.3_libc2.3.2_kernel2.4.21 em64t/cc3.3.3_libc2.3.3_kernel2.6.5 em64t/cc3.4.3_libc2.3.4_kernel2.6.9 em64t/cc4.1.0_libc2.4_kernel2.6.16.21
|
||||
# has ia32/*
|
||||
# has itanium/*
|
||||
set(_TBB_COMPILER ${TBB_COMPILER})
|
||||
set(_TBB_ARCHITECTURE ${TBB_ARCHITECTURE})
|
||||
endif (APPLE)
|
||||
endif (UNIX)
|
||||
|
||||
if (CMAKE_SYSTEM MATCHES "SunOS.*")
|
||||
# SUN
|
||||
# not yet supported
|
||||
# has em64t/cc3.4.3_kernel5.10
|
||||
# has ia32/*
|
||||
endif (CMAKE_SYSTEM MATCHES "SunOS.*")
|
||||
|
||||
|
||||
#-- Clear the public variables
|
||||
set (TBB_FOUND "NO")
|
||||
|
||||
|
||||
#-- Find TBB install dir and set ${_TBB_INSTALL_DIR} and cached ${TBB_INSTALL_DIR}
|
||||
# first: use CMake variable TBB_INSTALL_DIR
|
||||
if (TBB_INSTALL_DIR)
|
||||
set (_TBB_INSTALL_DIR ${TBB_INSTALL_DIR})
|
||||
endif (TBB_INSTALL_DIR)
|
||||
# second: use environment variable
|
||||
if (NOT _TBB_INSTALL_DIR)
|
||||
if (NOT "$ENV{TBB_INSTALL_DIR}" STREQUAL "")
|
||||
set (_TBB_INSTALL_DIR $ENV{TBB_INSTALL_DIR})
|
||||
endif (NOT "$ENV{TBB_INSTALL_DIR}" STREQUAL "")
|
||||
# Intel recommends setting TBB21_INSTALL_DIR
|
||||
if (NOT "$ENV{TBB21_INSTALL_DIR}" STREQUAL "")
|
||||
set (_TBB_INSTALL_DIR $ENV{TBB21_INSTALL_DIR})
|
||||
endif (NOT "$ENV{TBB21_INSTALL_DIR}" STREQUAL "")
|
||||
if (NOT "$ENV{TBB22_INSTALL_DIR}" STREQUAL "")
|
||||
set (_TBB_INSTALL_DIR $ENV{TBB22_INSTALL_DIR})
|
||||
endif (NOT "$ENV{TBB22_INSTALL_DIR}" STREQUAL "")
|
||||
if (NOT "$ENV{TBB30_INSTALL_DIR}" STREQUAL "")
|
||||
set (_TBB_INSTALL_DIR $ENV{TBB30_INSTALL_DIR})
|
||||
endif (NOT "$ENV{TBB30_INSTALL_DIR}" STREQUAL "")
|
||||
endif (NOT _TBB_INSTALL_DIR)
|
||||
# third: try to find path automatically
|
||||
if (NOT _TBB_INSTALL_DIR)
|
||||
if (_TBB_DEFAULT_INSTALL_DIR)
|
||||
set (_TBB_INSTALL_DIR ${_TBB_DEFAULT_INSTALL_DIR})
|
||||
endif (_TBB_DEFAULT_INSTALL_DIR)
|
||||
endif (NOT _TBB_INSTALL_DIR)
|
||||
# sanity check
|
||||
if (NOT _TBB_INSTALL_DIR)
|
||||
message (STATUS "TBB: Unable to find Intel TBB install directory. ${_TBB_INSTALL_DIR}")
|
||||
else (NOT _TBB_INSTALL_DIR)
|
||||
# finally: set the cached CMake variable TBB_INSTALL_DIR
|
||||
if (NOT TBB_INSTALL_DIR)
|
||||
set (TBB_INSTALL_DIR ${_TBB_INSTALL_DIR} CACHE PATH "Intel TBB install directory")
|
||||
mark_as_advanced(TBB_INSTALL_DIR)
|
||||
endif (NOT TBB_INSTALL_DIR)
|
||||
|
||||
|
||||
#-- A macro to rewrite the paths of the library. This is necessary, because
|
||||
# find_library() always found the em64t/vc9 version of the TBB libs
|
||||
macro(TBB_CORRECT_LIB_DIR var_name)
|
||||
# if (NOT "${_TBB_ARCHITECTURE}" STREQUAL "em64t")
|
||||
string(REPLACE em64t "${_TBB_ARCHITECTURE}" ${var_name} ${${var_name}})
|
||||
# endif (NOT "${_TBB_ARCHITECTURE}" STREQUAL "em64t")
|
||||
string(REPLACE ia32 "${_TBB_ARCHITECTURE}" ${var_name} ${${var_name}})
|
||||
string(REPLACE vc7.1 "${_TBB_COMPILER}" ${var_name} ${${var_name}})
|
||||
string(REPLACE vc8 "${_TBB_COMPILER}" ${var_name} ${${var_name}})
|
||||
string(REPLACE vc9 "${_TBB_COMPILER}" ${var_name} ${${var_name}})
|
||||
string(REPLACE vc10 "${_TBB_COMPILER}" ${var_name} ${${var_name}})
|
||||
string(REPLACE vc11 "${_TBB_COMPILER}" ${var_name} ${${var_name}})
|
||||
endmacro(TBB_CORRECT_LIB_DIR var_content)
|
||||
|
||||
|
||||
#-- Look for include directory and set ${TBB_INCLUDE_DIR}
|
||||
set (TBB_INC_SEARCH_DIR ${_TBB_INSTALL_DIR}/include)
|
||||
# Jiri: tbbvars now sets the CPATH environment variable to the directory
|
||||
# containing the headers.
|
||||
find_path(TBB_INCLUDE_DIR
|
||||
tbb/task_scheduler_init.h
|
||||
PATHS ${TBB_INC_SEARCH_DIR} ENV CPATH
|
||||
)
|
||||
mark_as_advanced(TBB_INCLUDE_DIR)
|
||||
|
||||
|
||||
#-- Look for libraries
|
||||
# GvdB: $ENV{TBB_ARCH_PLATFORM} is set by the build script tbbvars[.bat|.sh|.csh]
|
||||
if (NOT $ENV{TBB_ARCH_PLATFORM} STREQUAL "")
|
||||
set (_TBB_LIBRARY_DIR
|
||||
${_TBB_INSTALL_DIR}/lib/$ENV{TBB_ARCH_PLATFORM}
|
||||
${_TBB_INSTALL_DIR}/$ENV{TBB_ARCH_PLATFORM}/lib
|
||||
)
|
||||
endif (NOT $ENV{TBB_ARCH_PLATFORM} STREQUAL "")
|
||||
# Jiri: This block isn't mutually exclusive with the previous one
|
||||
# (hence no else), instead I test if the user really specified
|
||||
# the variables in question.
|
||||
if ((NOT ${TBB_ARCHITECTURE} STREQUAL "") AND (NOT ${TBB_COMPILER} STREQUAL ""))
|
||||
# HH: deprecated
|
||||
message(STATUS "[Warning] FindTBB.cmake: The use of TBB_ARCHITECTURE and TBB_COMPILER is deprecated and may not be supported in future versions. Please set \$ENV{TBB_ARCH_PLATFORM} (using tbbvars.[bat|csh|sh]).")
|
||||
# Jiri: It doesn't hurt to look in more places, so I store the hints from
|
||||
# ENV{TBB_ARCH_PLATFORM} and the TBB_ARCHITECTURE and TBB_COMPILER
|
||||
# variables and search them both.
|
||||
set (
|
||||
_TBB_LIBRARY_DIR "${_TBB_INSTALL_DIR}/${_TBB_ARCHITECTURE}/${_TBB_COMPILER}/lib" ${_TBB_LIBRARY_DIR}
|
||||
_TBB_LIBRARY_DIR "${_TBB_INSTALL_DIR}/lib/${_TBB_ARCHITECTURE}/${_TBB_COMPILER}" ${_TBB_LIBRARY_DIR}
|
||||
)
|
||||
endif ((NOT ${TBB_ARCHITECTURE} STREQUAL "") AND (NOT ${TBB_COMPILER} STREQUAL ""))
|
||||
|
||||
# GvdB: Mac OS X distribution places libraries directly in lib directory.
|
||||
list(APPEND _TBB_LIBRARY_DIR ${_TBB_INSTALL_DIR}/lib)
|
||||
|
||||
# Jiri: No reason not to check the default paths. From recent versions,
|
||||
# tbbvars has started exporting the LIBRARY_PATH and LD_LIBRARY_PATH
|
||||
# variables, which now point to the directories of the lib files.
|
||||
# It all makes more sense to use the ${_TBB_LIBRARY_DIR} as a HINTS
|
||||
# argument instead of the implicit PATHS as it isn't hard-coded
|
||||
# but computed by system introspection. Searching the LIBRARY_PATH
|
||||
# and LD_LIBRARY_PATH environment variables is now even more important
|
||||
# that tbbvars doesn't export TBB_ARCH_PLATFORM and it facilitates
|
||||
# the use of TBB built from sources.
|
||||
find_library(TBB_LIBRARY ${_TBB_LIB_NAME} HINTS ${_TBB_LIBRARY_DIR}
|
||||
PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH)
|
||||
find_library(TBB_MALLOC_LIBRARY ${_TBB_LIB_MALLOC_NAME} HINTS ${_TBB_LIBRARY_DIR}
|
||||
PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH)
|
||||
|
||||
#Extract path from TBB_LIBRARY name
|
||||
get_filename_component(TBB_LIBRARY_DIR ${TBB_LIBRARY} PATH)
|
||||
|
||||
#TBB_CORRECT_LIB_DIR(TBB_LIBRARY)
|
||||
#TBB_CORRECT_LIB_DIR(TBB_MALLOC_LIBRARY)
|
||||
mark_as_advanced(TBB_LIBRARY TBB_MALLOC_LIBRARY)
|
||||
|
||||
#-- Look for debug libraries
|
||||
# Jiri: Changed the same way as for the release libraries.
|
||||
find_library(TBB_LIBRARY_DEBUG ${_TBB_LIB_DEBUG_NAME} HINTS ${_TBB_LIBRARY_DIR}
|
||||
PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH)
|
||||
find_library(TBB_MALLOC_LIBRARY_DEBUG ${_TBB_LIB_MALLOC_DEBUG_NAME} HINTS ${_TBB_LIBRARY_DIR}
|
||||
PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH)
|
||||
|
||||
# Jiri: Self-built TBB stores the debug libraries in a separate directory.
|
||||
# Extract path from TBB_LIBRARY_DEBUG name
|
||||
get_filename_component(TBB_LIBRARY_DEBUG_DIR ${TBB_LIBRARY_DEBUG} PATH)
|
||||
|
||||
#TBB_CORRECT_LIB_DIR(TBB_LIBRARY_DEBUG)
|
||||
#TBB_CORRECT_LIB_DIR(TBB_MALLOC_LIBRARY_DEBUG)
|
||||
mark_as_advanced(TBB_LIBRARY_DEBUG TBB_MALLOC_LIBRARY_DEBUG)
|
||||
|
||||
|
||||
if (TBB_INCLUDE_DIR)
|
||||
if (TBB_LIBRARY)
|
||||
set (TBB_FOUND "YES")
|
||||
set (TBB_LIBRARIES ${TBB_LIBRARY} ${TBB_MALLOC_LIBRARY} ${TBB_LIBRARIES})
|
||||
set (TBB_DEBUG_LIBRARIES ${TBB_LIBRARY_DEBUG} ${TBB_MALLOC_LIBRARY_DEBUG} ${TBB_DEBUG_LIBRARIES})
|
||||
set (TBB_INCLUDE_DIRS ${TBB_INCLUDE_DIR} CACHE PATH "TBB include directory" FORCE)
|
||||
set (TBB_LIBRARY_DIRS ${TBB_LIBRARY_DIR} CACHE PATH "TBB library directory" FORCE)
|
||||
# Jiri: Self-built TBB stores the debug libraries in a separate directory.
|
||||
set (TBB_DEBUG_LIBRARY_DIRS ${TBB_LIBRARY_DEBUG_DIR} CACHE PATH "TBB debug library directory" FORCE)
|
||||
mark_as_advanced(TBB_INCLUDE_DIRS TBB_LIBRARY_DIRS TBB_DEBUG_LIBRARY_DIRS TBB_LIBRARIES TBB_DEBUG_LIBRARIES)
|
||||
message(STATUS "Found Intel TBB")
|
||||
endif (TBB_LIBRARY)
|
||||
endif (TBB_INCLUDE_DIR)
|
||||
|
||||
if (NOT TBB_FOUND)
|
||||
message(STATUS "TBB: Intel TBB NOT found!")
|
||||
message(STATUS "TBB: Looked for Threading Building Blocks in ${_TBB_INSTALL_DIR}")
|
||||
# do only throw fatal, if this pkg is REQUIRED
|
||||
if (TBB_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "Could NOT find TBB library.")
|
||||
endif (TBB_FIND_REQUIRED)
|
||||
endif (NOT TBB_FOUND)
|
||||
|
||||
endif (NOT _TBB_INSTALL_DIR)
|
||||
|
||||
if (TBB_FOUND)
|
||||
set(TBB_INTERFACE_VERSION 0)
|
||||
FILE(READ "${TBB_INCLUDE_DIRS}/tbb/tbb_stddef.h" _TBB_VERSION_CONTENTS)
|
||||
STRING(REGEX REPLACE ".*#define TBB_INTERFACE_VERSION ([0-9]+).*" "\\1" TBB_INTERFACE_VERSION "${_TBB_VERSION_CONTENTS}")
|
||||
set(TBB_INTERFACE_VERSION "${TBB_INTERFACE_VERSION}")
|
||||
endif (TBB_FOUND)
|
|
@ -0,0 +1,133 @@
|
|||
|
||||
# Add install prefix to search path
|
||||
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_INSTALL_PREFIX}")
|
||||
|
||||
# Default to Release mode
|
||||
if(NOT FIRST_PASS_DONE AND NOT CMAKE_BUILD_TYPE AND NOT MSVC AND NOT XCODE_VERSION)
|
||||
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
|
||||
"Choose the type of build, options are: None Debug Release Timing Profiling RelWithDebInfo."
|
||||
FORCE)
|
||||
endif()
|
||||
|
||||
# Add option for using build type postfixes to allow installing multiple build modes
|
||||
if(MSVC OR XCODE_VERSION)
|
||||
option(GTSAM_BUILD_TYPE_POSTFIXES "Enable/Disable appending the build type to the name of compiled libraries" ON)
|
||||
else()
|
||||
option(GTSAM_BUILD_TYPE_POSTFIXES "Enable/Disable appending the build type to the name of compiled libraries" OFF)
|
||||
endif()
|
||||
|
||||
# Add debugging flags but only on the first pass
|
||||
if(NOT FIRST_PASS_DONE)
|
||||
if(MSVC)
|
||||
set(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /MDd /Zi /Ob0 /Od /RTC1 /W3 /GR /EHsc /MP /DWINDOWS_LEAN_AND_MEAN" CACHE STRING "Flags used by the compiler during debug builds." FORCE)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /MDd /Zi /Ob0 /Od /RTC1 /W3 /GR /EHsc /MP /DWINDOWS_LEAN_AND_MEAN" CACHE STRING "Flags used by the compiler during debug builds." FORCE)
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "/MD /O2 /DNDEBUG /W3 /GR /EHsc /MP /Zi /d2Zi+ /DWINDOWS_LEAN_AND_MEAN" CACHE STRING "Flags used by the compiler during relwithdebinfo builds." FORCE)
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MD /O2 /DNDEBUG /W3 /GR /EHsc /MP /Zi /d2Zi+ /DWINDOWS_LEAN_AND_MEAN" CACHE STRING "Flags used by the compiler during relwithdebinfo builds." FORCE)
|
||||
set(CMAKE_C_FLAGS_RELEASE "/MD /O2 /DNDEBUG /W3 /GR /EHsc /MP /DWINDOWS_LEAN_AND_MEAN" CACHE STRING "Flags used by the compiler during release builds." FORCE)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "/MD /O2 /DNDEBUG /W3 /GR /EHsc /MP /DWINDOWS_LEAN_AND_MEAN" CACHE STRING "Flags used by the compiler during release builds." FORCE)
|
||||
set(CMAKE_C_FLAGS_TIMING "${CMAKE_C_FLAGS_RELEASE} /DENABLE_TIMING" CACHE STRING "Flags used by the compiler during timing builds." FORCE)
|
||||
set(CMAKE_CXX_FLAGS_TIMING "${CMAKE_CXX_FLAGS_RELEASE} /DENABLE_TIMING" CACHE STRING "Flags used by the compiler during timing builds." FORCE)
|
||||
set(CMAKE_EXE_LINKER_FLAGS_TIMING "${CMAKE_EXE_LINKER_FLAGS_RELEASE}" CACHE STRING "Linker flags during timing builds." FORCE)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_TIMING "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}" CACHE STRING "Linker flags during timing builds." FORCE)
|
||||
set(CMAKE_MODULE_LINKER_FLAGS_TIMING "${CMAKE_MODULE_LINKER_FLAGS_RELEASE}" CACHE STRING "Linker flags during timing builds." FORCE)
|
||||
mark_as_advanced(CMAKE_C_FLAGS_TIMING CMAKE_CXX_FLAGS_TIMING CMAKE_EXE_LINKER_FLAGS_TIMING CMAKE_SHARED_LINKER_FLAGS_TIMING CMAKE_MODULE_LINKER_FLAGS_TIMING)
|
||||
set(CMAKE_C_FLAGS_PROFILING "/MD /O2 /DNDEBUG /W3 /GR /EHsc /MP /Zi /DWINDOWS_LEAN_AND_MEAN" CACHE STRING "Flags used by the compiler during profiling builds." FORCE)
|
||||
set(CMAKE_CXX_FLAGS_PROFILING "/MD /O2 /DNDEBUG /W3 /GR /EHsc /MP /Zi /DWINDOWS_LEAN_AND_MEAN" CACHE STRING "Flags used by the compiler during profiling builds." FORCE)
|
||||
set(CMAKE_EXE_LINKER_FLAGS_PROFILING "${CMAKE_EXE_LINKER_FLAGS_RELEASE}" CACHE STRING "Linker flags during profiling builds." FORCE)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_PROFILING "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}" CACHE STRING "Linker flags during profiling builds." FORCE)
|
||||
set(CMAKE_MODULE_LINKER_FLAGS_PROFILING "${CMAKE_MODULE_LINKER_FLAGS_RELEASE}" CACHE STRING "Linker flags during profiling builds." FORCE)
|
||||
mark_as_advanced(CMAKE_C_FLAGS_PROFILING CMAKE_CXX_FLAGS_PROFILING CMAKE_EXE_LINKER_FLAGS_PROFILING CMAKE_SHARED_LINKER_FLAGS_PROFILING CMAKE_MODULE_LINKER_FLAGS_PROFILING)
|
||||
else()
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fno-inline -Wall" CACHE STRING "Flags used by the compiler during debug builds." FORCE)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-inline -Wall" CACHE STRING "Flags used by the compiler during debug builds." FORCE)
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-g -O3 -Wall -DNDEBUG" CACHE STRING "Flags used by the compiler during relwithdebinfo builds." FORCE)
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O3 -Wall -DNDEBUG" CACHE STRING "Flags used by the compiler during relwithdebinfo builds." FORCE)
|
||||
set(CMAKE_C_FLAGS_RELEASE "-O3 -Wall -DNDEBUG -Wall" CACHE STRING "Flags used by the compiler during release builds." FORCE)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall -DNDEBUG -Wall" CACHE STRING "Flags used by the compiler during release builds." FORCE)
|
||||
set(CMAKE_C_FLAGS_TIMING "${CMAKE_C_FLAGS_RELEASE} -DENABLE_TIMING" CACHE STRING "Flags used by the compiler during timing builds." FORCE)
|
||||
set(CMAKE_CXX_FLAGS_TIMING "${CMAKE_CXX_FLAGS_RELEASE} -DENABLE_TIMING" CACHE STRING "Flags used by the compiler during timing builds." FORCE)
|
||||
set(CMAKE_EXE_LINKER_FLAGS_TIMING "${CMAKE_EXE_LINKER_FLAGS_RELEASE}" CACHE STRING "Linker flags during timing builds." FORCE)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_TIMING "${CMAKE_EXE_LINKER_FLAGS_RELEASE}" CACHE STRING "Linker flags during timing builds." FORCE)
|
||||
mark_as_advanced(CMAKE_C_FLAGS_TIMING CMAKE_CXX_FLAGS_TIMING CMAKE_EXE_LINKER_FLAGS_TIMING CMAKE_SHARED_LINKER_FLAGS_TIMING)
|
||||
set(CMAKE_C_FLAGS_PROFILING "-g -O3 -Wall -DNDEBUG" CACHE STRING "Flags used by the compiler during profiling builds." FORCE)
|
||||
set(CMAKE_CXX_FLAGS_PROFILING "-g -O3 -Wall -DNDEBUG" CACHE STRING "Flags used by the compiler during profiling builds." FORCE)
|
||||
set(CMAKE_EXE_LINKER_FLAGS_PROFILING "${CMAKE_EXE_LINKER_FLAGS_RELEASE}" CACHE STRING "Linker flags during profiling builds." FORCE)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_PROFILING "${CMAKE__LINKER_FLAGS_RELEASE}" CACHE STRING "Linker flags during profiling builds." FORCE)
|
||||
mark_as_advanced(CMAKE_C_FLAGS_PROFILING CMAKE_CXX_FLAGS_PROFILING CMAKE_EXE_LINKER_FLAGS_PROFILING CMAKE_SHARED_LINKER_FLAGS_PROFILING)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Clang on Mac uses a template depth that is less than standard and is too small
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
if(NOT "${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "5.0")
|
||||
add_definitions(-ftemplate-depth=1024)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Set up build type library postfixes
|
||||
if(GTSAM_BUILD_TYPE_POSTFIXES)
|
||||
foreach(build_type Debug Timing RelWithDebInfo MinSizeRel)
|
||||
string(TOUPPER "${build_type}" build_type_toupper)
|
||||
set(CMAKE_${build_type_toupper}_POSTFIX ${build_type})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# Make common binary output directory when on Windows
|
||||
if(WIN32)
|
||||
set(RUNTIME_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin")
|
||||
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin")
|
||||
set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib")
|
||||
endif()
|
||||
|
||||
# Set up build type list for cmake-gui
|
||||
if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "")
|
||||
if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_GREATER 2.8 OR ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_EQUAL 2.8)
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS None Debug Release Timing Profiling RelWithDebInfo MinSizeRel)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Set up build types for MSVC and XCode
|
||||
if(NOT FIRST_PASS_DONE)
|
||||
set(CMAKE_CONFIGURATION_TYPES Debug Release Timing Profiling RelWithDebInfo MinSizeRel
|
||||
CACHE STRING "Build types available to MSVC and XCode" FORCE)
|
||||
mark_as_advanced(FORCE CMAKE_CONFIGURATION_TYPES)
|
||||
endif()
|
||||
|
||||
# Check build types
|
||||
string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_tolower)
|
||||
if( NOT cmake_build_type_tolower STREQUAL ""
|
||||
AND NOT cmake_build_type_tolower STREQUAL "none"
|
||||
AND NOT cmake_build_type_tolower STREQUAL "debug"
|
||||
AND NOT cmake_build_type_tolower STREQUAL "release"
|
||||
AND NOT cmake_build_type_tolower STREQUAL "timing"
|
||||
AND NOT cmake_build_type_tolower STREQUAL "profiling"
|
||||
AND NOT cmake_build_type_tolower STREQUAL "relwithdebinfo")
|
||||
message(FATAL_ERROR "Unknown build type \"${CMAKE_BUILD_TYPE}\". Allowed values are None, Debug, Release, Timing, Profiling, RelWithDebInfo (case-insensitive).")
|
||||
endif()
|
||||
|
||||
# Mark that first pass is done
|
||||
set(FIRST_PASS_DONE TRUE CACHE BOOL "Internally used to mark whether cmake has been run multiple times" FORCE)
|
||||
mark_as_advanced(FIRST_PASS_DONE)
|
||||
|
||||
# Enable Visual Studio solution folders
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS On)
|
||||
|
||||
# Function for automatically assigning source folders
|
||||
function(gtsam_assign_source_folders)
|
||||
set(FILES ${ARGV})
|
||||
foreach(file ${FILES})
|
||||
file(RELATIVE_PATH relative_file "${CMAKE_CURRENT_SOURCE_DIR}" "${file}")
|
||||
get_filename_component(relative_path "${relative_file}" PATH)
|
||||
file(TO_NATIVE_PATH "${relative_path}" relative_path)
|
||||
source_group("${relative_path}" FILES "${file}")
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
# Find and assign all source and header files
|
||||
function(gtsam_assign_all_source_folders)
|
||||
file(GLOB_RECURSE all_c_srcs "*.c")
|
||||
file(GLOB_RECURSE all_cpp_srcs "*.cpp")
|
||||
file(GLOB_RECURSE all_headers "*.h")
|
||||
gtsam_assign_source_folders("${all_c_srcs};${all_cpp_srcs};${all_headers}")
|
||||
endfunction()
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
# Writes a config file
|
||||
|
||||
function(GtsamMakeConfigFile PACKAGE_NAME)
|
||||
|
||||
if(WIN32 AND NOT CYGWIN)
|
||||
set(DEF_INSTALL_CMAKE_DIR CMake)
|
||||
else()
|
||||
set(DEF_INSTALL_CMAKE_DIR lib/cmake/${PACKAGE_NAME})
|
||||
endif()
|
||||
|
||||
# Configure extra file
|
||||
if(NOT "${ARGV1}" STREQUAL "")
|
||||
get_filename_component(name "${ARGV1}" NAME_WE)
|
||||
set(EXTRA_FILE "${name}.cmake")
|
||||
configure_file(${ARGV1} "${PROJECT_BINARY_DIR}/${EXTRA_FILE}" @ONLY)
|
||||
install(FILES "${PROJECT_BINARY_DIR}/${EXTRA_FILE}" DESTINATION "${CMAKE_INSTALL_PREFIX}/${DEF_INSTALL_CMAKE_DIR}")
|
||||
else()
|
||||
set(EXTRA_FILE "_does_not_exist_")
|
||||
endif()
|
||||
|
||||
file(RELATIVE_PATH CONF_REL_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/${DEF_INSTALL_CMAKE_DIR}" "${CMAKE_INSTALL_PREFIX}/include")
|
||||
file(RELATIVE_PATH CONF_REL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/${DEF_INSTALL_CMAKE_DIR}" "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
configure_file(${PROJECT_SOURCE_DIR}/cmake/Config.cmake.in "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}Config.cmake" @ONLY)
|
||||
message(STATUS "Wrote ${PROJECT_BINARY_DIR}/${PACKAGE_NAME}Config.cmake")
|
||||
|
||||
# Install config and exports files (for find scripts)
|
||||
install(FILES "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}Config.cmake" DESTINATION "${CMAKE_INSTALL_PREFIX}/${DEF_INSTALL_CMAKE_DIR}")
|
||||
install(EXPORT ${PACKAGE_NAME}-exports DESTINATION ${DEF_INSTALL_CMAKE_DIR})
|
||||
|
||||
endfunction()
|
|
@ -0,0 +1,281 @@
|
|||
# Set up cache options
|
||||
option(GTSAM_MEX_BUILD_STATIC_MODULE "Build MATLAB wrapper statically (increases build time)" OFF)
|
||||
set(GTSAM_BUILD_MEX_BINARY_FLAGS "" CACHE STRING "Extra flags for running Matlab MEX compilation")
|
||||
set(GTSAM_TOOLBOX_INSTALL_PATH "" CACHE PATH "Matlab toolbox destination, blank defaults to CMAKE_INSTALL_PREFIX/gtsam_toolbox")
|
||||
if(NOT GTSAM_TOOLBOX_INSTALL_PATH)
|
||||
set(GTSAM_TOOLBOX_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/gtsam_toolbox")
|
||||
endif()
|
||||
|
||||
# GTSAM_MEX_BUILD_STATIC_MODULE is not for Windows - on Windows any static
|
||||
# are already compiled into the library by the linker
|
||||
if(GTSAM_MEX_BUILD_STATIC_MODULE AND WIN32)
|
||||
message(FATAL_ERROR "GTSAM_MEX_BUILD_STATIC_MODULE should not be set on Windows - the linker already automatically compiles in any dependent static libraries. To create a standalone toolbox pacakge, simply ensure that CMake finds the static versions of all dependent libraries (Boost, etc).")
|
||||
endif()
|
||||
|
||||
# Try to automatically configure mex path
|
||||
if(APPLE)
|
||||
file(GLOB matlab_bin_directories "/Applications/MATLAB*/bin")
|
||||
set(mex_program_name "mex")
|
||||
elseif(WIN32)
|
||||
file(GLOB matlab_bin_directories "C:/Program Files*/MATLAB/*/bin")
|
||||
set(mex_program_name "mex.bat")
|
||||
else()
|
||||
file(GLOB matlab_bin_directories "/usr/local/MATLAB/*/bin")
|
||||
set(mex_program_name "mex")
|
||||
endif()
|
||||
# Run find_program explicitly putting $PATH after our predefined program
|
||||
# directories using 'ENV PATH' and 'NO_SYSTEM_ENVIRONMENT_PATH' - this prevents
|
||||
# finding the LaTeX mex program (totally unrelated to MATLAB Mex) when LaTeX is
|
||||
# on the system path.
|
||||
list(REVERSE matlab_bin_directories) # Reverse list so the highest version (sorted alphabetically) is preferred
|
||||
find_program(mex_command ${mex_program_name}
|
||||
PATHS ${matlab_bin_directories} ENV PATH
|
||||
NO_DEFAULT_PATH)
|
||||
mark_as_advanced(FORCE mex_command)
|
||||
# Now that we have mex, trace back to find the Matlab installation root
|
||||
get_filename_component(mex_command "${mex_command}" REALPATH)
|
||||
get_filename_component(mex_path "${mex_command}" PATH)
|
||||
get_filename_component(MATLAB_ROOT "${mex_path}/.." ABSOLUTE)
|
||||
set(MATLAB_ROOT "${MATLAB_ROOT}" CACHE PATH "Path to MATLAB installation root (e.g. /usr/local/MATLAB/R2012a)")
|
||||
|
||||
|
||||
# User-friendly wrapping function. Builds a mex module from the provided
|
||||
# interfaceHeader. For example, for the interface header /path/to/gtsam.h,
|
||||
# this will build the wrap module 'gtsam'.
|
||||
# Params:
|
||||
# interfaceHeader : Absolute or relative path to the interface definition file
|
||||
# linkLibraries : All dependent CMake target names, library names, or full library paths
|
||||
# extraIncludeDirs : Extra include directories, in addition to those already passed to include_directories(...)
|
||||
# extraMexFlags : Any additional compiler flags
|
||||
function(wrap_and_install_library interfaceHeader linkLibraries extraIncludeDirs extraMexFlags)
|
||||
wrap_library_internal("${interfaceHeader}" "${otherLibraries}" "${extraIncludeDirs}" "${mexFlags}")
|
||||
install_wrapped_library_internal("${interfaceHeader}")
|
||||
endfunction()
|
||||
|
||||
|
||||
function(wrap_library_internal interfaceHeader linkLibraries extraIncludeDirs extraMexFlags)
|
||||
if(UNIX AND NOT APPLE)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(mexModuleExt mexa64)
|
||||
else()
|
||||
set(mexModuleExt mexglx)
|
||||
endif()
|
||||
elseif(APPLE)
|
||||
set(mexModuleExt mexmaci64)
|
||||
elseif(MSVC)
|
||||
if(CMAKE_CL_64)
|
||||
set(mexModuleExt mexw64)
|
||||
else()
|
||||
set(mexModuleExt mexw32)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Wrap codegen interface
|
||||
#usage: wrap interfacePath moduleName toolboxPath headerPath
|
||||
# interfacePath : *absolute* path to directory of module interface file
|
||||
# moduleName : the name of the module, interface file must be called moduleName.h
|
||||
# toolboxPath : the directory in which to generate the wrappers
|
||||
# headerPath : path to matlab.h
|
||||
|
||||
# Extract module name from interface header file name
|
||||
get_filename_component(interfaceHeader "${interfaceHeader}" ABSOLUTE)
|
||||
get_filename_component(modulePath "${interfaceHeader}" PATH)
|
||||
get_filename_component(moduleName "${interfaceHeader}" NAME_WE)
|
||||
|
||||
# Paths for generated files
|
||||
set(generated_files_path "${PROJECT_BINARY_DIR}/wrap/${moduleName}")
|
||||
set(generated_cpp_file "${PROJECT_BINARY_DIR}/wrap/${moduleName}/${moduleName}_wrapper.cpp")
|
||||
set(compiled_mex_modules_root "${PROJECT_BINARY_DIR}/wrap/${moduleName}_mex")
|
||||
|
||||
message(STATUS "Building wrap module ${moduleName}")
|
||||
|
||||
# Find matlab.h in GTSAM
|
||||
if("${PROJECT_NAME}" STREQUAL "GTSAM")
|
||||
set(matlab_h_path "${PROJECT_SOURCE_DIR}")
|
||||
else()
|
||||
if(NOT GTSAM_INCLUDE_DIR)
|
||||
message(FATAL_ERROR "You must call find_package(GTSAM) before using wrap")
|
||||
endif()
|
||||
list(GET GTSAM_INCLUDE_DIR 0 installed_includes_path)
|
||||
set(matlab_h_path "${installed_includes_path}/wrap")
|
||||
endif()
|
||||
|
||||
# Add -shared or -static suffix to targets
|
||||
set(correctedOtherLibraries "")
|
||||
set(otherLibraryTargets "")
|
||||
foreach(lib ${moduleName} ${otherLibraries})
|
||||
if(TARGET ${lib})
|
||||
list(APPEND correctedOtherLibraries ${lib})
|
||||
list(APPEND otherLibraryTargets ${lib})
|
||||
elseif(TARGET ${lib}-shared) # Prefer the shared library if we have both shared and static)
|
||||
list(APPEND correctedOtherLibraries ${lib}-shared)
|
||||
list(APPEND otherLibraryTargets ${lib}-shared)
|
||||
elseif(TARGET ${lib}-static)
|
||||
list(APPEND correctedOtherLibraries ${lib}-static)
|
||||
list(APPEND otherLibraryTargets ${lib}-static)
|
||||
else()
|
||||
list(APPEND correctedOtherLibraries ${lib})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Set up generation of module source file
|
||||
file(MAKE_DIRECTORY "${generated_files_path}")
|
||||
add_custom_command(
|
||||
OUTPUT ${generated_cpp_file}
|
||||
DEPENDS ${interfaceHeader} wrap ${module_library_target} ${otherLibraryTargets}
|
||||
COMMAND
|
||||
wrap
|
||||
${modulePath}
|
||||
${moduleName}
|
||||
${generated_files_path}
|
||||
${matlab_h_path}
|
||||
VERBATIM
|
||||
WORKING_DIRECTORY ${generated_files_path})
|
||||
|
||||
# Set up building of mex module
|
||||
string(REPLACE ";" " " extraMexFlagsSpaced "${extraMexFlags}")
|
||||
string(REPLACE ";" " " mexFlagsSpaced "${GTSAM_BUILD_MEX_BINARY_FLAGS}")
|
||||
add_library(${moduleName}_wrapper MODULE ${generated_cpp_file} ${interfaceHeader})
|
||||
target_link_libraries(${moduleName}_wrapper ${correctedOtherLibraries})
|
||||
set_target_properties(${moduleName}_wrapper PROPERTIES
|
||||
OUTPUT_NAME "${moduleName}_wrapper"
|
||||
PREFIX ""
|
||||
SUFFIX ".${mexModuleExt}"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${compiled_mex_modules_root}"
|
||||
ARCHIVE_OUTPUT_DIRECTORY "${compiled_mex_modules_root}"
|
||||
RUNTIME_OUTPUT_DIRECTORY "${compiled_mex_modules_root}"
|
||||
CLEAN_DIRECT_OUTPUT 1)
|
||||
set_property(TARGET ${moduleName}_wrapper APPEND_STRING PROPERTY COMPILE_FLAGS " ${extraMexFlagsSpaced} ${mexFlagsSpaced} \"-I${MATLAB_ROOT}/extern/include\" -DMATLAB_MEX_FILE -DMX_COMPAT_32")
|
||||
set_property(TARGET ${moduleName}_wrapper APPEND PROPERTY INCLUDE_DIRECTORIES ${extraIncludeDirs})
|
||||
# Disable build type postfixes for the mex module - we install in different directories for each build type instead
|
||||
foreach(build_type ${CMAKE_CONFIGURATION_TYPES})
|
||||
string(TOUPPER "${build_type}" build_type_upper)
|
||||
set_target_properties(${moduleName}_wrapper PROPERTIES ${build_type_upper}_POSTFIX "")
|
||||
endforeach()
|
||||
# Set up platform-specific flags
|
||||
if(MSVC)
|
||||
if(CMAKE_CL_64)
|
||||
set(mxLibPath "${MATLAB_ROOT}/extern/lib/win64/microsoft")
|
||||
else()
|
||||
set(mxLibPath "${MATLAB_ROOT}/extern/lib/win32/microsoft")
|
||||
endif()
|
||||
target_link_libraries(${moduleName}_wrapper "${mxLibPath}/libmex.lib" "${mxLibPath}/libmx.lib" "${mxLibPath}/libmat.lib")
|
||||
set_target_properties(${moduleName}_wrapper PROPERTIES LINK_FLAGS "/export:mexFunction")
|
||||
set_property(SOURCE "${generated_cpp_file}" APPEND PROPERTY COMPILE_FLAGS "/bigobj")
|
||||
elseif(APPLE)
|
||||
set(mxLibPath "${MATLAB_ROOT}/bin/maci64")
|
||||
target_link_libraries(${moduleName}_wrapper "${mxLibPath}/libmex.dylib" "${mxLibPath}/libmx.dylib" "${mxLibPath}/libmat.dylib")
|
||||
endif()
|
||||
|
||||
# Hacking around output issue with custom command
|
||||
# Deletes generated build folder
|
||||
add_custom_target(wrap_${moduleName}_distclean
|
||||
COMMAND cmake -E remove_directory ${generated_files_path}
|
||||
COMMAND cmake -E remove_directory ${compiled_mex_modules_root})
|
||||
endfunction()
|
||||
|
||||
function(install_wrapped_library_internal interfaceHeader)
|
||||
get_filename_component(moduleName "${interfaceHeader}" NAME_WE)
|
||||
set(generated_files_path "${PROJECT_BINARY_DIR}/wrap/${moduleName}")
|
||||
|
||||
# NOTE: only installs .m and mex binary files (not .cpp) - the trailing slash on the directory name
|
||||
# here prevents creating the top-level module name directory in the destination.
|
||||
message(STATUS "Installing Matlab Toolbox to ${GTSAM_TOOLBOX_INSTALL_PATH}")
|
||||
if(GTSAM_BUILD_TYPE_POSTFIXES)
|
||||
foreach(build_type ${CMAKE_CONFIGURATION_TYPES})
|
||||
string(TOUPPER "${build_type}" build_type_upper)
|
||||
if("${build_type_upper}" STREQUAL "RELEASE")
|
||||
set(build_type_tag "") # Don't create release mode tag on installed directory
|
||||
else()
|
||||
set(build_type_tag "${build_type}")
|
||||
endif()
|
||||
# Split up filename to strip trailing '/' in GTSAM_TOOLBOX_INSTALL_PATH if there is one
|
||||
get_filename_component(location "${GTSAM_TOOLBOX_INSTALL_PATH}" PATH)
|
||||
get_filename_component(name "${GTSAM_TOOLBOX_INSTALL_PATH}" NAME)
|
||||
install(DIRECTORY "${generated_files_path}/" DESTINATION "${location}/${name}${build_type_tag}" CONFIGURATIONS "${build_type}" FILES_MATCHING PATTERN "*.m")
|
||||
install(TARGETS ${moduleName}_wrapper
|
||||
LIBRARY DESTINATION "${location}/${name}${build_type_tag}" CONFIGURATIONS "${build_type}"
|
||||
RUNTIME DESTINATION "${location}/${name}${build_type_tag}" CONFIGURATIONS "${build_type}")
|
||||
endforeach()
|
||||
else()
|
||||
install(DIRECTORY "${generated_files_path}/" DESTINATION ${GTSAM_TOOLBOX_INSTALL_PATH} FILES_MATCHING PATTERN "*.m")
|
||||
install(TARGETS ${moduleName}_wrapper
|
||||
LIBRARY DESTINATION ${GTSAM_TOOLBOX_INSTALL_PATH}
|
||||
RUNTIME DESTINATION ${GTSAM_TOOLBOX_INSTALL_PATH})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
# Function to setup codegen and building of the wrap toolbox
|
||||
#
|
||||
# params:
|
||||
# moduleName : the name of the module, interface file must be called moduleName.h
|
||||
# mexFlags : Compilation flags to be passed to the mex compiler
|
||||
# modulePath : relative path to module markup header file (called moduleName.h)
|
||||
# otherLibraries : list of library targets this should depend on
|
||||
# toolboxPath : the directory in which to generate/build wrappers
|
||||
# wrap_header_path : path to the installed wrap header
|
||||
function(wrap_library_generic moduleName mexFlags modulePath otherLibraries toolbox_path wrap_header_path)
|
||||
|
||||
if(NOT "${CMAKE_PROJECT_NAME}" STREQUAL "GTSAM")
|
||||
message("Your project uses wrap_library or wrap_library_generic - this is deprecated, please use the more user-friendly function wrap_and_install_library")
|
||||
endif()
|
||||
|
||||
# Append module name to link libraries to keep original behavior
|
||||
list(APPEND otherLibraries ${moduleName})
|
||||
|
||||
# Set up arguments
|
||||
set(interfaceHeader ${modulePath}/${moduleName}.h)
|
||||
|
||||
# Call internal function
|
||||
wrap_library_internal("${interfaceHeader}" "${otherLibraries}" "" "${mexFlags}")
|
||||
endfunction(wrap_library_generic)
|
||||
|
||||
# Function to setup codegen, building and installation of the wrap toolbox
|
||||
# This wrap setup function assumes that the toolbox will be installed directly,
|
||||
# with predictable matlab.h sourcing. Use this version when the toolbox will be used
|
||||
# from the installed version, rather than in place.
|
||||
# Assumes variable GTSAM_WRAP_HEADER_PATH has been set
|
||||
# params:
|
||||
# moduleName : the name of the module, interface file must be called moduleName.h
|
||||
# mexFlags : Compilation flags to be passed to the mex compiler
|
||||
# modulePath : relative path to module markup header file (called moduleName.h)
|
||||
# otherLibraries : list of library targets this should depend on
|
||||
function(wrap_library moduleName mexFlags modulePath otherLibraries)
|
||||
# Toolbox generation path goes in build folder
|
||||
set(toolbox_base_path ${PROJECT_BINARY_DIR}/wrap)
|
||||
set(toolbox_path ${toolbox_base_path}/${moduleName})
|
||||
|
||||
# Call generic version of function
|
||||
wrap_library_generic("${moduleName}" "${mexFlags}" "${modulePath}" "${otherLibraries}" "${toolbox_path}" "${GTSAM_WRAP_HEADER_PATH}")
|
||||
|
||||
install_wrapped_library_internal("${modulePath}/${moduleName}.h")
|
||||
|
||||
endfunction(wrap_library)
|
||||
|
||||
# Helper function to install MATLAB scripts and handle multiple build types where the scripts
|
||||
# should be installed to all build type toolboxes
|
||||
function(install_matlab_scripts source_directory patterns)
|
||||
set(patterns_args "")
|
||||
foreach(pattern ${patterns})
|
||||
list(APPEND patterns_args PATTERN "${pattern}")
|
||||
endforeach()
|
||||
if(GTSAM_BUILD_TYPE_POSTFIXES)
|
||||
foreach(build_type ${CMAKE_CONFIGURATION_TYPES})
|
||||
string(TOUPPER "${build_type}" build_type_upper)
|
||||
if("${build_type_upper}" STREQUAL "RELEASE")
|
||||
set(build_type_tag "") # Don't create release mode tag on installed directory
|
||||
else()
|
||||
set(build_type_tag "${build_type}")
|
||||
endif()
|
||||
# Split up filename to strip trailing '/' in GTSAM_TOOLBOX_INSTALL_PATH if there is one
|
||||
get_filename_component(location "${GTSAM_TOOLBOX_INSTALL_PATH}" PATH)
|
||||
get_filename_component(name "${GTSAM_TOOLBOX_INSTALL_PATH}" NAME)
|
||||
install(DIRECTORY "${source_directory}" DESTINATION "${location}/${name}${build_type_tag}" CONFIGURATIONS "${build_type}" FILES_MATCHING ${patterns_args} PATTERN ".svn" EXCLUDE)
|
||||
endforeach()
|
||||
else()
|
||||
install(DIRECTORY "${source_directory}" DESTINATION "${GTSAM_TOOLBOX_INSTALL_PATH}" FILES_MATCHING ${patterns_args} PATTERN ".svn" EXCLUDE)
|
||||
endif()
|
||||
|
||||
endfunction()
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
# print configuration variables
|
||||
# Usage:
|
||||
#print_config_flag(${GTSAM_BUILD_TESTS} "Build Tests ")
|
||||
function(print_config_flag flag msg)
|
||||
if (flag)
|
||||
message(STATUS " ${msg}: Enabled")
|
||||
else ()
|
||||
message(STATUS " ${msg}: Disabled")
|
||||
endif ()
|
||||
endfunction(print_config_flag)
|
|
@ -0,0 +1,67 @@
|
|||
#Setup cache options
|
||||
option(GTSAM_BUILD_PYTHON "Build Python wrapper statically (increases build time)" OFF)
|
||||
set(GTSAM_BUILD_PYTHON_FLAGS "" CACHE STRING "Extra flags for running Matlab PYTHON compilation")
|
||||
set(GTSAM_PYTHON_INSTALL_PATH "" CACHE PATH "Python toolbox destination, blank defaults to CMAKE_INSTALL_PREFIX/borg/python")
|
||||
if(NOT GTSAM_PYTHON_INSTALL_PATH)
|
||||
set(GTSAM_PYTHON_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/borg/python")
|
||||
endif()
|
||||
|
||||
#Author: Paul Furgale Modified by Andrew Melim
|
||||
function(wrap_python TARGET_NAME PYTHON_MODULE_DIRECTORY)
|
||||
# Boost
|
||||
find_package(Boost COMPONENTS python filesystem system REQUIRED)
|
||||
include_directories(${Boost_INCLUDE_DIRS})
|
||||
|
||||
# Find Python
|
||||
FIND_PACKAGE(PythonLibs 2.7 REQUIRED)
|
||||
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS})
|
||||
|
||||
IF(APPLE)
|
||||
# The apple framework headers don't include the numpy headers for some reason.
|
||||
GET_FILENAME_COMPONENT(REAL_PYTHON_INCLUDE ${PYTHON_INCLUDE_DIRS} REALPATH)
|
||||
IF( ${REAL_PYTHON_INCLUDE} MATCHES Python.framework)
|
||||
message("Trying to find extra headers for numpy from ${REAL_PYTHON_INCLUDE}.")
|
||||
message("Looking in ${REAL_PYTHON_INCLUDE}/../../Extras/lib/python/numpy/core/include/numpy")
|
||||
FIND_PATH(NUMPY_INCLUDE_DIR arrayobject.h
|
||||
${REAL_PYTHON_INCLUDE}/../../Extras/lib/python/numpy/core/include/numpy
|
||||
${REAL_PYTHON_INCLUDE}/numpy
|
||||
)
|
||||
IF(${NUMPY_INCLUDE_DIR} MATCHES NOTFOUND)
|
||||
message("Unable to find numpy include directories: ${NUMPY_INCLUDE_DIR}")
|
||||
ELSE()
|
||||
message("Found headers at ${NUMPY_INCLUDE_DIR}")
|
||||
INCLUDE_DIRECTORIES(${NUMPY_INCLUDE_DIR})
|
||||
INCLUDE_DIRECTORIES(${NUMPY_INCLUDE_DIR}/..)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF(APPLE)
|
||||
|
||||
|
||||
# Create a static library version
|
||||
add_library(${TARGET_NAME} SHARED ${ARGN})
|
||||
|
||||
target_link_libraries(${TARGET_NAME} ${Boost_PYTHON_LIBRARY} ${PYTHON_LIBRARY} gtsam-shared)
|
||||
set_target_properties(${TARGET_NAME} PROPERTIES
|
||||
OUTPUT_NAME ${TARGET_NAME}
|
||||
CLEAN_DIRECT_OUTPUT 1
|
||||
VERSION 1
|
||||
SOVERSION 0)
|
||||
|
||||
|
||||
# On OSX and Linux, the python library must end in the extension .so. Build this
|
||||
# filename here.
|
||||
get_property(PYLIB_OUTPUT_FILE TARGET ${TARGET_NAME} PROPERTY LOCATION)
|
||||
get_filename_component(PYLIB_OUTPUT_NAME ${PYLIB_OUTPUT_FILE} NAME_WE)
|
||||
set(PYLIB_SO_NAME ${PYLIB_OUTPUT_NAME}.so)
|
||||
|
||||
# Cause the library to be output in the correct directory.
|
||||
add_custom_command(TARGET ${TARGET_NAME}
|
||||
POST_BUILD
|
||||
COMMAND cp -v ${PYLIB_OUTPUT_FILE} ${PYTHON_MODULE_DIRECTORY}/${PYLIB_SO_NAME}
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
COMMENT "Copying library files to python directory" )
|
||||
|
||||
get_directory_property(AMCF ADDITIONAL_MAKE_CLEAN_FILES)
|
||||
list(APPEND AMCF ${PYTHON_MODULE_DIRECTORY}/${PYLIB_SO_NAME})
|
||||
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${AMCF}")
|
||||
endfunction(wrap_python)
|
|
@ -0,0 +1,206 @@
|
|||
# Build macros for using tests
|
||||
|
||||
enable_testing()
|
||||
|
||||
# Enable make check (http://www.cmake.org/Wiki/CMakeEmulateMakeCheck)
|
||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --output-on-failure)
|
||||
add_custom_target(timing)
|
||||
|
||||
# Add option for combining unit tests
|
||||
if(MSVC)
|
||||
option(GTSAM_SINGLE_TEST_EXE "Combine unit tests into single executable (faster compile)" ON)
|
||||
else()
|
||||
option(GTSAM_SINGLE_TEST_EXE "Combine unit tests into single executable (faster compile)" OFF)
|
||||
endif()
|
||||
|
||||
# Macro for adding categorized tests in a "tests" folder, with
|
||||
# optional exclusion of tests and convenience library linking options
|
||||
#
|
||||
# By default, all tests are linked with CppUnitLite and boost
|
||||
# Arguments:
|
||||
# - subdir The name of the category for this test
|
||||
# - local_libs A list of convenience libraries to use (if GTSAM_BUILD_CONVENIENCE_LIBRARIES is true)
|
||||
# - full_libs The main library to link against if not using convenience libraries
|
||||
# - excluded_tests A list of test files that should not be compiled - use for debugging
|
||||
function(gtsam_add_subdir_tests subdir local_libs full_libs excluded_tests)
|
||||
# Subdirectory target for tests
|
||||
add_custom_target(check.${subdir} COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --output-on-failure)
|
||||
set(is_test TRUE)
|
||||
|
||||
# Put check target in Visual Studio solution folder
|
||||
file(RELATIVE_PATH relative_path "${PROJECT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
set_property(TARGET check.${subdir} PROPERTY FOLDER "${relative_path}")
|
||||
|
||||
# Link with CppUnitLite - pulled from gtsam installation
|
||||
list(APPEND local_libs CppUnitLite)
|
||||
list(APPEND full_libs CppUnitLite)
|
||||
|
||||
# Build grouped tests
|
||||
gtsam_add_grouped_scripts("${subdir}" # Use subdirectory as group label
|
||||
"tests/test*.cpp" check "Test" # Standard for all tests
|
||||
"${local_libs}"
|
||||
"${full_libs}" "${excluded_tests}" # Pass in linking and exclusion lists
|
||||
${is_test}) # Set all as tests
|
||||
endfunction()
|
||||
|
||||
# Macro for adding categorized timing scripts in a "tests" folder, with
|
||||
# optional exclusion of tests and convenience library linking options
|
||||
#
|
||||
# By default, all tests are linked with boost
|
||||
# Arguments:
|
||||
# - subdir The name of the category for this timing script
|
||||
# - local_libs A list of convenience libraries to use (if GTSAM_BUILD_CONVENIENCE_LIBRARIES is true)
|
||||
# - full_libs The main library to link against if not using convenience libraries
|
||||
# - excluded_srcs A list of timing files that should not be compiled - use for debugging
|
||||
macro(gtsam_add_subdir_timing subdir local_libs full_libs excluded_srcs)
|
||||
# Subdirectory target for timing - does not actually execute the scripts
|
||||
add_custom_target(timing.${subdir})
|
||||
set(is_test FALSE)
|
||||
|
||||
# Build grouped benchmarks
|
||||
gtsam_add_grouped_scripts("${subdir}" # Use subdirectory as group label
|
||||
"tests/time*.cpp" timing "Timing Benchmark" # Standard for all timing scripts
|
||||
"${local_libs}" "${full_libs}" "${excluded_srcs}" # Pass in linking and exclusion lists
|
||||
${is_test}) # Treat as not a test
|
||||
endmacro()
|
||||
|
||||
# Macro for adding executables matching a pattern - builds one executable for
|
||||
# each file matching the pattern. These exectuables are automatically linked
|
||||
# with boost.
|
||||
# Arguments:
|
||||
# - pattern The glob pattern to match source files
|
||||
# - local_libs A list of convenience libraries to use (if GTSAM_BUILD_CONVENIENCE_LIBRARIES is true)
|
||||
# - full_libs The main library to link against if not using convenience libraries
|
||||
# - excluded_srcs A list of timing files that should not be compiled - use for debugging
|
||||
function(gtsam_add_executables pattern local_libs full_libs excluded_srcs)
|
||||
set(is_test FALSE)
|
||||
|
||||
if(NOT excluded_srcs)
|
||||
set(excluded_srcs "")
|
||||
endif()
|
||||
|
||||
# Build executables
|
||||
gtsam_add_grouped_scripts("" "${pattern}" "" "Executable" "${local_libs}" "${full_libs}" "${excluded_srcs}" ${is_test})
|
||||
endfunction()
|
||||
|
||||
# General-purpose script for adding tests with categories and linking options
|
||||
macro(gtsam_add_grouped_scripts group pattern target_prefix pretty_prefix_name local_libs full_libs excluded_srcs is_test)
|
||||
# Get all script files
|
||||
set(script_files "")
|
||||
foreach(one_pattern ${pattern})
|
||||
file(GLOB one_script_files "${one_pattern}")
|
||||
list(APPEND script_files "${one_script_files}")
|
||||
endforeach()
|
||||
|
||||
# Remove excluded scripts from the list
|
||||
set(exclusions "") # Need to copy out exclusion list for logic to work
|
||||
foreach(one_exclusion ${excluded_srcs})
|
||||
file(GLOB one_exclusion_srcs "${one_exclusion}")
|
||||
list(APPEND exclusions "${one_exclusion_srcs}")
|
||||
endforeach()
|
||||
if(exclusions)
|
||||
list(REMOVE_ITEM script_files ${exclusions})
|
||||
endif(exclusions)
|
||||
|
||||
# Separate into source files and headers
|
||||
set(script_srcs "")
|
||||
set(script_headers "")
|
||||
foreach(script_file ${script_files})
|
||||
get_filename_component(script_ext ${script_file} EXT)
|
||||
if(script_ext MATCHES "(h|H)")
|
||||
list(APPEND script_headers ${script_file})
|
||||
else()
|
||||
list(APPEND script_srcs ${script_file})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
|
||||
# Add targets and dependencies for each script
|
||||
if(NOT "${group}" STREQUAL "")
|
||||
message(STATUS "Adding ${pretty_prefix_name}s in ${group}")
|
||||
endif()
|
||||
|
||||
# Create exe's for each script, unless we're in SINGLE_TEST_EXE mode
|
||||
if(NOT is_test OR NOT GTSAM_SINGLE_TEST_EXE)
|
||||
foreach(script_src ${script_srcs})
|
||||
get_filename_component(script_base ${script_src} NAME_WE)
|
||||
if (script_base) # Check for null filenames and headers
|
||||
set( script_bin ${script_base} )
|
||||
message(STATUS "Adding ${pretty_prefix_name} ${script_bin}")
|
||||
add_executable(${script_bin} ${script_src} ${script_headers})
|
||||
if(NOT "${target_prefix}" STREQUAL "")
|
||||
if(NOT "${group}" STREQUAL "")
|
||||
add_dependencies(${target_prefix}.${group} ${script_bin})
|
||||
endif()
|
||||
add_dependencies(${target_prefix} ${script_bin})
|
||||
endif()
|
||||
|
||||
# Add TOPSRCDIR
|
||||
set_property(SOURCE ${script_src} APPEND PROPERTY COMPILE_DEFINITIONS "TOPSRCDIR=\"${PROJECT_SOURCE_DIR}\"")
|
||||
|
||||
# Disable building during make all/install
|
||||
if (GTSAM_DISABLE_TESTS_ON_INSTALL)
|
||||
set_target_properties(${script_bin} PROPERTIES EXCLUDE_FROM_ALL ON)
|
||||
endif()
|
||||
|
||||
if (is_test)
|
||||
add_test(NAME ${script_base} COMMAND ${script_bin})
|
||||
endif()
|
||||
|
||||
# Linking and dependendencies
|
||||
if (GTSAM_BUILD_CONVENIENCE_LIBRARIES)
|
||||
target_link_libraries(${script_bin} ${local_libs} ${GTSAM_BOOST_LIBRARIES})
|
||||
else()
|
||||
target_link_libraries(${script_bin} ${full_libs} ${GTSAM_BOOST_LIBRARIES})
|
||||
endif()
|
||||
|
||||
# Add .run target
|
||||
if(NOT MSVC)
|
||||
add_custom_target(${script_bin}.run ${EXECUTABLE_OUTPUT_PATH}${script_bin} ${ARGN})
|
||||
endif()
|
||||
|
||||
# Set up Visual Studio folders
|
||||
file(RELATIVE_PATH relative_path "${PROJECT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
set_property(TARGET ${script_bin} PROPERTY FOLDER "${relative_path}")
|
||||
endif()
|
||||
endforeach(script_src)
|
||||
|
||||
if(MSVC)
|
||||
source_group("" FILES ${script_srcs} ${script_headers})
|
||||
endif()
|
||||
else()
|
||||
# Create single unit test exe from all test scripts
|
||||
set(script_bin ${target_prefix}_${group}_prog)
|
||||
add_executable(${script_bin} ${script_srcs} ${script_headers})
|
||||
if (GTSAM_BUILD_CONVENIENCE_LIBRARIES)
|
||||
target_link_libraries(${script_bin} ${local_libs} ${Boost_LIBRARIES})
|
||||
else()
|
||||
target_link_libraries(${script_bin} ${Boost_LIBRARIES} ${full_libs})
|
||||
endif()
|
||||
|
||||
# Only have a main function in one script
|
||||
set(rest_script_srcs ${script_srcs})
|
||||
list(REMOVE_AT rest_script_srcs 0)
|
||||
set_property(SOURCE ${rest_script_srcs} APPEND PROPERTY COMPILE_DEFINITIONS "main=static no_main")
|
||||
|
||||
# Add TOPSRCDIR
|
||||
set_property(SOURCE ${script_srcs} APPEND PROPERTY COMPILE_DEFINITIONS "TOPSRCDIR=\"${PROJECT_SOURCE_DIR}\"")
|
||||
|
||||
# Add test
|
||||
add_dependencies(${target_prefix}.${group} ${script_bin})
|
||||
add_dependencies(${target_prefix} ${script_bin})
|
||||
add_test(NAME ${target_prefix}.${group} COMMAND ${script_bin})
|
||||
|
||||
# Disable building during make all/install
|
||||
if (GTSAM_DISABLE_TESTS_ON_INSTALL)
|
||||
set_target_properties(${script_bin} PROPERTIES EXCLUDE_FROM_ALL ON)
|
||||
endif()
|
||||
|
||||
# Set up Visual Studio folders
|
||||
if(MSVC)
|
||||
file(RELATIVE_PATH relative_path "${PROJECT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
set_property(TARGET ${script_bin} PROPERTY FOLDER "${relative_path}")
|
||||
source_group("" FILES ${script_srcs} ${script_headers})
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
|
@ -0,0 +1,46 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
|
||||
* @library_name@ Copyright 2010, Georgia Tech Research Corporation,
|
||||
* Atlanta, Georgia 30332-0415
|
||||
* All Rights Reserved
|
||||
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
|
||||
|
||||
* See LICENSE for the license information
|
||||
|
||||
* -------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @file dllexport.h
|
||||
* @brief Symbols for exporting classes and methods from DLLs
|
||||
* @author Richard Roberts
|
||||
* @date Mar 9, 2013
|
||||
*/
|
||||
|
||||
// Macros for exporting DLL symbols on Windows
|
||||
// Usage example:
|
||||
// In header file:
|
||||
// class GTSAM_EXPORT MyClass { ... };
|
||||
//
|
||||
// Results in the following declarations:
|
||||
// When included while compiling the GTSAM library itself:
|
||||
// class __declspec(dllexport) MyClass { ... };
|
||||
// When included while compiling other code against GTSAM:
|
||||
// class __declspec(dllimport) MyClass { ... };
|
||||
#ifdef _WIN32
|
||||
# ifdef @library_name@_EXPORTS
|
||||
# define @library_name@_EXPORT __declspec(dllexport)
|
||||
# define @library_name@_EXTERN_EXPORT __declspec(dllexport) extern
|
||||
# else
|
||||
# ifndef @library_name@_IMPORT_STATIC
|
||||
# define @library_name@_EXPORT __declspec(dllimport)
|
||||
# define @library_name@_EXTERN_EXPORT __declspec(dllimport)
|
||||
# else /* @library_name@_IMPORT_STATIC */
|
||||
# define @library_name@_EXPORT
|
||||
# define @library_name@_EXTERN_EXPORT extern
|
||||
# endif /* @library_name@_IMPORT_STATIC */
|
||||
# endif /* @library_name@_EXPORTS */
|
||||
#else /* _WIN32 */
|
||||
# define @library_name@_EXPORT
|
||||
# define @library_name@_EXTERN_EXPORT extern
|
||||
#endif
|
||||
|
|
@ -0,0 +1,173 @@
|
|||
# This file should be used as a template for creating new projects using the CMake tools
|
||||
# This project has the following features
|
||||
# - GTSAM linking
|
||||
# - Boost linking
|
||||
# - Unit tests via CppUnitLite
|
||||
# - Automatic detection of sources and headers in subfolders
|
||||
# - Installation of library and headers
|
||||
# - Matlab wrap interface with within-project building
|
||||
# - Use of GTSAM cmake macros
|
||||
|
||||
###################################################################################
|
||||
# To create your own project, replace "myproject" with the actual name of your project
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
enable_testing()
|
||||
project(myproject CXX C)
|
||||
|
||||
# Add the cmake subfolder to the cmake module path - necessary to use macros
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${PROJECT_SOURCE_DIR}/cmake")
|
||||
|
||||
# Ensure that local folder is searched before library folders
|
||||
include_directories(BEFORE "${PROJECT_SOURCE_DIR}")
|
||||
|
||||
# Load build type flags and default to Debug mode
|
||||
include(GtsamBuildTypes)
|
||||
|
||||
###################################################################################
|
||||
# Create a list of library dependencies
|
||||
# These will be linked with executables
|
||||
set(library_deps "")
|
||||
set(linking_mode "static")
|
||||
|
||||
# Find GTSAM components
|
||||
find_package(GTSAM REQUIRED) # Uses installed package
|
||||
list(APPEND library_deps gtsam-${linking_mode} gtsam_unstable-${linking_mode})
|
||||
|
||||
# Include ransac
|
||||
find_package(ransac REQUIRED) # Uses installed package
|
||||
list(APPEND library_deps ransac-${linking_mode})
|
||||
|
||||
# Boost - same requirement as gtsam
|
||||
find_package(Boost 1.43 COMPONENTS
|
||||
serialization
|
||||
system
|
||||
filesystem
|
||||
thread
|
||||
date_time
|
||||
REQUIRED)
|
||||
list(APPEND library_deps
|
||||
${Boost_SERIALIZATION_LIBRARY}
|
||||
${Boost_SYSTEM_LIBRARY}
|
||||
${Boost_FILESYSTEM_LIBRARY}
|
||||
${Boost_THREAD_LIBRARY}
|
||||
${Boost_DATE_TIME_LIBRARY})
|
||||
|
||||
include_directories(${Boost_INCLUDE_DIR} ${GTSAM_INCLUDE_DIR} ${ransac_INCLUDE_DIR})
|
||||
|
||||
###################################################################################
|
||||
# List subdirs to process tests/sources
|
||||
# Each of these will be scanned for new files
|
||||
set (myproject_subdirs
|
||||
"." # ensure root folder gets included
|
||||
stuff
|
||||
things
|
||||
)
|
||||
|
||||
# loop through subdirs to install and build up source lists
|
||||
set(myproject_lib_source "")
|
||||
set(myproject_tests_source "")
|
||||
set(myproject_scripts_source "")
|
||||
foreach(subdir ${myproject_subdirs})
|
||||
# Installing headers
|
||||
message(STATUS "Installing ${subdir}")
|
||||
file(GLOB sub_myproject_headers "myproject/${subdir}/*.h")
|
||||
install(FILES ${sub_myproject_headers} DESTINATION include/myproject/${subdir})
|
||||
|
||||
# add sources to main sources list
|
||||
file(GLOB subdir_srcs "myproject/${subdir}/*.cpp")
|
||||
list(APPEND myproject_lib_source ${subdir_srcs})
|
||||
|
||||
# add tests to main tests list
|
||||
file(GLOB subdir_test_srcs "myproject/${subdir}/tests/*.cpp")
|
||||
list(APPEND myproject_tests_source ${subdir_test_srcs})
|
||||
|
||||
# add scripts to main tests list
|
||||
file(GLOB subdir_scripts_srcs "myproject/${subdir}/scripts/*.cpp")
|
||||
list(APPEND myproject_scripts_source ${subdir_scripts_srcs})
|
||||
endforeach(subdir)
|
||||
|
||||
set(myproject_version ${myproject_VERSION_MAJOR}.${myproject_VERSION_MINOR}.${myproject_VERSION_PATCH})
|
||||
set(myproject_soversion ${myproject_VERSION_MAJOR})
|
||||
message(STATUS "GTSAM Version: ${gtsam_version}")
|
||||
message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}")
|
||||
|
||||
# Build library (static and shared versions)
|
||||
# Include installed versions
|
||||
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
add_library(${PROJECT_NAME}-shared SHARED ${myproject_lib_source})
|
||||
set_target_properties(${PROJECT_NAME}-shared PROPERTIES
|
||||
OUTPUT_NAME ${PROJECT_NAME}
|
||||
CLEAN_DIRECT_OUTPUT 1)
|
||||
install(TARGETS myproject-shared EXPORT myproject-exports LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION bin)
|
||||
list(APPEND myproject_EXPORTED_TARGETS myproject-shared)
|
||||
|
||||
add_library(${PROJECT_NAME}-static STATIC ${myproject_lib_source})
|
||||
set_target_properties(${PROJECT_NAME}-static PROPERTIES
|
||||
OUTPUT_NAME ${PROJECT_NAME}
|
||||
CLEAN_DIRECT_OUTPUT 1)
|
||||
install(TARGETS myproject-static EXPORT myproject-exports ARCHIVE DESTINATION lib)
|
||||
list(APPEND myproject_EXPORTED_TARGETS myproject-static)
|
||||
|
||||
install(TARGETS ${PROJECT_NAME}-shared LIBRARY DESTINATION lib )
|
||||
install(TARGETS ${PROJECT_NAME}-static ARCHIVE DESTINATION lib )
|
||||
|
||||
# Disabled tests - subtract these from the test files
|
||||
# Note the need for a full path
|
||||
set(disabled_tests
|
||||
"dummy"
|
||||
#"${PROJECT_SOURCE_DIR}/myproject/geometry/tests/testCovarianceEllipse.cpp"
|
||||
)
|
||||
list(REMOVE_ITEM myproject_tests_source ${disabled_tests})
|
||||
|
||||
###################################################################################
|
||||
# Build tests
|
||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
|
||||
foreach(test_src_file ${myproject_tests_source})
|
||||
get_filename_component(test_base ${test_src_file} NAME_WE)
|
||||
message(STATUS "Adding test ${test_src_file} with base name ${test_base}" )
|
||||
add_executable(${test_base} ${test_src_file})
|
||||
target_link_libraries(${test_base} ${PROJECT_NAME}-${linking_mode} ${library_deps} CppUnitLite)
|
||||
add_test(${test_base} ${EXECUTABLE_OUTPUT_PATH}/${test_base})
|
||||
add_custom_target(${test_base}.run ${test_base} ${ARGN})
|
||||
add_dependencies(check ${test_base})
|
||||
endforeach(test_src_file)
|
||||
|
||||
# Build scripts
|
||||
foreach(script_src_file ${myproject_scripts_source})
|
||||
get_filename_component(script_base ${script_src_file} NAME_WE)
|
||||
message(STATUS "Adding script ${script_src_file} with base name ${script_base}" )
|
||||
add_executable(${script_base} ${script_src_file})
|
||||
target_link_libraries(${script_base} ${PROJECT_NAME}-${linking_mode} ${library_deps} CppUnitLite)
|
||||
add_custom_target(${script_base}.run ${script_base} ${ARGN})
|
||||
endforeach(script_src_file)
|
||||
|
||||
###################################################################################
|
||||
# Matlab wrapping
|
||||
include(GtsamMatlabWrap)
|
||||
set(MEX_COMMAND "mex" CACHE STRING "Command to use for executing mex (if on path, 'mex' will work)")
|
||||
set(GTSAM_BUILD_MEX_BINARY_FLAGS "" CACHE STRING "Extra flags for running Matlab MEX compilation")
|
||||
set(MYPROJECT_TOOLBOX_DIR "../matlab/myproject" CACHE PATH "Install folder for matlab toolbox - defaults to inside project")
|
||||
set(WRAP_HEADER_PATH "${GTSAM_DIR}/../../../include")
|
||||
set(MYPROJECT_TOOLBOX_FLAGS
|
||||
${GTSAM_BUILD_MEX_BINARY_FLAGS} -I${PROJECT_SOURCE_DIR} -I${PROJECT_SOURCE_DIR}/myproject -I${Boost_INCLUDE_DIR} -I${MEX_INCLUDE_ROOT} -I${GTSAM_INCLUDE_DIR} -I${WRAP_HEADER_PATH} -Wl,-rpath,${CMAKE_BINARY_DIR}:${CMAKE_INSTALL_PREFIX}/lib)
|
||||
set(MYPROJECT_LIBRARY_DEPS gtsam gtsam_unstable ransac myproject)
|
||||
set(GTSAM_BUILD_MEX_BIN ON)
|
||||
|
||||
# Function to setup codegen, building and installation of the wrap toolbox
|
||||
# This wrap setup function assumes that the toolbox will be installed directly,
|
||||
# with predictable matlab.h sourcing
|
||||
# params:
|
||||
# moduleName : the name of the module, interface file must be called moduleName.h
|
||||
# mexFlags : Compilation flags to be passed to the mex compiler
|
||||
# modulePath : relative path to module markup header file (called moduleName.h)
|
||||
# otherLibraries : list of library targets this should depend on
|
||||
# toolboxPath : the directory in which to generate/build wrappers
|
||||
# wrap_header_path : path to the installed wrap header
|
||||
wrap_library_generic(myproject "${MYPROJECT_TOOLBOX_FLAGS}" "" "${MYPROJECT_LIBRARY_DEPS}" "${MYPROJECT_TOOLBOX_DIR}" "${WRAP_HEADER_PATH}")
|
||||
|
||||
###################################################################################
|
||||
# Create Install config and export files
|
||||
# This config file takes the place of FindXXX.cmake scripts
|
||||
include(GtsamMakeConfigFile)
|
||||
GtsamMakeConfigFile(myproject)
|
||||
export(TARGETS ${myproject_EXPORTED_TARGETS} FILE myproject-exports.cmake)
|
|
@ -0,0 +1,38 @@
|
|||
# This file should be used as a template for creating new projects using the CMake tools
|
||||
# This project has the following features
|
||||
# - GTSAM linking
|
||||
# - Unit tests via CppUnitLite
|
||||
# - Scripts
|
||||
|
||||
###################################################################################
|
||||
# To create your own project, replace "myproject" with the actual name of your project
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
enable_testing()
|
||||
project(myproject CXX C)
|
||||
|
||||
# Add the cmake subfolder to the cmake module path - necessary to use macros
|
||||
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
|
||||
|
||||
# Ensure that local folder is searched before library folders
|
||||
include_directories(BEFORE "${PROJECT_SOURCE_DIR}")
|
||||
|
||||
# Load build type flags and default to Debug mode
|
||||
include(GtsamBuildTypes)
|
||||
|
||||
###################################################################################
|
||||
# Find GTSAM components
|
||||
find_package(GTSAM REQUIRED) # Uses installed package
|
||||
include_directories(${GTSAM_INCLUDE_DIR})
|
||||
|
||||
###################################################################################
|
||||
# Build static library from common sources
|
||||
add_library(${PROJECT_NAME} STATIC ${PROJECT_NAME}/MySourceFiles.cpp)
|
||||
target_link_libraries(${PROJECT_NAME} gtsam-shared)
|
||||
|
||||
###################################################################################
|
||||
# Build tests (CMake tracks the dependecy to link with GTSAM through our project's static library)
|
||||
gtsam_add_subdir_tests(${PROJECT_NAME} "${PROJECT_NAME}" "${PROJECT_NAME}" "")
|
||||
|
||||
###################################################################################
|
||||
# Build scripts (CMake tracks the dependecy to link with GTSAM through our project's static library)
|
||||
gtsam_add_executables("${PROJECT_NAME}/myScripts.cpp" "${PROJECT_NAME}" "${PROJECT_NAME}" "")
|
|
@ -0,0 +1,47 @@
|
|||
# This is FindCppUnitLite.cmake
|
||||
# DEPRECIATED: Use config file approach to pull in targets from gtsam
|
||||
# CMake module to locate the CppUnit package
|
||||
# The following variables will be defined:
|
||||
#
|
||||
# CppUnitLite_FOUND : TRUE if the package has been successfully found
|
||||
# CppUnitLite_INCLUDE_DIR : paths to CppUnitLite's INCLUDE directories
|
||||
# CppUnitLite_LIBS : paths to CppUnitLite's libraries
|
||||
|
||||
# If gtsam was found by a previous call to FindGTSAM, prefer to find the
|
||||
# CppUnitLite in the same place as that gtsam
|
||||
if(GTSAM_LIBS)
|
||||
# Find the gtsam library path found by a previous call to FindGTSAM
|
||||
get_filename_component(_gtsam_lib_dir "${GTSAM_LIBS}" PATH)
|
||||
get_filename_component(_gtsam_lib_dir_name "${_gtsam_lib_dir}" NAME)
|
||||
# If the gtsam library was in a directory called 'gtsam', it means we found
|
||||
# gtsam in the source tree, otherwise (probably 'lib') in an installed location.
|
||||
if(_gtsam_lib_dir_name STREQUAL "gtsam")
|
||||
get_filename_component(_gtsam_build_dir "${_gtsam_lib_dir}" PATH)
|
||||
set(_gtsam_cppunitlite_dir "${_gtsam_build_dir}/CppUnitLite")
|
||||
else()
|
||||
set(_gtsam_cppunitlite_dir "${_gtsam_lib_dir}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(GTSAM_LIBS)
|
||||
# Twice to get the build directory, not build/gtsam
|
||||
get_filename_component(_gtsam_build_dir "${GTSAM_LIBS}" PATH)
|
||||
get_filename_component(_gtsam_build_dir "${_gtsam_build_dir}" PATH)
|
||||
endif()
|
||||
|
||||
# Find include dirs
|
||||
find_path(CppUnitLite_INCLUDE_DIR CppUnitLite/Test.h
|
||||
PATHS "${GTSAM_INCLUDE_DIR}" ${CMAKE_INSTALL_PREFIX}/include "$ENV{HOME}/include" /usr/local/include /usr/include
|
||||
DOC "CppUnitLite INCLUDE directories")
|
||||
|
||||
# Find libraries
|
||||
find_library(CppUnitLite_LIBS NAMES CppUnitLite
|
||||
HINTS "${_gtsam_cppunitlite_dir}" ${CMAKE_INSTALL_PREFIX}/lib "$ENV{HOME}/lib" /usr/local/lib /usr/lib
|
||||
DOC "CppUnitLite libraries")
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set CppUnitLite_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(CppUnitLite DEFAULT_MSG
|
||||
CppUnitLite_LIBS CppUnitLite_INCLUDE_DIR)
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
# This is FindGTSAM.cmake
|
||||
# DEPRECIATED: Use config file approach to pull in targets from gtsam
|
||||
# CMake module to locate the GTSAM package
|
||||
#
|
||||
# The following cache variables may be set before calling this script:
|
||||
#
|
||||
# GTSAM_DIR (or GTSAM_ROOT): (Optional) The install prefix OR source tree of gtsam (e.g. /usr/local or src/gtsam)
|
||||
# GTSAM_BUILD_NAME: (Optional) If compiling against a source tree, the name of the build directory
|
||||
# within it (e.g build-debug). Without this defined, this script tries to
|
||||
# intelligently find the build directory based on the project's build directory name
|
||||
# or based on the build type (Debug/Release/etc).
|
||||
#
|
||||
# The following variables will be defined:
|
||||
#
|
||||
# GTSAM_FOUND : TRUE if the package has been successfully found
|
||||
# GTSAM_INCLUDE_DIR : paths to GTSAM's INCLUDE directories
|
||||
# GTSAM_LIBS : paths to GTSAM's libraries
|
||||
#
|
||||
# NOTES on compiling against an uninstalled GTSAM build tree:
|
||||
# - A GTSAM source tree will be automatically searched for in the directory
|
||||
# 'gtsam' next to your project directory, after searching
|
||||
# CMAKE_INSTALL_PREFIX and $HOME, but before searching /usr/local and /usr.
|
||||
# - The build directory will be searched first with the same name as your
|
||||
# project's build directory, e.g. if you build from 'MyProject/build-optimized',
|
||||
# 'gtsam/build-optimized' will be searched first. Next, a build directory for
|
||||
# your project's build type, e.g. if CMAKE_BUILD_TYPE in your project is
|
||||
# 'Release', then 'gtsam/build-release' will be searched next. Finally, plain
|
||||
# 'gtsam/build' will be searched.
|
||||
# - You can control the gtsam build directory name directly by defining the CMake
|
||||
# cache variable 'GTSAM_BUILD_NAME', then only 'gtsam/${GTSAM_BUILD_NAME} will
|
||||
# be searched.
|
||||
# - Use the standard CMAKE_PREFIX_PATH, or GTSAM_DIR, to find a specific gtsam
|
||||
# directory.
|
||||
|
||||
# Get path suffixes to help look for gtsam
|
||||
if(GTSAM_BUILD_NAME)
|
||||
set(gtsam_build_names "${GTSAM_BUILD_NAME}/gtsam")
|
||||
else()
|
||||
# lowercase build type
|
||||
string(TOLOWER "${CMAKE_BUILD_TYPE}" build_type_suffix)
|
||||
# build suffix of this project
|
||||
get_filename_component(my_build_name "${CMAKE_BINARY_DIR}" NAME)
|
||||
|
||||
set(gtsam_build_names "${my_build_name}/gtsam" "build-${build_type_suffix}/gtsam" "build/gtsam")
|
||||
endif()
|
||||
|
||||
# Use GTSAM_ROOT or GTSAM_DIR equivalently
|
||||
if(GTSAM_ROOT AND NOT GTSAM_DIR)
|
||||
set(GTSAM_DIR "${GTSAM_ROOT}")
|
||||
endif()
|
||||
|
||||
if(GTSAM_DIR)
|
||||
# Find include dirs
|
||||
find_path(GTSAM_INCLUDE_DIR gtsam/inference/FactorGraph.h
|
||||
PATHS "${GTSAM_DIR}/include" "${GTSAM_DIR}" NO_DEFAULT_PATH
|
||||
DOC "GTSAM include directories")
|
||||
|
||||
# Find libraries
|
||||
find_library(GTSAM_LIBS NAMES gtsam
|
||||
HINTS "${GTSAM_DIR}/lib" "${GTSAM_DIR}" NO_DEFAULT_PATH
|
||||
PATH_SUFFIXES ${gtsam_build_names}
|
||||
DOC "GTSAM libraries")
|
||||
else()
|
||||
# Find include dirs
|
||||
set(extra_include_paths ${CMAKE_INSTALL_PREFIX}/include "$ENV{HOME}/include" "${PROJECT_SOURCE_DIR}/../gtsam" /usr/local/include /usr/include)
|
||||
find_path(GTSAM_INCLUDE_DIR gtsam/inference/FactorGraph.h
|
||||
PATHS ${extra_include_paths}
|
||||
DOC "GTSAM include directories")
|
||||
if(NOT GTSAM_INCLUDE_DIR)
|
||||
message(STATUS "Searched for gtsam headers in default paths plus ${extra_include_paths}")
|
||||
endif()
|
||||
|
||||
# Find libraries
|
||||
find_library(GTSAM_LIBS NAMES gtsam
|
||||
HINTS ${CMAKE_INSTALL_PREFIX}/lib "$ENV{HOME}/lib" "${PROJECT_SOURCE_DIR}/../gtsam" /usr/local/lib /usr/lib
|
||||
PATH_SUFFIXES ${gtsam_build_names}
|
||||
DOC "GTSAM libraries")
|
||||
endif()
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set GTSAM_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(GTSAM DEFAULT_MSG
|
||||
GTSAM_LIBS GTSAM_INCLUDE_DIR)
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
# This is FindGTSAM_UNSTABLE.cmake
|
||||
# DEPRECIATED: Use config file approach to pull in targets from gtsam
|
||||
# CMake module to locate the GTSAM_UNSTABLE package
|
||||
#
|
||||
# The following cache variables may be set before calling this script:
|
||||
#
|
||||
# GTSAM_UNSTABLE_DIR (or GTSAM_UNSTABLE_ROOT): (Optional) The install prefix OR source tree of gtsam_unstable (e.g. /usr/local or src/gtsam_unstable)
|
||||
# GTSAM_UNSTABLE_BUILD_NAME: (Optional) If compiling against a source tree, the name of the build directory
|
||||
# within it (e.g build-debug). Without this defined, this script tries to
|
||||
# intelligently find the build directory based on the project's build directory name
|
||||
# or based on the build type (Debug/Release/etc).
|
||||
#
|
||||
# The following variables will be defined:
|
||||
#
|
||||
# GTSAM_UNSTABLE_FOUND : TRUE if the package has been successfully found
|
||||
# GTSAM_UNSTABLE_INCLUDE_DIR : paths to GTSAM_UNSTABLE's INCLUDE directories
|
||||
# GTSAM_UNSTABLE_LIBS : paths to GTSAM_UNSTABLE's libraries
|
||||
#
|
||||
# NOTES on compiling against an uninstalled GTSAM_UNSTABLE build tree:
|
||||
# - A GTSAM_UNSTABLE source tree will be automatically searched for in the directory
|
||||
# 'gtsam_unstable' next to your project directory, after searching
|
||||
# CMAKE_INSTALL_PREFIX and $HOME, but before searching /usr/local and /usr.
|
||||
# - The build directory will be searched first with the same name as your
|
||||
# project's build directory, e.g. if you build from 'MyProject/build-optimized',
|
||||
# 'gtsam_unstable/build-optimized' will be searched first. Next, a build directory for
|
||||
# your project's build type, e.g. if CMAKE_BUILD_TYPE in your project is
|
||||
# 'Release', then 'gtsam_unstable/build-release' will be searched next. Finally, plain
|
||||
# 'gtsam_unstable/build' will be searched.
|
||||
# - You can control the gtsam build directory name directly by defining the CMake
|
||||
# cache variable 'GTSAM_UNSTABLE_BUILD_NAME', then only 'gtsam/${GTSAM_UNSTABLE_BUILD_NAME} will
|
||||
# be searched.
|
||||
# - Use the standard CMAKE_PREFIX_PATH, or GTSAM_UNSTABLE_DIR, to find a specific gtsam
|
||||
# directory.
|
||||
|
||||
# Get path suffixes to help look for gtsam_unstable
|
||||
if(GTSAM_UNSTABLE_BUILD_NAME)
|
||||
set(gtsam_unstable_build_names "${GTSAM_UNSTABLE_BUILD_NAME}/gtsam_unstable")
|
||||
else()
|
||||
# lowercase build type
|
||||
string(TOLOWER "${CMAKE_BUILD_TYPE}" build_type_suffix)
|
||||
# build suffix of this project
|
||||
get_filename_component(my_build_name "${CMAKE_BINARY_DIR}" NAME)
|
||||
|
||||
set(gtsam_unstable_build_names "${my_build_name}/gtsam_unstable" "build-${build_type_suffix}/gtsam_unstable" "build/gtsam_unstable")
|
||||
endif()
|
||||
|
||||
# Use GTSAM_UNSTABLE_ROOT or GTSAM_UNSTABLE_DIR equivalently
|
||||
if(GTSAM_UNSTABLE_ROOT AND NOT GTSAM_UNSTABLE_DIR)
|
||||
set(GTSAM_UNSTABLE_DIR "${GTSAM_UNSTABLE_ROOT}")
|
||||
endif()
|
||||
|
||||
if(GTSAM_UNSTABLE_DIR)
|
||||
# Find include dirs
|
||||
find_path(GTSAM_UNSTABLE_INCLUDE_DIR gtsam_unstable/base/DSF.h
|
||||
PATHS "${GTSAM_UNSTABLE_DIR}/include" "${GTSAM_UNSTABLE_DIR}" NO_DEFAULT_PATH
|
||||
DOC "GTSAM_UNSTABLE include directories")
|
||||
|
||||
# Find libraries
|
||||
find_library(GTSAM_UNSTABLE_LIBS NAMES gtsam_unstable
|
||||
HINTS "${GTSAM_UNSTABLE_DIR}/lib" "${GTSAM_UNSTABLE_DIR}" NO_DEFAULT_PATH
|
||||
PATH_SUFFIXES ${gtsam_unstable_build_names}
|
||||
DOC "GTSAM_UNSTABLE libraries")
|
||||
else()
|
||||
# Find include dirs
|
||||
set(extra_include_paths ${CMAKE_INSTALL_PREFIX}/include "$ENV{HOME}/include" "${PROJECT_SOURCE_DIR}/../gtsam" /usr/local/include /usr/include)
|
||||
find_path(GTSAM_UNSTABLE_INCLUDE_DIR gtsam_unstable/base/DSF.h
|
||||
PATHS ${extra_include_paths}
|
||||
DOC "GTSAM_UNSTABLE include directories")
|
||||
if(NOT GTSAM_UNSTABLE_INCLUDE_DIR)
|
||||
message(STATUS "Searched for gtsam_unstable headers in default paths plus ${extra_include_paths}")
|
||||
endif()
|
||||
|
||||
# Find libraries
|
||||
find_library(GTSAM_UNSTABLE_LIBS NAMES gtsam_unstable
|
||||
HINTS ${CMAKE_INSTALL_PREFIX}/lib "$ENV{HOME}/lib" "${PROJECT_SOURCE_DIR}/../gtsam" /usr/local/lib /usr/lib
|
||||
PATH_SUFFIXES ${gtsam_unstable_build_names}
|
||||
DOC "GTSAM_UNSTABLE libraries")
|
||||
endif()
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set GTSAM_UNSTABLE_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(GTSAM_UNSTABLE DEFAULT_MSG
|
||||
GTSAM_UNSTABLE_LIBS GTSAM_UNSTABLE_INCLUDE_DIR)
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
# This is FindWrap.cmake
|
||||
# DEPRECIATED: Use config file approach to pull in targets from gtsam
|
||||
# CMake module to locate the Wrap tool and header after installation package
|
||||
# The following variables will be defined:
|
||||
#
|
||||
# Wrap_FOUND : TRUE if the package has been successfully found
|
||||
# Wrap_CMD : command for executing wrap
|
||||
# Wrap_INCLUDE_DIR : paths to Wrap's INCLUDE directories
|
||||
|
||||
# If gtsam was found by a previous call to FindGTSAM, prefer to find the
|
||||
# wrap in the same place as that gtsam
|
||||
if(GTSAM_LIBS)
|
||||
# Find the gtsam library path found by a previous call to FindGTSAM
|
||||
get_filename_component(_gtsam_lib_dir "${GTSAM_LIBS}" PATH)
|
||||
get_filename_component(_gtsam_lib_dir_name "${_gtsam_lib_dir}" NAME)
|
||||
# If the gtsam library was in a directory called 'gtsam', it means we found
|
||||
# gtsam in the source tree, otherwise (probably 'lib') in an installed location.
|
||||
if(_gtsam_lib_dir_name STREQUAL "gtsam")
|
||||
get_filename_component(_gtsam_build_dir "${_gtsam_lib_dir}" PATH)
|
||||
set(_gtsam_wrap_dir "${_gtsam_build_dir}/wrap")
|
||||
else()
|
||||
set(_gtsam_wrap_dir "${_gtsam_lib_dir}/../bin")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Find include dir
|
||||
find_path(Wrap_INCLUDE_DIR wrap/matlab.h
|
||||
PATHS "${GTSAM_INCLUDE_DIR}" ${CMAKE_INSTALL_PREFIX}/include "$ENV{HOME}/include" /usr/local/include /usr/include
|
||||
DOC "Wrap INCLUDE directories")
|
||||
|
||||
# Find the installed executable
|
||||
find_program(Wrap_CMD NAMES wrap
|
||||
PATHS "${_gtsam_wrap_dir}" ${CMAKE_INSTALL_PREFIX}/bin "$ENV{HOME}/bin" /usr/local/bin /usr/bin
|
||||
DOC "Wrap executable location")
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set Wrap_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Wrap DEFAULT_MSG
|
||||
Wrap_CMD Wrap_INCLUDE_DIR)
|
||||
|
Loading…
Reference in New Issue