2011-10-25 15:48:19 +00:00
|
|
|
|
2015-11-30 00:27:57 -05:00
|
|
|
SET(headers_ui
|
|
|
|
|
TcpServerPool.h
|
|
|
|
|
)
|
|
|
|
|
|
2016-05-06 16:54:18 -04:00
|
|
|
IF(QT4_FOUND)
|
2015-11-30 00:27:57 -05:00
|
|
|
QT4_WRAP_CPP(moc_srcs ${headers_ui})
|
|
|
|
|
ELSE()
|
|
|
|
|
QT5_WRAP_CPP(moc_srcs ${headers_ui})
|
|
|
|
|
ENDIF()
|
|
|
|
|
|
2011-10-25 15:48:19 +00:00
|
|
|
SET(INCLUDE_DIRS
|
2014-07-31 20:11:46 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/../include
|
2011-10-25 15:48:19 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
|
${OpenCV_INCLUDE_DIRS}
|
|
|
|
|
)
|
|
|
|
|
|
2016-05-06 16:54:18 -04:00
|
|
|
IF(QT4_FOUND)
|
2015-11-29 18:39:20 -05:00
|
|
|
INCLUDE(${QT_USE_FILE})
|
2016-05-06 16:54:18 -04:00
|
|
|
ENDIF(QT4_FOUND)
|
2011-10-25 15:48:19 +00:00
|
|
|
|
|
|
|
|
SET(LIBRARIES
|
|
|
|
|
${QT_LIBRARIES}
|
|
|
|
|
${OpenCV_LIBS}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
#include files
|
|
|
|
|
INCLUDE_DIRECTORIES(${INCLUDE_DIRS})
|
|
|
|
|
|
2015-11-30 00:27:57 -05:00
|
|
|
SET(SRC_FILES main.cpp ${moc_srcs} )
|
2014-08-28 21:36:23 +00:00
|
|
|
|
2011-11-24 20:45:50 +00:00
|
|
|
# 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 )
|
2014-05-06 15:43:51 +00:00
|
|
|
SET(SRC_FILES ${SRC_FILES} ${PROJECT_NAME}.rc) # Error on visual studio 2008
|
2011-11-24 20:45:50 +00:00
|
|
|
ENDIF( MINGW )
|
|
|
|
|
ENDIF(WIN32)
|
|
|
|
|
|
2011-10-25 15:48:19 +00:00
|
|
|
# create an executable file
|
2011-11-09 20:48:04 +00:00
|
|
|
IF(APPLE AND BUILD_AS_BUNDLE)
|
2014-08-28 21:36:23 +00:00
|
|
|
ADD_EXECUTABLE(find_object_app MACOSX_BUNDLE ${SRC_FILES})
|
2012-11-06 22:51:33 +00:00
|
|
|
ELSEIF(MINGW)
|
2014-08-28 21:36:23 +00:00
|
|
|
ADD_EXECUTABLE(find_object_app WIN32 ${SRC_FILES})
|
2012-11-06 22:51:33 +00:00
|
|
|
ELSE()
|
2014-08-28 21:36:23 +00:00
|
|
|
ADD_EXECUTABLE(find_object_app ${SRC_FILES})
|
2011-11-09 20:48:04 +00:00
|
|
|
ENDIF()
|
2011-10-25 15:48:19 +00:00
|
|
|
# Linking with Qt libraries
|
2014-07-31 20:11:46 +00:00
|
|
|
TARGET_LINK_LIBRARIES(find_object_app find_object ${LIBRARIES})
|
2016-05-06 16:54:18 -04:00
|
|
|
IF(Qt5_FOUND)
|
2015-11-29 18:39:20 -05:00
|
|
|
QT5_USE_MODULES(find_object_app Widgets Core Gui Network PrintSupport)
|
2016-05-06 16:54:18 -04:00
|
|
|
ENDIF(Qt5_FOUND)
|
2011-10-25 15:48:19 +00:00
|
|
|
|
2011-11-09 20:48:04 +00:00
|
|
|
IF(APPLE AND BUILD_AS_BUNDLE)
|
2014-07-31 20:11:46 +00:00
|
|
|
SET_TARGET_PROPERTIES(find_object_app PROPERTIES
|
2011-11-09 20:48:04 +00:00
|
|
|
OUTPUT_NAME ${CMAKE_BUNDLE_NAME})
|
|
|
|
|
ELSEIF(WIN32)
|
2014-07-31 20:11:46 +00:00
|
|
|
SET_TARGET_PROPERTIES(find_object_app PROPERTIES
|
2011-11-09 19:01:46 +00:00
|
|
|
OUTPUT_NAME ${PROJECT_NAME})
|
2011-11-09 20:48:04 +00:00
|
|
|
ELSE()
|
2014-07-31 20:11:46 +00:00
|
|
|
SET_TARGET_PROPERTIES(find_object_app PROPERTIES
|
2011-11-09 20:48:04 +00:00
|
|
|
OUTPUT_NAME ${PROJECT_PREFIX})
|
|
|
|
|
ENDIF()
|
2011-11-09 19:01:46 +00:00
|
|
|
|
|
|
|
|
#---------------------------
|
|
|
|
|
# Installation stuff
|
|
|
|
|
#---------------------------
|
2014-07-31 20:11:46 +00:00
|
|
|
INSTALL(TARGETS find_object_app
|
2015-11-29 18:39:20 -05:00
|
|
|
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT runtime
|
2011-11-09 19:01:46 +00:00
|
|
|
BUNDLE DESTINATION "${CMAKE_BUNDLE_LOCATION}" COMPONENT runtime)
|
2011-11-09 20:48:04 +00:00
|
|
|
|
|
|
|
|
#---------------------------
|
|
|
|
|
# Dependencies packaging
|
|
|
|
|
#---------------------------
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
IF((APPLE AND BUILD_AS_BUNDLE) OR WIN32)
|
2014-08-29 01:18:55 +00:00
|
|
|
SET(APPS "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin/${PROJECT_NAME}${CMAKE_EXECUTABLE_SUFFIX}")
|
2011-11-09 19:01:46 +00:00
|
|
|
SET(plugin_dest_dir bin)
|
|
|
|
|
SET(qtconf_dest_dir bin)
|
2011-11-09 20:48:04 +00:00
|
|
|
IF(APPLE)
|
|
|
|
|
SET(plugin_dest_dir MacOS)
|
|
|
|
|
SET(qtconf_dest_dir Resources)
|
|
|
|
|
SET(APPS "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/MacOS/${CMAKE_BUNDLE_NAME}")
|
|
|
|
|
ENDIF(APPLE)
|
|
|
|
|
|
2011-11-09 19:01:46 +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
|
2018-05-28 14:56:10 -04:00
|
|
|
IF(QT_PLUGINS_DIR)
|
|
|
|
|
INSTALL(DIRECTORY "${QT_PLUGINS_DIR}/imageformats"
|
2011-11-09 19:01:46 +00:00
|
|
|
DESTINATION ${plugin_dest_dir}/plugins
|
|
|
|
|
COMPONENT runtime
|
|
|
|
|
REGEX ".*d4.dll" EXCLUDE
|
|
|
|
|
REGEX ".*d4.a" EXCLUDE)
|
2018-05-28 14:56:10 -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)
|
|
|
|
|
#MESSAGE(STATUS "Qt5 plugin \"${plugin_loc}\" installed in \"${plugin_dest_dir}/plugins${plugin_type}\"")
|
|
|
|
|
INSTALL(FILES ${plugin_loc}
|
|
|
|
|
DESTINATION ${plugin_dest_dir}/plugins${plugin_type}
|
|
|
|
|
COMPONENT runtime)
|
|
|
|
|
endforeach()
|
|
|
|
|
ENDIF()
|
2011-11-09 19:01:46 +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)
|
2011-11-09 20:48:04 +00:00
|
|
|
IF(APPLE)
|
|
|
|
|
SET(QT_CONF_FILE [Paths]\nPlugins=MacOS/plugins)
|
|
|
|
|
ENDIF(APPLE)
|
2011-11-09 19:01:46 +00:00
|
|
|
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-05-10 03:23:20 +00:00
|
|
|
IF(APPLE)
|
2014-08-28 22:31:21 +00:00
|
|
|
SET(DIRS ${DIRS} /usr/local /usr/local/lib)
|
2012-05-10 03:23:20 +00:00
|
|
|
ENDIF(APPLE)
|
2011-11-09 19:01:46 +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 "
|
|
|
|
|
file(GLOB_RECURSE QTPLUGINS \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/plugins/*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
|
|
|
|
|
include(\"BundleUtilities\")
|
|
|
|
|
fixup_bundle(\"${APPS}\" \"\${QTPLUGINS}\" \"${DIRS}\")
|
|
|
|
|
" COMPONENT runtime)
|
2011-11-09 20:48:04 +00:00
|
|
|
ENDIF((APPLE AND BUILD_AS_BUNDLE) OR WIN32)
|
2011-11-09 19:01:46 +00:00
|
|
|
|
2018-07-13 13:48:57 +07:00
|
|
|
if(UNIX AND NOT APPLE)
|
|
|
|
|
set (CMAKE_CXX_FLAGS "-ltcmalloc")
|
|
|
|
|
ENDIF()
|