CMakeLists.txt 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. CMAKE_MINIMUM_REQUIRED(VERSION 3.16.3)
  2. PROJECT(TrackpointApp VERSION 0.0.1 LANGUAGES CXX)
  3. # Include modules
  4. INCLUDE(FetchContent)
  5. # Build TrackpointApp
  6. # Set C++ mode
  7. SET(CMAKE_CXX_STANDARD 14)
  8. SET(CMAKE_CXX_STANDARD_REQUIRED True)
  9. SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -Wunreachable-code -Wno-register")
  10. SET(CMAKE_CXX_FLAGS_RELEASE "-O2 -Wno-register")
  11. SET(CMAKE_AUTOUIC ON)
  12. SET(CMAKE_AUTOMOC ON)
  13. SET(CMAKE_AUTORCC ON)
  14. SET(CMAKE_INCLUDE_CURRENT_DIR ON)
  15. ADD_COMPILE_DEFINITIONS(GL_SILENCE_DEPRECATION)
  16. # Qt
  17. LIST(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_LIST_DIR}/thirdparty/qt/install")
  18. FIND_PACKAGE(Qt6 COMPONENTS Core Gui Widgets OpenGLWidgets REQUIRED NO_CMAKE_SYSTEM_PATH)
  19. # Json
  20. INCLUDE(thirdparty/json.cmake)
  21. # Development build: dynamic link
  22. if(NOT BUILD_STATIC_RELEASE)
  23. # OpenSceneGraph
  24. INCLUDE(thirdparty/openscenegraph.cmake)
  25. # lib3mf
  26. INCLUDE(thirdparty/lib3mf.cmake)
  27. ENDIF()
  28. # Release build: static link
  29. if(BUILD_STATIC_RELEASE)
  30. ADD_DEFINITIONS(-DINCLUDE_PLUGINS)
  31. # OpenSceneGraph
  32. LIST(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_LIST_DIR}/thirdparty/openscenegraph/install")
  33. FIND_PACKAGE(OpenSceneGraph REQUIRED COMPONENTS osgViewer osgDB osgGA osgText osgUtil)
  34. # lib3mf
  35. LIST(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_LIST_DIR}/thirdparty/lib3mf/install")
  36. FIND_PACKAGE(Lib3MF REQUIRED)
  37. ENDIF()
  38. # The executable we want to build
  39. QT_ADD_EXECUTABLE(TrackpointApp
  40. src/main.cpp
  41. src/MainWindow.cpp
  42. include/MainWindow.hpp
  43. gui/MainWindow.ui
  44. src/NoMeshWidget.cpp
  45. include/NoMeshWidget.hpp
  46. gui/NoMeshWidget.ui
  47. src/EditWidget.cpp
  48. include/EditWidget.hpp
  49. gui/EditWidget.ui
  50. include/OSGWidget.hpp
  51. src/OSGWidget.cpp
  52. src/ProjectStore.cpp
  53. src/PickHandler.cpp
  54. src/TrackPoint.cpp
  55. src/OptiTrackPoint.cpp
  56. src/ActionPoint.cpp
  57. src/SteamVRTrackPoint.cpp
  58. src/OpenScadRenderer.cpp
  59. src/StringBasics.cpp
  60. src/TrackPointRenderer.cpp
  61. src/PointShape.cpp
  62. src/HudCallback.cpp
  63. src/STLImport.cpp
  64. src/MeshTools.cpp
  65. )
  66. if(NOT BUILD_STATIC_RELEASE)
  67. INCLUDE_DIRECTORIES(
  68. ${${OPENSCENEGRAPH_PREFIX}_SOURCE_DIR}/include
  69. ${${OPENSCENEGRAPH_PREFIX}_BINARY_DIR}/include
  70. ${${LIB3MF_PREFIX}_BINARY_DIR}/Autogenerated/Bindings/Cpp
  71. )
  72. TARGET_LINK_LIBRARIES(TrackpointApp PRIVATE
  73. osg osgViewer osgDB osgGA osgText osgUtil
  74. lib3mf
  75. )
  76. ENDIF()
  77. if(BUILD_STATIC_RELEASE)
  78. INCLUDE_DIRECTORIES(
  79. ${OPENSCENEGRAPH_INCLUDE_DIRS}
  80. ${LIB3MF_INCLUDE_DIRS}
  81. )
  82. TARGET_LINK_LIBRARIES(TrackpointApp PRIVATE
  83. ${OPENSCENEGRAPH_LIBRARIES}
  84. ${LIB3MF_LIBRARIES}
  85. )
  86. ENDIF()
  87. INCLUDE_DIRECTORIES(
  88. ${${JSON_PREFIX}_SOURCE_DIR}/include
  89. ${CMAKE_CURRENT_LIST_DIR}/thirdparty/stl_reader/install
  90. include
  91. gui
  92. resources
  93. )
  94. TARGET_LINK_LIBRARIES(TrackpointApp PRIVATE
  95. nlohmann_json::nlohmann_json
  96. Qt6::Core
  97. Qt6::Gui
  98. Qt6::Widgets
  99. Qt6::OpenGLWidgets
  100. )
  101. # Header to have version number available in the code
  102. CONFIGURE_FILE(include/trackpointapp.hpp.in include/trackpointapp.hpp)