PageRenderTime 71ms CodeModel.GetById 35ms RepoModel.GetById 0ms app.codeStats 0ms

/pluginTemplates/grabber/CMakeLists.txt

https://bitbucket.org/itom/itom
CMake | 292 lines | 66 code | 39 blank | 187 comment | 5 complexity | 44cf40dd24c2836c2ab6d9d4afad7bf6 MD5 | raw file
  1. ###################################################################
  2. ###################################################################
  3. # CMake Template for a plugin of itom
  4. #
  5. # You can use this template, use it in your plugins, modify it,
  6. # copy it and distribute it without any license restrictions.
  7. ###################################################################
  8. ###################################################################
  9. #here you give your project a unique name (replace MyGrabberPlugin by the desired project name of your plugin)
  10. set(target_name MyGrabberPlugin)
  11. # this should be the first line of your project.
  12. cmake_minimum_required(VERSION 3.1...3.15)
  13. set(ITOM_SDK_DIR NOTFOUND CACHE PATH "path of SDK subfolder of itom root (build) directory")
  14. #this is to automatically detect the SDK subfolder of the itom build directory.
  15. find_path(ITOM_SDK_DIR "cmake/itom_sdk.cmake"
  16. HINTS "C:/itom/build/itom/SDK"
  17. "${CMAKE_CURRENT_BINARY_DIR}/../../itom/SDK"
  18. DOC "path of SDK subfolder of itom root (build) directory")
  19. if(NOT ITOM_SDK_DIR)
  20. message(SEND_ERROR "ITOM_SDK_DIR is invalid. Provide itom SDK directory path first")
  21. endif()
  22. # ...which contains useful scripts for completing this file
  23. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR} ${ITOM_SDK_DIR}/cmake)
  24. set(CMAKE_INCLUDE_CURRENT_DIR ON)
  25. # ... for example this one, found in the CMAKE_MODULE_PATH
  26. include(ItomBuildMacros)
  27. # The CMake policies are assumed to behave like the tested version given as argument.
  28. itom_init_cmake_policy(3.12)
  29. # and this does some magic for you, as setting some common vars and
  30. # passing some switches to your project you can use in sourcecode.
  31. # If your sources are within a Git repository, it will also parse
  32. # the current commit hash and store it to gitVersion.h.
  33. #
  34. # This macro will also check if the package VisualLeakDetector can
  35. # be found (Visual Studio only) by calling find_package(VisualLeakDetector).
  36. # If so, you can enable this via the CMake option VISUALLEAKDETECTOR_ENABLED.
  37. # Add ${VISUALLEAKDETECTOR_LIBRARIES} to target_link_libraries below.
  38. itom_init_plugin_library(${target_name})
  39. #################################################################
  40. # Input elements for CMake GUI (Checkboxes, Pathes, Strings...)
  41. #################################################################
  42. # BUILD_TARGET64 is set according to bitage of selected compiler
  43. # You may select loaded libraries(32 vs 64 bit) according to the Value of this
  44. # This value is usually forced to the bitage of the itom SDK if
  45. # find_package(ITOM_SDK...) is used (see below).
  46. option(BUILD_TARGET64 "Build for 64 bit target if set to ON or 32 bit if set to OFF." ON)
  47. #################################################################
  48. # Automatic package detection
  49. # add here FIND_PACKAGE commands for searching for 3rd party
  50. # libraries
  51. #
  52. # for detecting Qt, use FIND_PACKAGE_QT instead of the
  53. # native command, since FIND_PACKAGE_QT detects the Qt4 or 5
  54. # version.
  55. #################################################################
  56. # the itom SDK needs to be detected, use the COMPONENTS keyword
  57. # to define which library components are needed. Possible values
  58. # are:
  59. # - dataobject for the ito::DataObject (usually required)
  60. # - itomCommonLib (RetVal, Param,...) (required)
  61. # - itomCommonQtLib (AddInInterface,...) (required)
  62. # - itomWidgets (further widgets) (may be used in dock widget...)
  63. # - pointcloud (pointCloud, point, polygonMesh...) (optional)
  64. # if no components are indicated, all components above are used
  65. find_package(ITOM_SDK COMPONENTS dataobject itomCommonLib itomCommonQtLib itomWidgets REQUIRED)
  66. #find_package(OpenCV COMPONENTS core REQUIRED) #if you require openCV indicate all components that are required (e.g. core, imgproc...),
  67. # if the dataobject is included in the ITOM_SDK components, the OpenCV core component is detected there and the necessary include
  68. # directories and libraries to link agains are contained in ITOM_SDK_LIBRARIES and ITOM_SDK_INCLUDE_DIRS
  69. # 'itom_find_package_qt' is a wrapper for find_package(Qt5...) and internally calls
  70. # this and sets some things more. The component names are wrapped to Qt5_{name}.
  71. #
  72. # usage of itom_find_package_qt(automoc component1, component2, ...)
  73. # automoc is ON or OFF and only relevant for Qt5, usually set it to ON
  74. # possible components are: OpenGL,Core,Designer,Xml,Svg,Sql,Network,UiTools,Widgets,PrintSupport,LinguistTools...
  75. # The automoc flag is deprecated. It is usually smarter to use both automoc,
  76. # autorcc (for parsing qrc resource files ) and autouic (for parsing ui files) in terms
  77. # of settings the properties of this target (see below):
  78. # set_target_properties(${target_name} PROPERTIES AUTOMOC ON AUTORCC ON AUTOUIC ON)
  79. itom_find_package_qt(ON Core Widgets LinguistTools)
  80. #################################################################
  81. # General settings and preprocessor settings
  82. #################################################################
  83. #add here some preprocessors, if necessary, e.g.
  84. #add_definitions(-DMYOPTION)
  85. #################################################################
  86. # List of include directories
  87. #
  88. # Hint: necessary Qt include directories are automatically added
  89. # via the FIND_PACKAGE macro above
  90. #################################################################
  91. include_directories(
  92. ${CMAKE_CURRENT_BINARY_DIR} #build directory of this plugin (recommended)
  93. ${CMAKE_CURRENT_SOURCE_DIR} #source directory of this plugin (recommended)
  94. ${ITOM_SDK_INCLUDE_DIRS} #include directory of the itom SDK (recommended) as well as necessary 3rd party directories (e.g. from OpenCV)
  95. #add further include directories here
  96. )
  97. #################################################################
  98. # List of linker directories
  99. #
  100. # Hint: libraries detected using FIND_PACKAGE usually provide
  101. # all necessary libraries in a specific variable (e.g.
  102. # ${OpenCV_LIBS} or ${ITOM_SDK_LIBRARIES}). These variables
  103. # already contain absolute pathes, therefore no link directory
  104. # needs to be set for them. Simply add these variables to
  105. # the link target command below.
  106. #################################################################
  107. link_directories(
  108. #add all linker directories
  109. )
  110. #################################################################
  111. # List of header files, source files, ui files and rcc files
  112. #
  113. # Add all header files to the PLUGIN_HEADERS list.
  114. # Add all source (cpp,...) files to the PLUGIN_SOURCES list.
  115. # Add all ui-files (Qt-Designer layouts) to the PLUGIN_UI list.
  116. #
  117. # Use absolute pathes, e.g. using one of the following variables:
  118. #
  119. # ${ITOM_SDK_INCLUDE_DIR} is the include directory of itom SDK
  120. # ${CMAKE_CURRENT_SOURCE_DIR} is the source directory of this plugin
  121. # ${CMAKE_CURRENT_BINARY_DIR} is the build directory of this plugin
  122. #
  123. #################################################################
  124. set(PLUGIN_HEADERS
  125. ${CMAKE_CURRENT_SOURCE_DIR}/myGrabber.h
  126. ${CMAKE_CURRENT_SOURCE_DIR}/dialogMyGrabber.h
  127. ${CMAKE_CURRENT_SOURCE_DIR}/dockWidgetMyGrabber.h
  128. ${CMAKE_CURRENT_SOURCE_DIR}/pluginVersion.h
  129. ${CMAKE_CURRENT_BINARY_DIR}/gitVersion.h #provided by the init script, contains currently checked out git tag
  130. #add further header files (absolute pathes e.g. using CMAKE_CURRENT_SOURCE_DIR)
  131. )
  132. set(PLUGIN_SOURCES
  133. ${CMAKE_CURRENT_SOURCE_DIR}/dialogMyGrabber.cpp
  134. ${CMAKE_CURRENT_SOURCE_DIR}/dockWidgetMyGrabber.cpp
  135. ${CMAKE_CURRENT_SOURCE_DIR}/myGrabber.cpp
  136. #add further source files here
  137. )
  138. #Append rc file to the source files for adding information about the plugin
  139. # to the properties of the DLL under Visual Studio.
  140. if(MSVC)
  141. list(APPEND PLUGIN_SOURCES ${ITOM_SDK_INCLUDE_DIR}/../pluginLibraryVersion.rc)
  142. endif()
  143. set(PLUGIN_UI
  144. ${CMAKE_CURRENT_SOURCE_DIR}/dialogMyGrabber.ui
  145. ${CMAKE_CURRENT_SOURCE_DIR}/dockWidgetMyGrabber.ui
  146. )
  147. set(PLUGIN_RCC
  148. #add absolute pathes to any *.qrc resource files here
  149. )
  150. #################################################################
  151. # Group files in their original folder structure (MSVC only)
  152. # If you have some header and source files in a specific
  153. # subfolder, you can even have this subfolder in your
  154. # IDE (mainly Visual Studio supports this). Then call
  155. # itom_add_source_group(directoryName) for each subdirectory.
  156. #
  157. # HINT: This command does nothing for IDE different than MSVC.
  158. #################################################################
  159. #itom_add_source_group(subdirectory)
  160. #################################################################
  161. # Compile and link the plugin library
  162. #
  163. #################################################################
  164. #add all (generated) header and source files to the library (these files are compiled then)
  165. add_library(${target_name} SHARED
  166. ${PLUGIN_SOURCES}
  167. ${PLUGIN_HEADERS}
  168. ${PLUGIN_UI}
  169. ${PLUGIN_RCC}
  170. )
  171. # Qt: enable all automoc, autouic and autorcc. Autouic file will be disabled for all files that are processed manually by itom_qt_wrap_ui.
  172. set_target_properties(${target_name} PROPERTIES AUTOMOC ON AUTORCC ON AUTOUIC ON)
  173. #link the compiled library
  174. #append all libraries this plugin should be linked to at the end of the target_link_libraries command
  175. # Important variables are:
  176. # ${ITOM_SDK_LIBRARIES} -> all necessary libraries from find_package(ITOM_SDK)
  177. # -> all necessary libraries from FIND_PACKAGE_QT (Qt4 or Qt5)
  178. # ${OpenCV_LIBS} -> all necessary libraries opencv libraries from find_package(OpenCV)
  179. #
  180. # if you want to link against one library whose directory is already added to link_directories above
  181. # simply add its filename without suffix (*.lib, *.so...). This is automatically done by CMake
  182. target_link_libraries(${target_name} ${ITOM_SDK_LIBRARIES} ${QT5_LIBRARIES} ${VISUALLEAKDETECTOR_LIBRARIES})
  183. #################################################################
  184. # Plugin Translation
  185. #
  186. # In the plugin source directory can be a 'translation' subfolder
  187. # with one or multiple *.ts files (name pattern {target_name}_{language}.ts).
  188. # The itom_library_translation macro adds an ITOM_LANGUAGES string
  189. # to the CMake GUI, where all desired language IDs (besides 'en'
  190. # for english (always the default language) should be given as
  191. # semicolon separated string. To parse all translatable strings
  192. # in the source code (for the first time or to update the ts files),
  193. # set the CMake Option ITOM_UPDATE_TRANSLATIONS and generate
  194. # the project and build the solution (there are now ${target_name}_translation
  195. # projects. Then ts files will be generated in the translation source
  196. # directory for each language (check it into the Git repository)
  197. # or existing ts files will be updated. Then use the QtLinguist
  198. # tool to translate these ts files. After re-building your
  199. # solution, the ts-files are compiled into qm-files, which are then
  200. # put into itom's plugin subdirectory together with the plugin
  201. # library itself.
  202. #################################################################
  203. set(FILES_TO_TRANSLATE ${PLUGIN_SOURCES} ${PLUGIN_HEADERS} ${PLUGIN_UI} ${PLUGIN_RCC})
  204. itom_library_translation(
  205. QM_FILES
  206. TARGET ${target_name}
  207. FILES_TO_TRANSLATE ${FILES_TO_TRANSLATE}
  208. )
  209. #################################################################
  210. # Plugin Documentation
  211. #
  212. # In the source directory of the plugin can be a subfolder 'docs'.
  213. # This folder can contain one or more *.rst files with the docu-
  214. # mentation of the plugin. CMake organizes the rest if you
  215. # indicate the name of the main documentation file(without
  216. # suffix rst) in the following command:
  217. #
  218. # itom_configure_plugin_documentation(${target_name} nameOfTheFile)
  219. #################################################################
  220. itom_configure_plugin_documentation(${target_name} myGrabber)
  221. #################################################################
  222. # Post-Build Copy Operations
  223. #
  224. # itom is able to force a post-build process that copies
  225. # different files, like the currently created library, to
  226. # other destination pathes. This is done in this section.
  227. # At first pairs of sources and destinations are added
  228. # to the lists COPY_SOURCES and COPY_DESTINATIONS.
  229. # Afterwards, the post-build process is generated using
  230. # itom_post_build_copy_files.
  231. #
  232. # The following macros can be used to fill up the source
  233. # and destination list:
  234. #
  235. # itom_add_pluginlibrary_to_copy_list
  236. # - this is necessary for each plugin such that the library
  237. # is automatically copied to the plugins folder of
  238. # the itom build directory.
  239. #
  240. # itom_add_plugin_qm_files_to_copy_list
  241. # - installs the generated translation files (qm) at the
  242. # right place in the itom build directory as well.
  243. #
  244. #################################################################
  245. set(COPY_SOURCES "")
  246. set(COPY_DESTINATIONS "")
  247. itom_add_pluginlibrary_to_copy_list(${target_name} COPY_SOURCES COPY_DESTINATIONS)
  248. itom_add_plugin_qm_files_to_copy_list(${target_name} QM_FILES COPY_SOURCES COPY_DESTINATIONS)
  249. itom_post_build_copy_files(${target_name} COPY_SOURCES COPY_DESTINATIONS)
  250. #if you want to copy one or more files to the lib-folder of
  251. # the itom build directory, use the following macro:
  252. #
  253. # itom_post_build_copy_files_to_lib_folder(${target}, ${listOfFiles})