TEXT   45

CMakeLists

Guest on 5th August 2022 01:36:04 AM

  1. project(CuraEngine)
  2.  
  3. cmake_minimum_required(VERSION 2.8.12)
  4.  
  5. option (ENABLE_ARCUS
  6.     "Enable support for ARCUS" ON)
  7.  
  8. if (ENABLE_ARCUS)
  9.     message(STATUS "Building with Arcus")
  10.     find_package(Arcus REQUIRED)
  11.     add_definitions(-DARCUS)
  12. endif ()
  13.  
  14. if(NOT ${CMAKE_VERSION} VERSION_LESS 3.1)
  15.     set(CMAKE_CXX_STANDARD 11)
  16. else()
  17.     set(CMAKE_CXX_FLAGS "-std=c++11")
  18. endif()
  19.  
  20. if(APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  21.     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")
  22. endif()
  23.  
  24. if(NOT DEFINED LIB_SUFFIX)
  25.     set(LIB_SUFFIX "")
  26. endif()
  27. set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
  28.  
  29. set(CURA_ENGINE_VERSION "master" CACHE STRING "Version name of Cura")
  30.  
  31. option(BUILD_TESTS OFF)
  32.  
  33. # Add a compiler flag to check the output for insane values if we are in debug mode.
  34. if(CMAKE_BUILD_TYPE MATCHES DEBUG OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
  35.     message(STATUS "Building debug release of CuraEngine.")
  36.     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra -O0 -g -fno-omit-frame-pointer")
  37.     add_definitions(-DASSERT_INSANE_OUTPUT)
  38.     add_definitions(-DUSE_CPU_TIME)
  39.     add_definitions(-DDEBUG)
  40. endif()
  41.  
  42. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") # Add warnings
  43.  
  44. option (ENABLE_MORE_COMPILER_OPTIMIZATION_FLAGS
  45.     "Enable more optimization flags" ON)
  46. if (ENABLE_MORE_COMPILER_OPTIMIZATION_FLAGS)
  47.     message (STATUS "Compile with more optimization flags")
  48.     set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -Ofast -funroll-loops")
  49. endif ()
  50.  
  51. if(NOT APPLE AND NOT WIN32)
  52.     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++")
  53. endif()
  54.  
  55. option (ENABLE_OPENMP
  56.     "Use OpenMP for parallel code" ON)
  57.  
  58. if (ENABLE_OPENMP)
  59.     FIND_PACKAGE( OpenMP )
  60.     if( OPENMP_FOUND )
  61.         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}" )
  62.     endif()
  63. endif()
  64.  
  65. include_directories(${CMAKE_CURRENT_BINARY_DIR} libs)
  66.  
  67. add_library(clipper STATIC libs/clipper/clipper.cpp)
  68.  
  69. set(engine_SRCS # Except main.cpp.
  70.     src/bridge.cpp
  71.     src/commandSocket.cpp
  72.     src/ConicalOverhang.cpp
  73.     src/ExtruderTrain.cpp
  74.     src/FffGcodeWriter.cpp
  75.     src/FffPolygonGenerator.cpp
  76.     src/FffProcessor.cpp
  77.     src/gcodeExport.cpp
  78.     src/GCodePathConfig.cpp
  79.     src/infill.cpp
  80.     src/InsetOrderOptimizer.cpp
  81.     src/layerPart.cpp
  82.     src/LayerPlan.cpp
  83.     src/LayerPlanBuffer.cpp
  84.     src/MergeInfillLines.cpp
  85.     src/mesh.cpp
  86.     src/MeshGroup.cpp
  87.     src/Mold.cpp
  88.     src/multiVolumes.cpp
  89.     src/pathOrderOptimizer.cpp
  90.     src/Preheat.cpp
  91.     src/PrimeTower.cpp
  92.     src/raft.cpp
  93.     src/skin.cpp
  94.     src/SkirtBrim.cpp
  95.     src/SupportInfillPart.cpp
  96.     src/sliceDataStorage.cpp
  97.     src/slicer.cpp
  98.     src/support.cpp
  99.     src/timeEstimate.cpp
  100.     src/TopSurface.cpp
  101.     src/TreeSupport.cpp
  102.     src/WallsComputation.cpp
  103.     src/wallOverlap.cpp
  104.     src/Weaver.cpp
  105.     src/Wireframe2gcode.cpp
  106.  
  107.     src/infill/NoZigZagConnectorProcessor.cpp
  108.     src/infill/ZigzagConnectorProcessor.cpp
  109.     src/infill/SpaceFillingTreeFill.cpp
  110.     src/infill/SpaghettiInfill.cpp
  111.     src/infill/SpaghettiInfillPathGenerator.cpp
  112.     src/infill/SubDivCube.cpp
  113.  
  114.     src/pathPlanning/Comb.cpp
  115.     src/pathPlanning/GCodePath.cpp
  116.     src/pathPlanning/LinePolygonsCrossings.cpp
  117.     src/pathPlanning/NozzleTempInsert.cpp
  118.     src/pathPlanning/TimeMaterialEstimates.cpp
  119.  
  120.     src/progress/Progress.cpp
  121.     src/progress/ProgressStageEstimator.cpp
  122.  
  123.     src/settings/PathConfigStorage.cpp
  124.     src/settings/SettingConfig.cpp
  125.     src/settings/SettingContainer.cpp
  126.     src/settings/SettingRegistry.cpp
  127.     src/settings/settings.cpp
  128.     src/settings/AdaptiveLayerHeights.cpp
  129.     src/settings/AdaptiveLayerHeights.h
  130.  
  131.     src/utils/AABB.cpp
  132.     src/utils/AABB3D.cpp
  133.     src/utils/Date.cpp
  134.     src/utils/gettime.cpp
  135.     src/utils/LinearAlg2D.cpp
  136.     src/utils/ListPolyIt.cpp
  137.     src/utils/logoutput.cpp
  138.     src/utils/MinimumSpanningTree.cpp
  139.     src/utils/PolygonsPointIndex.cpp
  140.     src/utils/PolygonProximityLinker.cpp
  141.     src/utils/polygonUtils.cpp
  142.     src/utils/polygon.cpp
  143.     src/utils/ProximityPointLink.cpp
  144.     src/utils/socket.cpp
  145.     src/utils/SpaceFillingTree.cpp
  146. )
  147.  
  148. # List of tests. For each test there must be a file tests/${NAME}.cpp and a file tests/${NAME}.h.
  149. set(engine_TEST_INFILL
  150.     SpaceFillingTreeFillTest
  151. )
  152. set(engine_TEST_UTILS
  153.     SparseGridTest
  154.     IntPointTest
  155.     LinearAlg2DTest
  156.     PolygonUtilsTest
  157.     PolygonTest
  158.     StringTest
  159. )
  160.  
  161. # Generating ProtoBuf protocol
  162. if (ENABLE_ARCUS)
  163. protobuf_generate_cpp(engine_PB_SRCS engine_PB_HEADERS Cura.proto)
  164. endif ()
  165.  
  166. # Compiling CuraEngine itself.
  167. add_library(_CuraEngine ${engine_SRCS} ${engine_PB_SRCS}) #First compile all of CuraEngine as library, allowing this to be re-used for tests.
  168. target_link_libraries(_CuraEngine clipper)
  169. if (ENABLE_ARCUS)
  170.     target_link_libraries(_CuraEngine Arcus)
  171. endif ()
  172.  
  173. set_target_properties(_CuraEngine PROPERTIES COMPILE_DEFINITIONS "VERSION=\"${CURA_ENGINE_VERSION}\"")
  174.  
  175. if (UNIX)
  176.     target_link_libraries(_CuraEngine pthread)
  177. endif()
  178. add_executable(CuraEngine src/main.cpp) #Then compile main.cpp as separate executable, and link the library to it.
  179. target_link_libraries(CuraEngine _CuraEngine)
  180.  
  181. # Compiling the test environment.
  182. if (BUILD_TESTS)
  183.     message(STATUS "Building tests...")
  184.  
  185.     find_package(cppunit)
  186.  
  187.     enable_testing()
  188.     foreach (test ${engine_TEST})
  189.         add_executable(${test} tests/main.cpp tests/${test}.cpp)
  190.         target_link_libraries(${test} _CuraEngine cppunit)
  191.         add_test(${test} ${test})
  192.     endforeach()
  193.     foreach (test ${engine_TEST_INFILL})
  194.         add_executable(${test} tests/main.cpp tests/infill/${test}.cpp)
  195.         target_link_libraries(${test} _CuraEngine cppunit)
  196.         add_test(${test} ${test})
  197.     endforeach()
  198.     foreach (test ${engine_TEST_UTILS})
  199.         add_executable(${test} tests/main.cpp tests/utils/${test}.cpp)
  200.         target_link_libraries(${test} _CuraEngine cppunit)
  201.         add_test(${test} ${test})
  202.     endforeach()
  203. endif()
  204.  
  205.  
  206. add_custom_command(TARGET CuraEngine POST_BUILD
  207.                    COMMAND ${CMAKE_COMMAND} -E copy_directory
  208.                        ${CMAKE_SOURCE_DIR}/resources $<TARGET_FILE_DIR:CuraEngine>)
  209.  
  210. # Installing CuraEngine.
  211. include(GNUInstallDirs)
  212. install(TARGETS CuraEngine DESTINATION ${CMAKE_INSTALL_BINDIR})
  213. include(CPackConfig.cmake)

Raw Paste


Login or Register to edit or fork this paste. It's free.