CMakeLists.txt 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. project( CloudCompare VERSION 2.14.0 )
  2. include( CMakePolicies NO_POLICY_SCOPE )
  3. option( CC_USE_EIGEN
  4. "Compile CloudCompare with Eigen (for registration)"
  5. OFF
  6. )
  7. if ( CC_USE_EIGEN )
  8. set ( EIGEN_ROOT_DIR "" CACHE PATH "Eigen root (contains the Eigen directory)" )
  9. if ( NOT EIGEN_ROOT_DIR )
  10. message( SEND_ERROR "No Eigen root directory specified (EIGEN_ROOT_DIR)" )
  11. endif()
  12. endif()
  13. include_directories( ${CloudComparePlugins_SOURCE_DIR} )
  14. include_directories( ${CMAKE_CURRENT_SOURCE_DIR} )
  15. include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/db_tree )
  16. include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/ui_templates )
  17. include_directories( ${CMAKE_CURRENT_BINARY_DIR} )
  18. file( GLOB header_list *.h )
  19. file( GLOB source_list *.cpp )
  20. file( GLOB ui_list ui_templates/*.ui )
  21. file( GLOB qrc_list *.qrc )
  22. file( GLOB txt_list TODO.txt ${CloudCompareProjects_SOURCE_DIR}/CHANGELOG.md )
  23. add_subdirectory( db_tree )
  24. add_subdirectory( pluginManager )
  25. add_subdirectory( extern/QCustomPlot EXCLUDE_FROM_ALL )
  26. qt5_wrap_ui( generated_ui_list ${ui_list} )
  27. qt5_add_resources( generated_qrc_list ${qrc_list} )
  28. if( MSVC )
  29. # App icon with MSVC
  30. set( rc_list images/icon/cc_icon.rc )
  31. #to get rid of the (system) console
  32. add_executable( ${PROJECT_NAME} WIN32 ${header_list} ${source_list} ${generated_ui_list} ${generated_qrc_list} ${rc_list} ${txt_list} ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/windows/qt5.natvis )
  33. elseif( APPLE )
  34. add_executable( ${PROJECT_NAME} MACOSX_BUNDLE ${header_list} ${source_list} ${generated_ui_list} ${generated_qrc_list} ${txt_list} )
  35. else()
  36. add_executable( ${PROJECT_NAME} ${header_list} ${source_list} ${generated_ui_list} ${generated_qrc_list} ${rc_list} ${txt_list} )
  37. target_compile_definitions( ${PROJECT_NAME} PRIVATE QT_NO_KEYWORDS )
  38. endif()
  39. target_link_libraries( ${PROJECT_NAME}
  40. CCAppCommon
  41. QCustomPlot
  42. Qt5::PrintSupport
  43. )
  44. if( CCCORELIB_USE_QT_CONCURRENT )
  45. # We want *deployqt to handle this dependency, so instead of just copying the file
  46. # link to the target.
  47. target_link_libraries( ${PROJECT_NAME}
  48. Qt5::Concurrent
  49. )
  50. endif()
  51. # Eigen
  52. if ( CC_USE_EIGEN )
  53. target_include_directories( ${PROJECT_NAME}
  54. PUBLIC
  55. ${EIGEN_ROOT_DIR}
  56. )
  57. target_compile_definitions( ${PROJECT_NAME}
  58. PUBLIC
  59. CC_USES_EIGEN
  60. )
  61. endif()
  62. # Add custom preprocessor definitions
  63. if( WIN32 )
  64. if (MSVC)
  65. set_target_properties( ${PROJECT_NAME} PROPERTIES LINK_FLAGS " /MANIFEST:NO" )
  66. endif()
  67. endif()
  68. # App icon with Code::Blocks/MinGW
  69. if( WIN32 )
  70. if( MINGW )
  71. if (NOT CMAKE_RC_COMPILER)
  72. set( CMAKE_RC_COMPILER windres )
  73. endif()
  74. add_custom_command( TARGET ${PROJECT_NAME} PRE_BUILD COMMAND ${CMAKE_RC_COMPILER} -i ${CMAKE_CURRENT_SOURCE_DIR}/images/icon/cc_icon.rc --input-format=rc -o ${CMAKE_CURRENT_BINARY_DIR}/cc_icon.res -O coff )
  75. endif()
  76. endif()
  77. if (NOT APPLE)
  78. # Install program.
  79. # On macOs, the DeployQt step will install the bundle that contains the executable with
  80. # library paths properly set, reinstalling the executable here would break the bundle.
  81. install_ext( TARGETS ${PROJECT_NAME} ${CLOUDCOMPARE_DEST_FOLDER} "" )
  82. endif()
  83. # Auxiliary files
  84. set( auxFiles ${CloudCompareProjects_SOURCE_DIR}/CHANGELOG.md bin_other/license.txt bin_other/global_shift_list_template.txt )
  85. if( WIN32 )
  86. # Additional auxiliary file(s)
  87. file( GLOB batch_list bin_other/*.bat )
  88. list( APPEND auxFiles ${batch_list} )
  89. endif()
  90. # Install auxiliary files
  91. if( WIN32 OR APPLE )
  92. foreach( filename ${auxFiles} )
  93. install_ext( FILES ${filename} ${CLOUDCOMPARE_DEST_FOLDER} "" )
  94. endforeach()
  95. else( UNIX )
  96. foreach( filename ${auxFiles} )
  97. install_ext( FILES ${filename} share/cloudcompare "" )
  98. endforeach()
  99. endif()
  100. # Put together our Application bundle on macOS
  101. if( APPLE )
  102. add_subdirectory( Mac )
  103. endif()
  104. # Translation
  105. add_subdirectory(translations)
  106. ## Shaders
  107. # Copy shader dirs into our shadow build directory
  108. file( COPY ${CC_FBO_LIB_SOURCE_DIR}/shaders DESTINATION "${CMAKE_BINARY_DIR}" )
  109. file( COPY ${CMAKE_CURRENT_SOURCE_DIR}/shaders DESTINATION "${CMAKE_BINARY_DIR}" )
  110. # Export common shader files to all install destinations
  111. if( APPLE )
  112. install( FILES ${CC_FBO_LIB_SOURCE_DIR}/shaders/Bilateral/bilateral.frag DESTINATION ${CLOUDCOMPARE_MAC_BASE_DIR}/Contents/Shaders/Bilateral )
  113. install( FILES ${CC_FBO_LIB_SOURCE_DIR}/shaders/Bilateral/bilateral.vert DESTINATION ${CLOUDCOMPARE_MAC_BASE_DIR}/Contents/Shaders/Bilateral )
  114. install( FILES ${CMAKE_CURRENT_SOURCE_DIR}/shaders/ColorRamp/color_ramp.frag DESTINATION ${CLOUDCOMPARE_MAC_BASE_DIR}/Contents/Shaders/ColorRamp )
  115. install( FILES ${CMAKE_CURRENT_SOURCE_DIR}/shaders/DrawNormals/DrawNormals.vs DESTINATION ${CLOUDCOMPARE_MAC_BASE_DIR}/Contents/Shaders/DrawNormals )
  116. install( FILES ${CMAKE_CURRENT_SOURCE_DIR}/shaders/DrawNormals/DrawNormals.gs DESTINATION ${CLOUDCOMPARE_MAC_BASE_DIR}/Contents/Shaders/DrawNormals )
  117. install( FILES ${CMAKE_CURRENT_SOURCE_DIR}/shaders/DrawNormals/DrawNormals.fs DESTINATION ${CLOUDCOMPARE_MAC_BASE_DIR}/Contents/Shaders/DrawNormals )
  118. elseif( UNIX )
  119. install( FILES ${CC_FBO_LIB_SOURCE_DIR}/shaders/Bilateral/bilateral.frag DESTINATION share/cloudcompare/shaders/Bilateral )
  120. install( FILES ${CC_FBO_LIB_SOURCE_DIR}/shaders/Bilateral/bilateral.vert DESTINATION share/cloudcompare/shaders/Bilateral )
  121. install( FILES ${CMAKE_CURRENT_SOURCE_DIR}/shaders/ColorRamp/color_ramp.frag DESTINATION share/cloudcompare/shaders/ColorRamp )
  122. install( FILES ${CMAKE_CURRENT_SOURCE_DIR}/shaders/DrawNormals/DrawNormals.vs DESTINATION share/cloudcompare/shaders/DrawNormals )
  123. install( FILES ${CMAKE_CURRENT_SOURCE_DIR}/shaders/DrawNormals/DrawNormals.gs DESTINATION share/cloudcompare/shaders/DrawNormals )
  124. install( FILES ${CMAKE_CURRENT_SOURCE_DIR}/shaders/DrawNormals/DrawNormals.fs DESTINATION share/cloudcompare/shaders/DrawNormals )
  125. else()
  126. install_ext( FILES ${CC_FBO_LIB_SOURCE_DIR}/shaders/Bilateral/bilateral.frag ${CLOUDCOMPARE_DEST_FOLDER} /shaders/Bilateral )
  127. install_ext( FILES ${CC_FBO_LIB_SOURCE_DIR}/shaders/Bilateral/bilateral.vert ${CLOUDCOMPARE_DEST_FOLDER} /shaders/Bilateral )
  128. install_ext( FILES ${CMAKE_CURRENT_SOURCE_DIR}/shaders/ColorRamp/color_ramp.frag ${CLOUDCOMPARE_DEST_FOLDER} /shaders/ColorRamp )
  129. install_ext( FILES ${CMAKE_CURRENT_SOURCE_DIR}/shaders/DrawNormals/DrawNormals.vs ${CLOUDCOMPARE_DEST_FOLDER} /shaders/DrawNormals )
  130. install_ext( FILES ${CMAKE_CURRENT_SOURCE_DIR}/shaders/DrawNormals/DrawNormals.gs ${CLOUDCOMPARE_DEST_FOLDER} /shaders/DrawNormals )
  131. install_ext( FILES ${CMAKE_CURRENT_SOURCE_DIR}/shaders/DrawNormals/DrawNormals.fs ${CLOUDCOMPARE_DEST_FOLDER} /shaders/DrawNormals )
  132. endif()
  133. # Install plugins and shaders in the correct folder for each platform
  134. if( APPLE )
  135. InstallPlugins(
  136. DEST_PATH "${CLOUDCOMPARE_MAC_PLUGIN_DIR}"
  137. SHADER_DEST_PATH "${CLOUDCOMPARE_MAC_BASE_DIR}/Contents/Shaders"
  138. )
  139. elseif( UNIX )
  140. InstallPlugins(
  141. DEST_PATH "${CMAKE_INSTALL_LIBDIR}/cloudcompare/plugins"
  142. SHADER_DEST_PATH share/cloudcompare/shaders
  143. )
  144. else()
  145. InstallPlugins(
  146. DEST_PATH "${CLOUDCOMPARE_DEST_FOLDER}"
  147. DEST_FOLDER "plugins"
  148. SHADER_DEST_PATH "${CLOUDCOMPARE_DEST_FOLDER}"
  149. SHADER_DEST_FOLDER "shaders"
  150. )
  151. endif()
  152. if( WIN32 )
  153. DeployQt(
  154. TARGET
  155. ${PROJECT_NAME}
  156. DEPLOY_PATH
  157. ${CLOUDCOMPARE_DEST_FOLDER}
  158. )
  159. else()
  160. DeployQt(
  161. TARGET
  162. ${PROJECT_NAME}
  163. DEPLOY_PATH
  164. ${PROJECT_NAME}
  165. )
  166. endif()
  167. # Add a 'fake' custom target to force the recompilation of ccApplication.ccp in order to
  168. # always get an up-to-date version number (based on the current date)
  169. add_custom_target(CC_UPDATE_VERSION ALL COMMAND ${CMAKE_COMMAND} -E touch_nocreate ${CMAKE_CURRENT_SOURCE_DIR}/ccApplication.cpp)