CMakeLists.txt 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 20)
  8. SET(CMAKE_CXX_STANDARD_REQUIRED True)
  9. SET(CMAKE_CXX_FLAGS_DEBUG "-O0")
  10. SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
  11. SET(CMAKE_AUTOUIC ON)
  12. SET(CMAKE_AUTOMOC ON)
  13. SET(CMAKE_AUTORCC ON)
  14. SET(CMAKE_INCLUDE_CURRENT_DIR ON)
  15. # Qt
  16. LIST(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_LIST_DIR}/thirdparty/qt/install")
  17. FIND_PACKAGE(Qt6 COMPONENTS Core Gui Widgets OpenGLWidgets REQUIRED NO_CMAKE_SYSTEM_PATH)
  18. # Json
  19. INCLUDE(thirdparty/json.cmake)
  20. # Development build: dynamic link
  21. if(NOT BUILD_STATIC_RELEASE)
  22. # OpenSceneGraph
  23. INCLUDE(thirdparty/openscenegraph.cmake)
  24. # lib3mf
  25. INCLUDE(thirdparty/lib3mf.cmake)
  26. ENDIF()
  27. # Release build: static link
  28. if(BUILD_STATIC_RELEASE)
  29. ADD_DEFINITIONS(-DINCLUDE_PLUGINS)
  30. # OpenSceneGraph
  31. LIST(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_LIST_DIR}/thirdparty/openscenegraph/install")
  32. FIND_PACKAGE(OpenSceneGraph REQUIRED COMPONENTS osgViewer osgDB osgGA osgText osgUtil)
  33. # lib3mf
  34. LIST(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_LIST_DIR}/thirdparty/lib3mf/install")
  35. FIND_PACKAGE(Lib3MF REQUIRED)
  36. ENDIF()
  37. # The executable we want to build
  38. QT_ADD_EXECUTABLE(TrackpointApp
  39. src/main.cpp
  40. src/MainWindow.cpp
  41. include/MainWindow.hpp
  42. gui/MainWindow.ui
  43. src/NoMeshWidget.cpp
  44. include/NoMeshWidget.hpp
  45. gui/NoMeshWidget.ui
  46. src/EditWidget.cpp
  47. include/EditWidget.hpp
  48. gui/EditWidget.ui
  49. include/OSGWidget.hpp
  50. src/OSGWidget.cpp
  51. src/ProjectStore.cpp
  52. src/PickHandler.cpp
  53. src/StoreHandler.cpp
  54. src/TrackPoint.cpp
  55. src/ThreeMFWriter.cpp
  56. src/OpenScadRenderer.cpp
  57. )
  58. if(NOT BUILD_STATIC_RELEASE)
  59. INCLUDE_DIRECTORIES(
  60. ${${OPENSCENEGRAPH_PREFIX}_SOURCE_DIR}/include
  61. ${${LIB3MF_PREFIX}_BINARY_DIR}/Autogenerated/Bindings/Cpp
  62. )
  63. TARGET_LINK_LIBRARIES(TrackpointApp PRIVATE
  64. osg osgViewer osgDB osgGA osgText osgUtil
  65. lib3mf
  66. )
  67. ENDIF()
  68. if(BUILD_STATIC_RELEASE)
  69. INCLUDE_DIRECTORIES(
  70. ${OPENSCENEGRAPH_INCLUDE_DIRS}
  71. ${LIB3MF_INCLUDE_DIRS}
  72. )
  73. TARGET_LINK_LIBRARIES(TrackpointApp PRIVATE
  74. ${OPENSCENEGRAPH_LIBRARIES}
  75. ${LIB3MF_LIBRARIES}
  76. )
  77. ENDIF()
  78. INCLUDE_DIRECTORIES(
  79. ${${JSON_PREFIX}_SOURCE_DIR}/include
  80. include
  81. gui
  82. )
  83. TARGET_LINK_LIBRARIES(TrackpointApp PRIVATE
  84. nlohmann_json::nlohmann_json
  85. Qt6::Core
  86. Qt6::Gui
  87. Qt6::Widgets
  88. Qt6::OpenGLWidgets
  89. )
  90. # Header to have version number available in the code
  91. CONFIGURE_FILE(src/trackpointapp.hpp.in src/trackpointapp.hpp)