Adding buildtools not used by gtsam, but used by other projects (figuring people will always have gtsam checked out)
parent
43e4c66407
commit
da36d07b93
|
@ -0,0 +1,246 @@
|
||||||
|
# - Try to find OpenCV library installation
|
||||||
|
# See http://sourceforge.net/projects/opencvlibrary/
|
||||||
|
#
|
||||||
|
# The follwoing variables are optionally searched for defaults
|
||||||
|
# OpenCV_ROOT_DIR: Base directory of OpenCv tree to use.
|
||||||
|
# OpenCV_FIND_REQUIRED_COMPONENTS : FIND_PACKAGE(OpenCV COMPONENTS ..)
|
||||||
|
# compatible interface. typically CV CXCORE CVAUX HIGHGUI CVCAM .. etc.
|
||||||
|
#
|
||||||
|
# The following are set after configuration is done:
|
||||||
|
# OpenCV_FOUND
|
||||||
|
# OpenCV_INCLUDE_DIR
|
||||||
|
# OpenCV_LIBRARIES
|
||||||
|
# OpenCV_LINK_DIRECTORIES
|
||||||
|
#
|
||||||
|
# deprecated:
|
||||||
|
# OPENCV_* uppercase replaced by case sensitive OpenCV_*
|
||||||
|
# OPENCV_EXE_LINKER_FLAGS
|
||||||
|
# OPENCV_INCLUDE_DIR : replaced by plural *_DIRS
|
||||||
|
#
|
||||||
|
# 2004/05 Jan Woetzel, Friso, Daniel Grest
|
||||||
|
# 2006/01 complete rewrite by Jan Woetzel
|
||||||
|
# 1006/09 2nd rewrite introducing ROOT_DIR and PATH_SUFFIXES
|
||||||
|
# to handle multiple installed versions gracefully by Jan Woetzel
|
||||||
|
#
|
||||||
|
# tested with:
|
||||||
|
# -OpenCV 0.97 (beta5a): MSVS 7.1, gcc 3.3, gcc 4.1
|
||||||
|
# -OpenCV 0.99 (1.0rc1): MSVS 7.1
|
||||||
|
#
|
||||||
|
# www.mip.informatik.uni-kiel.de/~jw
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
MACRO(DBG_MSG _MSG)
|
||||||
|
# MESSAGE(STATUS "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}):\n${_MSG}")
|
||||||
|
ENDMACRO(DBG_MSG)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# required cv components with header and library if COMPONENTS unspecified
|
||||||
|
IF (NOT OpenCV_FIND_COMPONENTS)
|
||||||
|
# default
|
||||||
|
SET(OpenCV_FIND_REQUIRED_COMPONENTS CV CXCORE CVAUX HIGHGUI )
|
||||||
|
IF (WIN32)
|
||||||
|
LIST(APPEND OpenCV_FIND_REQUIRED_COMPONENTS CVCAM ) # WIN32 only actually
|
||||||
|
ENDIF(WIN32)
|
||||||
|
ENDIF (NOT OpenCV_FIND_COMPONENTS)
|
||||||
|
|
||||||
|
|
||||||
|
# typical root dirs of installations, exactly one of them is used
|
||||||
|
SET (OpenCV_POSSIBLE_ROOT_DIRS
|
||||||
|
"${OpenCV_ROOT_DIR}"
|
||||||
|
"$ENV{OpenCV_ROOT_DIR}"
|
||||||
|
"$ENV{OPENCV_DIR}" # only for backward compatibility deprecated by ROOT_DIR
|
||||||
|
"$ENV{OPENCV_HOME}" # only for backward compatibility
|
||||||
|
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Intel(R) Open Source Computer Vision Library_is1;Inno Setup: App Path]"
|
||||||
|
"$ENV{ProgramFiles}/OpenCV"
|
||||||
|
/usr/local
|
||||||
|
/usr
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# MIP Uni Kiel /opt/net network installation
|
||||||
|
# get correct prefix for current gcc compiler version for gcc 3.x 4.x
|
||||||
|
IF (${CMAKE_COMPILER_IS_GNUCXX})
|
||||||
|
IF (NOT OpenCV_FIND_QUIETLY)
|
||||||
|
MESSAGE(STATUS "Checking GNUCXX version 3/4 to determine OpenCV /opt/net/ path")
|
||||||
|
ENDIF (NOT OpenCV_FIND_QUIETLY)
|
||||||
|
EXEC_PROGRAM(${CMAKE_CXX_COMPILER} ARGS --version OUTPUT_VARIABLE CXX_COMPILER_VERSION)
|
||||||
|
IF (CXX_COMPILER_VERSION MATCHES ".*3\\.[0-9].*")
|
||||||
|
SET(IS_GNUCXX3 TRUE)
|
||||||
|
LIST(APPEND OpenCV_POSSIBLE_ROOT_DIRS /opt/net/gcc33/OpenCV )
|
||||||
|
ENDIF(CXX_COMPILER_VERSION MATCHES ".*3\\.[0-9].*")
|
||||||
|
IF (CXX_COMPILER_VERSION MATCHES ".*4\\.[0-9].*")
|
||||||
|
SET(IS_GNUCXX4 TRUE)
|
||||||
|
LIST(APPEND OpenCV_POSSIBLE_ROOT_DIRS /opt/net/gcc41/OpenCV )
|
||||||
|
ENDIF(CXX_COMPILER_VERSION MATCHES ".*4\\.[0-9].*")
|
||||||
|
ENDIF (${CMAKE_COMPILER_IS_GNUCXX})
|
||||||
|
|
||||||
|
#DBG_MSG("DBG (OpenCV_POSSIBLE_ROOT_DIRS=${OpenCV_POSSIBLE_ROOT_DIRS}")
|
||||||
|
|
||||||
|
#
|
||||||
|
# select exactly ONE OpenCV base directory/tree
|
||||||
|
# to avoid mixing different version headers and libs
|
||||||
|
#
|
||||||
|
FIND_PATH(OpenCV_ROOT_DIR
|
||||||
|
NAMES
|
||||||
|
cv/include/cv.h # windows
|
||||||
|
include/opencv/cv.h # linux /opt/net
|
||||||
|
include/cv/cv.h
|
||||||
|
include/cv.h
|
||||||
|
PATHS ${OpenCV_POSSIBLE_ROOT_DIRS})
|
||||||
|
DBG_MSG("OpenCV_ROOT_DIR=${OpenCV_ROOT_DIR}")
|
||||||
|
|
||||||
|
|
||||||
|
# header include dir suffixes appended to OpenCV_ROOT_DIR
|
||||||
|
SET(OpenCV_INCDIR_SUFFIXES
|
||||||
|
include
|
||||||
|
include/cv
|
||||||
|
include/opencv
|
||||||
|
cv/include
|
||||||
|
cxcore/include
|
||||||
|
cvaux/include
|
||||||
|
otherlibs/cvcam/include
|
||||||
|
otherlibs/highgui
|
||||||
|
otherlibs/highgui/include
|
||||||
|
otherlibs/_graphics/include
|
||||||
|
)
|
||||||
|
|
||||||
|
# library linkdir suffixes appended to OpenCV_ROOT_DIR
|
||||||
|
SET(OpenCV_LIBDIR_SUFFIXES
|
||||||
|
lib
|
||||||
|
OpenCV/lib
|
||||||
|
otherlibs/_graphics/lib
|
||||||
|
)
|
||||||
|
#DBG_MSG("OpenCV_LIBDIR_SUFFIXES=${OpenCV_LIBDIR_SUFFIXES}")
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# find incdir for each lib
|
||||||
|
#
|
||||||
|
FIND_PATH(OpenCV_CV_INCLUDE_DIR
|
||||||
|
NAMES cv.h
|
||||||
|
PATHS ${OpenCV_ROOT_DIR}
|
||||||
|
PATH_SUFFIXES ${OpenCV_INCDIR_SUFFIXES} )
|
||||||
|
FIND_PATH(OpenCV_CXCORE_INCLUDE_DIR
|
||||||
|
NAMES cxcore.h
|
||||||
|
PATHS ${OpenCV_ROOT_DIR}
|
||||||
|
PATH_SUFFIXES ${OpenCV_INCDIR_SUFFIXES} )
|
||||||
|
FIND_PATH(OpenCV_CVAUX_INCLUDE_DIR
|
||||||
|
NAMES cvaux.h
|
||||||
|
PATHS ${OpenCV_ROOT_DIR}
|
||||||
|
PATH_SUFFIXES ${OpenCV_INCDIR_SUFFIXES} )
|
||||||
|
FIND_PATH(OpenCV_HIGHGUI_INCLUDE_DIR
|
||||||
|
NAMES highgui.h
|
||||||
|
PATHS ${OpenCV_ROOT_DIR}
|
||||||
|
PATH_SUFFIXES ${OpenCV_INCDIR_SUFFIXES} )
|
||||||
|
FIND_PATH(OpenCV_CVCAM_INCLUDE_DIR
|
||||||
|
NAMES cvcam.h
|
||||||
|
PATHS ${OpenCV_ROOT_DIR}
|
||||||
|
PATH_SUFFIXES ${OpenCV_INCDIR_SUFFIXES} )
|
||||||
|
|
||||||
|
#
|
||||||
|
# find sbsolute path to all libraries
|
||||||
|
# some are optionally, some may not exist on Linux
|
||||||
|
#
|
||||||
|
FIND_LIBRARY(OpenCV_CV_LIBRARY
|
||||||
|
NAMES cv opencv
|
||||||
|
PATHS ${OpenCV_ROOT_DIR}
|
||||||
|
PATH_SUFFIXES ${OpenCV_LIBDIR_SUFFIXES} )
|
||||||
|
FIND_LIBRARY(OpenCV_CVAUX_LIBRARY
|
||||||
|
NAMES cvaux
|
||||||
|
PATHS ${OpenCV_ROOT_DIR} PATH_SUFFIXES ${OpenCV_LIBDIR_SUFFIXES} )
|
||||||
|
FIND_LIBRARY(OpenCV_CVCAM_LIBRARY
|
||||||
|
NAMES cvcam
|
||||||
|
PATHS ${OpenCV_ROOT_DIR} PATH_SUFFIXES ${OpenCV_LIBDIR_SUFFIXES} )
|
||||||
|
FIND_LIBRARY(OpenCV_CVHAARTRAINING_LIBRARY
|
||||||
|
NAMES cvhaartraining
|
||||||
|
PATHS ${OpenCV_ROOT_DIR} PATH_SUFFIXES ${OpenCV_LIBDIR_SUFFIXES} )
|
||||||
|
FIND_LIBRARY(OpenCV_CXCORE_LIBRARY
|
||||||
|
NAMES cxcore
|
||||||
|
PATHS ${OpenCV_ROOT_DIR} PATH_SUFFIXES ${OpenCV_LIBDIR_SUFFIXES} )
|
||||||
|
FIND_LIBRARY(OpenCV_CXTS_LIBRARY
|
||||||
|
NAMES cxts
|
||||||
|
PATHS ${OpenCV_ROOT_DIR} PATH_SUFFIXES ${OpenCV_LIBDIR_SUFFIXES} )
|
||||||
|
FIND_LIBRARY(OpenCV_HIGHGUI_LIBRARY
|
||||||
|
NAMES highgui
|
||||||
|
PATHS ${OpenCV_ROOT_DIR} PATH_SUFFIXES ${OpenCV_LIBDIR_SUFFIXES} )
|
||||||
|
FIND_LIBRARY(OpenCV_ML_LIBRARY
|
||||||
|
NAMES ml
|
||||||
|
PATHS ${OpenCV_ROOT_DIR} PATH_SUFFIXES ${OpenCV_LIBDIR_SUFFIXES} )
|
||||||
|
FIND_LIBRARY(OpenCV_TRS_LIBRARY
|
||||||
|
NAMES trs
|
||||||
|
PATHS ${OpenCV_ROOT_DIR} PATH_SUFFIXES ${OpenCV_LIBDIR_SUFFIXES} )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Logic selecting required libs and headers
|
||||||
|
#
|
||||||
|
SET(OpenCV_FOUND ON)
|
||||||
|
DBG_MSG("OpenCV_FIND_REQUIRED_COMPONENTS=${OpenCV_FIND_REQUIRED_COMPONENTS}")
|
||||||
|
FOREACH(NAME ${OpenCV_FIND_REQUIRED_COMPONENTS} )
|
||||||
|
|
||||||
|
# only good if header and library both found
|
||||||
|
IF (OpenCV_${NAME}_INCLUDE_DIR AND OpenCV_${NAME}_LIBRARY)
|
||||||
|
LIST(APPEND OpenCV_INCLUDE_DIRS ${OpenCV_${NAME}_INCLUDE_DIR} )
|
||||||
|
LIST(APPEND OpenCV_LIBRARIES ${OpenCV_${NAME}_LIBRARY} )
|
||||||
|
#DBG_MSG("appending for NAME=${NAME} ${OpenCV_${NAME}_INCLUDE_DIR} and ${OpenCV_${NAME}_LIBRARY}" )
|
||||||
|
ELSE (OpenCV_${NAME}_INCLUDE_DIR AND OpenCV_${NAME}_LIBRARY)
|
||||||
|
DBG_MSG("OpenCV component NAME=${NAME} not found! "
|
||||||
|
"\nOpenCV_${NAME}_INCLUDE_DIR=${OpenCV_${NAME}_INCLUDE_DIR} "
|
||||||
|
"\nOpenCV_${NAME}_LIBRARY=${OpenCV_${NAME}_LIBRARY} ")
|
||||||
|
SET(OpenCV_FOUND OFF)
|
||||||
|
ENDIF (OpenCV_${NAME}_INCLUDE_DIR AND OpenCV_${NAME}_LIBRARY)
|
||||||
|
|
||||||
|
ENDFOREACH(NAME)
|
||||||
|
|
||||||
|
DBG_MSG("OpenCV_INCLUDE_DIRS=${OpenCV_INCLUDE_DIRS}")
|
||||||
|
DBG_MSG("OpenCV_LIBRARIES=${OpenCV_LIBRARIES}")
|
||||||
|
|
||||||
|
# get the link directory for rpath to be used with LINK_DIRECTORIES:
|
||||||
|
IF (OpenCV_CV_LIBRARY)
|
||||||
|
GET_FILENAME_COMPONENT(OpenCV_LINK_DIRECTORIES ${OpenCV_CV_LIBRARY} PATH)
|
||||||
|
ENDIF (OpenCV_CV_LIBRARY)
|
||||||
|
|
||||||
|
MARK_AS_ADVANCED(
|
||||||
|
OpenCV_ROOT_DIR
|
||||||
|
OpenCV_INCLUDE_DIRS
|
||||||
|
OpenCV_CV_INCLUDE_DIR
|
||||||
|
OpenCV_CXCORE_INCLUDE_DIR
|
||||||
|
OpenCV_CVAUX_INCLUDE_DIR
|
||||||
|
OpenCV_CVCAM_INCLUDE_DIR
|
||||||
|
OpenCV_HIGHGUI_INCLUDE_DIR
|
||||||
|
OpenCV_LIBRARIES
|
||||||
|
OpenCV_CV_LIBRARY
|
||||||
|
OpenCV_CXCORE_LIBRARY
|
||||||
|
OpenCV_CVAUX_LIBRARY
|
||||||
|
OpenCV_CVCAM_LIBRARY
|
||||||
|
OpenCV_CVHAARTRAINING_LIBRARY
|
||||||
|
OpenCV_CXTS_LIBRARY
|
||||||
|
OpenCV_HIGHGUI_LIBRARY
|
||||||
|
OpenCV_ML_LIBRARY
|
||||||
|
OpenCV_TRS_LIBRARY
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# be backward compatible:
|
||||||
|
SET(OPENCV_LIBRARIES ${OpenCV_LIBRARIES} )
|
||||||
|
SET(OPENCV_INCLUDE_DIR ${OpenCV_INCLUDE_DIRS} )
|
||||||
|
SET(OPENCV_FOUND ${OpenCV_FOUND})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# display help message
|
||||||
|
IF(NOT OpenCV_FOUND)
|
||||||
|
# make FIND_PACKAGE friendly
|
||||||
|
IF(NOT OpenCV_FIND_QUIETLY)
|
||||||
|
IF(OpenCV_FIND_REQUIRED)
|
||||||
|
MESSAGE(FATAL_ERROR
|
||||||
|
"OpenCV required but some headers or libs not found. Please specify it's location with OpenCV_ROOT_DIR env. variable.")
|
||||||
|
ELSE(OpenCV_FIND_REQUIRED)
|
||||||
|
MESSAGE(STATUS
|
||||||
|
"ERROR: OpenCV was not found.")
|
||||||
|
ENDIF(OpenCV_FIND_REQUIRED)
|
||||||
|
ENDIF(NOT OpenCV_FIND_QUIETLY)
|
||||||
|
ENDIF(NOT OpenCV_FOUND)
|
|
@ -0,0 +1,76 @@
|
||||||
|
# This is a Makefile wrapper for CMake, to make it easier to build cmake from
|
||||||
|
# within Eclipse. This does an out-of-source build in the 'build' directory.
|
||||||
|
# CMake is run automatically when necessary!
|
||||||
|
#
|
||||||
|
# Useful targets:
|
||||||
|
# cmake, ccmake, cmake_gui: Run this variant of cmake from the 'build' directory
|
||||||
|
# configure: Just runs cmake
|
||||||
|
# distclean: Clean out the build directory, including removing the CMake cache
|
||||||
|
# All other targets are just passed to the Makefile created by CMake.
|
||||||
|
#
|
||||||
|
# If CMake is not finding the packages it needs, set CMAKE_PREFIX_PATH in the
|
||||||
|
# environment, e.g. CMAKE_PREFIX_PATH=/opt/local:/opt/local/libexec/qt4-mac for
|
||||||
|
# MacPorts.
|
||||||
|
#
|
||||||
|
# Another feature if you need to set CMake options, but never want to run it by
|
||||||
|
# hand, is to put the CMake command line options in the environment variable
|
||||||
|
# $CMAKE_OPTIONS, and this Makefile will pass it on! You can do this in Eclipse.
|
||||||
|
#
|
||||||
|
# Nov 24, 2009, Richard Roberts
|
||||||
|
#
|
||||||
|
|
||||||
|
BUILD=build
|
||||||
|
|
||||||
|
# Default target
|
||||||
|
d_all: all ;
|
||||||
|
.PHONY: d_all
|
||||||
|
|
||||||
|
##### Special targets #####
|
||||||
|
|
||||||
|
# Run cmake
|
||||||
|
.PHONY: configure
|
||||||
|
configure: cmake ;
|
||||||
|
|
||||||
|
# Run cmake variants
|
||||||
|
.PHONY: cmake ccmake cmake_gui
|
||||||
|
cmake ccmake cmake_gui: builddir_exists
|
||||||
|
cd ${BUILD}; $@ ${CMAKE_OPTIONS} ..
|
||||||
|
|
||||||
|
# Re-run CMake if the Makefile is out of date or non-existant
|
||||||
|
${BUILD}/Makefile:
|
||||||
|
@if [ ! -d ${BUILD} ]; then \
|
||||||
|
echo "[cmake_wrapper]: mkdir ${BUILD}"; \
|
||||||
|
mkdir ${BUILD}; \
|
||||||
|
fi
|
||||||
|
cd ${BUILD}; cmake ${CMAKE_OPTIONS} ..
|
||||||
|
|
||||||
|
# Clear the cache, totally remove everything
|
||||||
|
.PHONY: distclean
|
||||||
|
distclean:
|
||||||
|
@if [ -d ${BUILD} ]; then \
|
||||||
|
if [ -d ${BUILD}/CMakeFiles -a -f ${BUILD}/CMakeCache.txt ]; then \
|
||||||
|
echo "[cmake_wrapper]: rm -r ${BUILD}"; \
|
||||||
|
rm -r ${BUILD}; \
|
||||||
|
else \
|
||||||
|
echo "[cmake_wrapper]: *** Did not find one of ${BUILD}/CMakeFiles or ${BUILD}/CMakeCache.txt," >&2; \
|
||||||
|
echo "[cmake_wrapper]: *** so not attempting to remove ${BUILD}, please remove manually." >&2; \
|
||||||
|
exit 1; \
|
||||||
|
fi \
|
||||||
|
else \
|
||||||
|
echo "[cmake_wrapper]: Did not find ${BUILD} - nothing to clean or in the wrong directory" >&2; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Make sure the build directory exists
|
||||||
|
.PHONY: builddir_exists
|
||||||
|
builddir_exists:
|
||||||
|
@if [ ! -d ${BUILD} ]; then \
|
||||||
|
echo "[cmake_wrapper]: mkdir ${BUILD}"; \
|
||||||
|
mkdir ${BUILD}; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Default rule to pass target to CMake Makefile
|
||||||
|
%:
|
||||||
|
make -f$(lastword ${MAKEFILE_LIST}) ${BUILD}/Makefile
|
||||||
|
VERBOSE=1 make -C${BUILD} $@
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,203 @@
|
||||||
|
# CMake file for cpp libraries and projects
|
||||||
|
#
|
||||||
|
# To use:
|
||||||
|
# cmake_minimum_required(VERSION 2.6)
|
||||||
|
# include("$ENV{HOME}/borg/gtsam/buildtools/gt.cmake")
|
||||||
|
# project(your-project-name CXX C)
|
||||||
|
#
|
||||||
|
# November, 2009 - Richard Roberts
|
||||||
|
|
||||||
|
cmake_policy(PUSH)
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 2.6)
|
||||||
|
|
||||||
|
# Set the default install prefix
|
||||||
|
set(CMAKE_INSTALL_PREFIX "$ENV{HOME}" CACHE PATH "Installation prefix" FORCE)
|
||||||
|
|
||||||
|
# Add borg libraries and includes
|
||||||
|
include_directories("${CMAKE_INSTALL_PREFIX}/include")
|
||||||
|
link_directories("${CMAKE_INSTALL_PREFIX}/lib")
|
||||||
|
|
||||||
|
# Path to CppUnitLite
|
||||||
|
set(GT_CPPUNITLITE_INCLUDE_DIR "${BORG_SOFTWARE_ROOT}/gtsam")
|
||||||
|
set(GT_CPPUNITLITE_LIB_DIR "${BORG_SOFTWARE_ROOT}/gtsam/CppUnitLite")
|
||||||
|
|
||||||
|
# Enable unit testing
|
||||||
|
enable_testing()
|
||||||
|
add_custom_target(check make all test)
|
||||||
|
|
||||||
|
|
||||||
|
############
|
||||||
|
### Quick "use" functions
|
||||||
|
file(TO_CMAKE_PATH "${CMAKE_CURRENT_LIST_FILE}" GT_BUILDTOOLS)
|
||||||
|
string(REPLACE "/" ";" GT_BUILDTOOLS "${GT_BUILDTOOLS}")
|
||||||
|
list(REMOVE_AT GT_BUILDTOOLS -1)
|
||||||
|
string(REPLACE ";" "/" GT_BUILDTOOLS "${GT_BUILDTOOLS}")
|
||||||
|
message(STATUS "Build tools dir ${GT_BUILDTOOLS}")
|
||||||
|
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${GT_BUILDTOOLS}")
|
||||||
|
function(GT_USE_BOOST)
|
||||||
|
find_package(Boost REQUIRED)
|
||||||
|
link_directories(${Boost_LIBRARY_DIRS})
|
||||||
|
include_directories(${Boost_INCLUDE_DIRS})
|
||||||
|
link_libraries(${Boost_LIBRARIES})
|
||||||
|
endfunction(GT_USE_BOOST)
|
||||||
|
function(GT_USE_QT4 extra_components)
|
||||||
|
find_package(Qt4 COMPONENTS QtCore QtGui ${extra_components} REQUIRED)
|
||||||
|
include(${QT_USE_FILE})
|
||||||
|
link_libraries(${QT_LIBRARIES})
|
||||||
|
endfunction(GT_USE_QT4)
|
||||||
|
function(GT_USE_OPENCV)
|
||||||
|
find_package(OpenCV REQUIRED)
|
||||||
|
link_directories(${OpenCV_LINK_DIRECTORIES})
|
||||||
|
include_directories(${OpenCV_INCLUDE_DIRS})
|
||||||
|
link_libraries(${OpenCV_LIBRARIES)
|
||||||
|
endfunction(GT_USE_OPENCV)
|
||||||
|
function(GT_USE_GTSAM)
|
||||||
|
link_libraries("gtsam")
|
||||||
|
endfunction(GT_USE_GTSAM)
|
||||||
|
function(GT_USE_EASY2D)
|
||||||
|
link_libraries("easy2d")
|
||||||
|
endfunction(GT_USE_EASY2D)
|
||||||
|
|
||||||
|
|
||||||
|
############
|
||||||
|
### Main target functions, calling one of these will replace the previous main target.
|
||||||
|
|
||||||
|
# Define "common" sources when there is no main library or executable
|
||||||
|
function(GT_MAIN_SOURCES)
|
||||||
|
set(GT_COMMON_SOURCES "")
|
||||||
|
foreach(srcpat ${ARGN})
|
||||||
|
# Get the sources matching the specified pattern
|
||||||
|
file(GLOB srcs RELATIVE "${PROJECT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/${srcpat}")
|
||||||
|
set(GT_COMMON_SOURCES ${GT_COMMON_SOURCES} ${srcs} PARENT_SCOPE)
|
||||||
|
#message(STATUS "Adding sources: " ${srcs})
|
||||||
|
endforeach(srcpat)
|
||||||
|
endfunction(GT_MAIN_SOURCES)
|
||||||
|
|
||||||
|
# Add headers to be installed
|
||||||
|
function(GT_INSTALL_HEADERS)
|
||||||
|
foreach(srcpat ${ARGN})
|
||||||
|
# Get the sources matching the specified pattern
|
||||||
|
file(GLOB srcs RELATIVE "${PROJECT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/${srcpat}")
|
||||||
|
install(FILES ${srcs} DESTINATION "include/${PROJECT_NAME}")
|
||||||
|
endforeach(srcpat)
|
||||||
|
endfunction(GT_INSTALL_HEADERS)
|
||||||
|
|
||||||
|
# Define the main shared library from the given sources
|
||||||
|
function(GT_MAIN_SHLIB)
|
||||||
|
gt_main_sources(${ARGN})
|
||||||
|
set(GT_COMMON_SOURCES "${GT_COMMON_SOURCES}" PARENT_SCOPE)
|
||||||
|
message(STATUS "[gt.cmake] Adding main shlib \"${PROJECT_NAME}\" with sources ${GT_COMMON_SOURCES}")
|
||||||
|
add_library(${PROJECT_NAME} SHARED ${GT_COMMON_SOURCES})
|
||||||
|
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION "lib" ARCHIVE DESTINATION "lib")
|
||||||
|
endfunction(GT_MAIN_SHLIB)
|
||||||
|
|
||||||
|
# Define the main static library from the given sources
|
||||||
|
function(GT_MAIN_STLIB)
|
||||||
|
gt_main_sources(${ARGN})
|
||||||
|
set(GT_COMMON_SOURCES "${GT_COMMON_SOURCES}" PARENT_SCOPE)
|
||||||
|
message(STATUS "[gt.cmake] Adding main stlib \"${PROJECT_NAME}\" with sources ${GT_COMMON_SOURCES}")
|
||||||
|
add_library(${PROJECT_NAME} STATIC ${GT_COMMON_SOURCES})
|
||||||
|
install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION "lib")
|
||||||
|
endfunction(GT_MAIN_STLIB)
|
||||||
|
|
||||||
|
# Define the main executable from the given sources
|
||||||
|
function(GT_MAIN_EXE)
|
||||||
|
gt_main_sources(${ARGN})
|
||||||
|
set(GT_COMMON_SOURCES "${GT_COMMON_SOURCES}" PARENT_SCOPE)
|
||||||
|
message(STATUS "[gt.cmake] Adding main exe \"${PROJECT_NAME}\" with sources ${GT_COMMON_SOURCES}")
|
||||||
|
add_executable(${PROJECT_NAME} ${GT_COMMON_SOURCES})
|
||||||
|
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION "bin")
|
||||||
|
endfunction(GT_MAIN_EXE)
|
||||||
|
|
||||||
|
|
||||||
|
############
|
||||||
|
### "Auto" targets - main() files and unit tests
|
||||||
|
|
||||||
|
# Add "auto" executables
|
||||||
|
function(GT_AUTO_EXES)
|
||||||
|
foreach(srcpat ${ARGN})
|
||||||
|
# Get the sources matching the specified pattern
|
||||||
|
file(GLOB srcs RELATIVE "${PROJECT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/${srcpat}")
|
||||||
|
foreach(src ${srcs})
|
||||||
|
gt_get_stem(exe ${src})
|
||||||
|
message(STATUS "[gt.cmake] Adding auto exe \"${exe}\" from ${src}")
|
||||||
|
add_executable(${exe} ${src} ${GT_COMMON_SOURCES})
|
||||||
|
endforeach(src ${srcs})
|
||||||
|
endforeach(srcpat ${ARGN})
|
||||||
|
endfunction(GT_AUTO_EXES)
|
||||||
|
|
||||||
|
# Add "auto" executables and install them
|
||||||
|
function(GT_AUTO_INSTALLED_EXES)
|
||||||
|
foreach(srcpat ${ARGN})
|
||||||
|
# Get the sources matching the specified pattern
|
||||||
|
file(GLOB srcs RELATIVE "${PROJECT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/${srcpat}")
|
||||||
|
foreach(src ${srcs})
|
||||||
|
gt_get_stem(exe ${src})
|
||||||
|
message(STATUS "[gt.cmake] Adding auto installed exe \"${exe}\" from ${src}")
|
||||||
|
add_executable(${exe} ${src} ${GT_COMMON_SOURCES})
|
||||||
|
install(TARGETS ${exe} RUNTIME DESTINATION "bin")
|
||||||
|
endforeach(src ${srcs})
|
||||||
|
endforeach(srcpat ${ARGN})
|
||||||
|
endfunction(GT_AUTO_INSTALLED_EXES)
|
||||||
|
|
||||||
|
|
||||||
|
# Add "auto" unit tests
|
||||||
|
function(GT_AUTO_TESTS)
|
||||||
|
# Enable testing
|
||||||
|
if(NOT gt_testing_on)
|
||||||
|
message(STATUS "[gt.cmake] Enabling unit testing")
|
||||||
|
include_directories("${GT_CPPUNITLITE_INCLUDE_DIR}")
|
||||||
|
link_directories("${GT_CPPUNITLITE_LIB_DIR}")
|
||||||
|
set(gt_testing_on 1 PARENT_SCOPE)
|
||||||
|
endif(NOT gt_testing_on)
|
||||||
|
|
||||||
|
foreach(srcpat ${ARGN})
|
||||||
|
# Get the sources matching the specified pattern
|
||||||
|
file(GLOB srcs RELATIVE "${PROJECT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/${srcpat}")
|
||||||
|
foreach(src ${srcs})
|
||||||
|
gt_get_stem(exe ${src})
|
||||||
|
message(STATUS "[gt.cmake] Adding test \"${exe}\" from ${src}")
|
||||||
|
add_executable(${exe} ${src} ${GT_COMMON_SOURCES})
|
||||||
|
target_link_libraries(${exe} "CppUnitLite")
|
||||||
|
add_test(${exe} ${exe})
|
||||||
|
endforeach(src ${srcs})
|
||||||
|
endforeach(srcpat ${ARGN})
|
||||||
|
endfunction(GT_AUTO_TESTS)
|
||||||
|
|
||||||
|
|
||||||
|
function(GT_GET_STEM outstem path)
|
||||||
|
gt_get_pathstem(outpath stem "${path}")
|
||||||
|
set(${outstem} "${stem}" PARENT_SCOPE)
|
||||||
|
#message(STATUS "Got ${stem} for stem from child, setting into variable ${outstem}")
|
||||||
|
endfunction(GT_GET_STEM)
|
||||||
|
|
||||||
|
# Get the target name from a source file path
|
||||||
|
function(GT_GET_PATHSTEM outpath outstem path)
|
||||||
|
#message(STATUS "Looking for stem of ${path}")
|
||||||
|
# Get the file name from the path
|
||||||
|
file(TO_CMAKE_PATH "${path}" stems)
|
||||||
|
string(REPLACE "/" ";" stems "${path}")
|
||||||
|
list(GET stems -1 stem)
|
||||||
|
#message(STATUS "Got ${stem} for filename")
|
||||||
|
list(REMOVE_AT stems -1)
|
||||||
|
string(REPLACE ";" "/" stems "${stems}")
|
||||||
|
file(TO_NATIVE_PATH "${stems}" stems)
|
||||||
|
set(${outpath} "${stems}" PARENT_SCOPE)
|
||||||
|
#message(STATUS "Got ${stems} for path")
|
||||||
|
# Remove extension
|
||||||
|
string(REPLACE "." ";" stem "${stem}")
|
||||||
|
list(LENGTH stem llen)
|
||||||
|
if(${llen} GREATER 1)
|
||||||
|
list(REMOVE_AT stem -1)
|
||||||
|
else(${llen} GREATER 1)
|
||||||
|
list(APPEND stem "out")
|
||||||
|
endif(${llen} GREATER 1)
|
||||||
|
string(REPLACE ";" "." stem "${stem}")
|
||||||
|
set(${outstem} "${stem}" PARENT_SCOPE)
|
||||||
|
#message(STATUS "Got ${stem} for stem (setting into variable ${outstem})")
|
||||||
|
endfunction(GT_GET_PATHSTEM)
|
||||||
|
|
||||||
|
|
||||||
|
cmake_policy(POP)
|
||||||
|
|
Loading…
Reference in New Issue