2011-06-05 14:45:39 +00:00
SET ( SRC_FILES
main.cpp
)
# For Apple set the icns file containing icons
IF ( APPLE AND BUILD_AS_BUNDLE )
# set how it shows up in the Info.plist file
SET ( MACOSX_BUNDLE_ICON_FILE ${ PROJECT_NAME } .icns )
# set where in the bundle to put the icns file
SET_SOURCE_FILES_PROPERTIES ( ${ CMAKE_CURRENT_SOURCE_DIR } / ${ PROJECT_NAME } .icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources )
# include the icns file in the target
SET ( SRC_FILES ${ SRC_FILES } ${ CMAKE_CURRENT_SOURCE_DIR } / ${ PROJECT_NAME } .icns )
ENDIF ( APPLE AND BUILD_AS_BUNDLE )
# Add exe icon resource
IF ( WIN32 )
IF ( MINGW )
# resource compilation for MinGW
ADD_CUSTOM_COMMAND ( OUTPUT ${ CMAKE_CURRENT_BINARY_DIR } /AppIco.o
COMMAND windres.exe -I ${ CMAKE_CURRENT_SOURCE_DIR } -i ${ CMAKE_CURRENT_SOURCE_DIR } / ${ PROJECT_NAME } .rc
-o ${ CMAKE_CURRENT_BINARY_DIR } /AppIco.o )
SET ( SRC_FILES ${ SRC_FILES } ${ CMAKE_CURRENT_BINARY_DIR } /AppIco.o )
ELSE ( MINGW )
SET ( SRC_FILES ${ SRC_FILES } ${ PROJECT_NAME } .rc )
ENDIF ( MINGW )
ENDIF ( WIN32 )
# Add binary
IF ( APPLE AND BUILD_AS_BUNDLE )
2023-02-12 16:18:01 -08:00
ADD_EXECUTABLE ( rtabmap_app MACOSX_BUNDLE ${ SRC_FILES } )
2013-12-11 00:12:44 +00:00
ELSEIF ( MINGW )
2023-02-12 16:18:01 -08:00
ADD_EXECUTABLE ( rtabmap_app WIN32 ${ SRC_FILES } )
2011-06-05 14:45:39 +00:00
ELSE ()
2023-02-12 16:18:01 -08:00
ADD_EXECUTABLE ( rtabmap_app ${ SRC_FILES } )
2011-06-05 14:45:39 +00:00
ENDIF ()
2023-02-12 16:18:01 -08:00
TARGET_LINK_LIBRARIES ( rtabmap_app rtabmap_gui )
2011-06-05 14:45:39 +00:00
IF ( APPLE AND BUILD_AS_BUNDLE )
2023-02-12 16:18:01 -08:00
SET_TARGET_PROPERTIES ( rtabmap_app PROPERTIES
2011-06-05 14:45:39 +00:00
OUTPUT_NAME ${ CMAKE_BUNDLE_NAME } )
ELSEIF ( WIN32 )
2023-02-12 16:18:01 -08:00
SET_TARGET_PROPERTIES ( rtabmap_app PROPERTIES
2011-06-05 14:45:39 +00:00
OUTPUT_NAME ${ PROJECT_NAME } )
ELSE ()
2023-02-12 16:18:01 -08:00
SET_TARGET_PROPERTIES ( rtabmap_app PROPERTIES
2011-06-05 14:45:39 +00:00
OUTPUT_NAME ${ PROJECT_PREFIX } )
ENDIF ()
#---------------------------
# Installation stuff
#---------------------------
2023-02-12 16:18:01 -08:00
INSTALL ( TARGETS rtabmap_app
2014-12-17 17:28:21 +01:00
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT runtime
2011-06-05 14:45:39 +00:00
BUNDLE DESTINATION "${CMAKE_BUNDLE_LOCATION}" COMPONENT runtime )
IF ( APPLE AND BUILD_AS_BUNDLE )
INSTALL ( CODE "execute_process(COMMAND ln -s \" ../MacOS/ ${ CMAKE_BUNDLE_NAME } \" ${ PROJECT_NAME }
WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin)")
ENDIF(APPLE AND BUILD_AS_BUNDLE )
2018-09-04 15:44:37 -04:00
IF ( BUILD_AS_BUNDLE AND ( APPLE OR WIN32 ))
2014-06-16 22:00:10 +00:00
SET ( APPS "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin/${PROJECT_NAME}${CMAKE_EXECUTABLE_SUFFIX}" )
2011-06-05 14:45:39 +00:00
SET ( plugin_dest_dir bin )
SET ( qtconf_dest_dir bin )
2014-06-16 22:00:10 +00:00
SET ( openni2_dest_dir bin )
2011-06-05 14:45:39 +00:00
IF ( APPLE )
SET ( plugin_dest_dir MacOS )
SET ( qtconf_dest_dir Resources )
2014-06-17 01:45:52 +00:00
SET ( openni2_dest_dir MacOS )
2011-06-05 14:45:39 +00:00
SET ( APPS "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/MacOS/${CMAKE_BUNDLE_NAME}" )
ENDIF ( APPLE )
2014-06-16 22:00:10 +00:00
IF ( OpenNI2_FOUND )
# Install needed OpenNI sensor dll by copying directories from the OpenNI2 installation
IF ( WIN32 )
find_path ( OpenNI2_BIN_DIR NAMES OpenNI2.dll )
IF ( NOT OpenNI2_BIN_DIR )
MESSAGE ( FATAL_ERROR "OpenNI2.dll not found! Verify your PATH." )
ENDIF ( NOT OpenNI2_BIN_DIR )
2014-06-17 01:45:52 +00:00
ELSE ()
# Mac OS X
get_filename_component ( OpenNI2_BIN_DIR "${OpenNI2_LIBRARY}" PATH )
ENDIF ()
2014-06-16 22:00:10 +00:00
INSTALL ( DIRECTORY "${OpenNI2_BIN_DIR}/OpenNI2"
DESTINATION ${ openni2_dest_dir }
COMPONENT runtime
REGEX ".*pdb" EXCLUDE )
2014-06-17 01:45:52 +00:00
INSTALL ( FILES "${OpenNI2_BIN_DIR}/OpenNI.ini"
DESTINATION ${ openni2_dest_dir }
COMPONENT runtime )
2014-06-16 22:00:10 +00:00
ENDIF ( OpenNI2_FOUND )
2020-07-01 14:46:37 -04:00
IF ( k4a_FOUND )
# Install needed depthengine_2_0.dll
IF ( WIN32 )
file ( TO_CMAKE_PATH "$ENV{K4A_ROOT_DIR}" ENV_K4A_ROOT_DIR )
INSTALL ( FILES "${ENV_K4A_ROOT_DIR}/tools/depthengine_2_0.dll"
DESTINATION ${ plugin_dest_dir }
COMPONENT runtime )
ENDIF ( WIN32 )
ENDIF ( k4a_FOUND )
2021-12-29 15:13:13 -05:00
IF ( Torch_FOUND )
# Install needed cudnn_ops_infer64_8.dll and cudnn_cnn_infer64_8.dll
# TODO: should be a more general way to include them if version is different
IF ( WIN32 AND CUDA_FOUND )
find_file ( CUDNN_OPS_DLL NAMES cudnn_ops_infer64_8.dll )
find_file ( CUDNN_CNN_DLL NAMES cudnn_cnn_infer64_8.dll )
IF ( CUDNN_OPS_DLL AND CUDNN_CNN_DLL )
MESSAGE ( STATUS "Found ${CUDNN_OPS_DLL}" )
MESSAGE ( STATUS "Found ${CUDNN_CNN_DLL}" )
INSTALL ( FILES ${ CUDNN_OPS_DLL } ${ CUDNN_CNN_DLL }
DESTINATION ${ plugin_dest_dir }
COMPONENT runtime )
ELSE ()
MESSAGE ( AUTHOR_WARNING "Using Torch with CUDA, but cudnn_ops_infer64_8.dll and cudnn_cnn_infer64_8.dll are not found on the PATH, so it won't be added to package." )
ENDIF ()
ENDIF ( WIN32 AND CUDA_FOUND )
ENDIF ( Torch_FOUND )
2014-06-16 22:00:10 +00:00
2011-06-05 14:45:39 +00:00
# Install needed Qt plugins by copying directories from the qt installation
# One can cull what gets copied by using 'REGEX "..." EXCLUDE'
# Exclude debug libraries
2016-06-02 17:52:22 -04:00
IF ( QT_PLUGINS_DIR )
2016-06-04 15:17:13 -04:00
INSTALL ( DIRECTORY "${QT_PLUGINS_DIR}/imageformats"
2011-06-05 14:45:39 +00:00
DESTINATION ${ plugin_dest_dir } /plugins
COMPONENT runtime
REGEX ".*d4.dll" EXCLUDE
REGEX ".*d4.a" EXCLUDE )
2016-06-04 15:17:13 -04:00
ELSE ()
#Qt5
foreach ( plugin ${ Qt5Gui_PLUGINS } )
get_target_property ( plugin_loc ${ plugin } LOCATION )
get_filename_component ( plugin_dir ${ plugin_loc } DIRECTORY )
string ( REPLACE "plugins" ";" loc_list ${ plugin_dir } )
list ( GET loc_list 1 plugin_type )
2018-11-01 10:38:09 -04:00
IF ( NOT plugin_root )
get_filename_component ( plugin_root ${ plugin_dir } DIRECTORY )
2021-12-29 15:13:13 -05:00
ENDIF ( NOT plugin_root )
2020-06-18 12:09:26 -04:00
#MESSAGE(STATUS "Qt5 plugin \"${plugin_loc}\" installed in \"${plugin_dest_dir}/plugins${plugin_type}\"")
2016-06-04 15:17:13 -04:00
INSTALL ( FILES ${ plugin_loc }
DESTINATION ${ plugin_dest_dir } /plugins ${ plugin_type }
COMPONENT runtime )
2021-12-29 15:13:13 -05:00
endforeach ()
2020-06-18 12:09:26 -04:00
IF ( NOT Qt5Widgets_VERSION VERSION_LESS 5.10.0 )
IF ( WIN32 )
2021-12-29 15:13:13 -05:00
SET ( plugin_loc "${plugin_root}/styles/qwindowsvistastyle.dll" )
ELSEIF ( APPLE )
SET ( plugin_loc "${plugin_root}/styles/libqmacstyle.dylib" )
2020-06-18 12:09:26 -04:00
ENDIF ()
IF ( EXISTS ${ plugin_loc } )
get_filename_component ( plugin_dir ${ plugin_loc } DIRECTORY )
string ( REPLACE "plugins" ";" loc_list ${ plugin_dir } )
list ( GET loc_list 1 plugin_type )
INSTALL ( FILES ${ plugin_loc }
DESTINATION ${ plugin_dest_dir } /plugins ${ plugin_type }
COMPONENT runtime )
#MESSAGE(STATUS "Qt5 plugin \"${plugin_loc}\" installed in \"${plugin_dest_dir}/plugins${plugin_type}\"")
ENDIF ( EXISTS ${ plugin_loc } )
ENDIF ( NOT Qt5Widgets_VERSION VERSION_LESS 5.10.0 )
2016-06-04 15:17:13 -04:00
ENDIF ()
2011-06-05 14:45:39 +00:00
# install a qt.conf file
# this inserts some cmake code into the install script to write the file
SET ( QT_CONF_FILE [Paths]\nPlugins=plugins )
IF ( APPLE )
SET ( QT_CONF_FILE [Paths]\nPlugins=MacOS/plugins )
ENDIF ( APPLE )
INSTALL ( CODE "
file(WRITE \" \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"${QT_CONF_FILE}\")
" COMPONENT runtime)
# directories to look for dependencies
SET(DIRS ${QT_LIBRARY_DIRS} ${PROJECT_SOURCE_DIR}/bin)
2012-12-12 03:12:37 +00:00
IF(APPLE)
SET(DIRS ${DIRS} /usr/local /usr/local/lib)
ENDIF(APPLE)
2011-06-05 14:45:39 +00:00
# Now the work of copying dependencies into the bundle/package
# The quotes are escaped and variables to use at install time have their $ escaped
# An alternative is the do a configure_file() on a script and use install(SCRIPT ...).
# Note that the image plugins depend on QtSvg and QtXml, and it got those copied
# over.
# To find dependencies, cmake use " otool " on Apple and " dumpbin " on Windows (make sure you have one of them).
install(CODE "
2016-05-04 16:45:19 -04:00
file(GLOB_RECURSE QTPLUGINS \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/plugins/*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
2015-04-25 17:50:24 -04:00
set(BU_CHMOD_BUNDLE_ITEMS ON )
2011-06-05 14:45:39 +00:00
include ( \"BundleUtilities\")
fixup_bundle(\ "${APPS}\" \"\${QTPLUGINS}\" \"${DIRS}\")
" COMPONENT runtime )
2018-09-04 19:01:43 -04:00
ENDIF ( BUILD_AS_BUNDLE AND ( APPLE OR WIN32 ))
2011-06-05 14:45:39 +00:00