From 3f28fa125bbed6da8db3c2563a9fd599d5c9c026 Mon Sep 17 00:00:00 2001 From: FormerLurker Date: Tue, 12 May 2020 12:04:06 -0500 Subject: [PATCH] First attempt to use CMake to build. --- .gitignore | 4 ++ ArcWelder/ArcWelder.vcxproj | 6 +++ ArcWelder/ArcWelder.vcxproj.filters | 6 +++ ArcWelder/CMakeLists.txt | 28 ++++++++++ ArcWelder/sourcelist.cmake | 5 ++ ArcWelderConsole/ArcWelderConsole.vcxproj | 6 +++ .../ArcWelderConsole.vcxproj.filters | 6 +++ ArcWelderConsole/CMakeLists.txt | 19 +++++++ ArcWelderConsole/sourcelist.cmake | 3 ++ .../ArcWelderInverseProcessor.vcxproj | 6 +++ .../ArcWelderInverseProcessor.vcxproj.filters | 6 +++ ArcWelderInverseProcessor/CMakeLists.txt | 19 +++++++ ArcWelderInverseProcessor/sourcelist.cmake | 4 ++ ArcWelderLib.sln | 8 +++ CMakeLists.txt | 28 ++++++++++ GcodeProcessorLib/CMakeLists.txt | 21 ++++++++ GcodeProcessorLib/GcodeProcessorLib.vcxproj | 6 +++ .../GcodeProcessorLib.vcxproj.filters | 6 +++ GcodeProcessorLib/sourcelist.cmake | 24 +++++++++ PyArcWelder/CMakeLists.txt | 54 +++++++++++++++++++ PyArcWelder/PyArcWelder.vcxproj | 6 +++ PyArcWelder/PyArcWelder.vcxproj.filters | 6 +++ PyArcWelder/sourcelist.cmake | 6 +++ sourcelist.cmake | 4 ++ 24 files changed, 287 insertions(+) create mode 100644 ArcWelder/CMakeLists.txt create mode 100644 ArcWelder/sourcelist.cmake create mode 100644 ArcWelderConsole/CMakeLists.txt create mode 100644 ArcWelderConsole/sourcelist.cmake create mode 100644 ArcWelderInverseProcessor/CMakeLists.txt create mode 100644 ArcWelderInverseProcessor/sourcelist.cmake create mode 100644 CMakeLists.txt create mode 100644 GcodeProcessorLib/CMakeLists.txt create mode 100644 GcodeProcessorLib/sourcelist.cmake create mode 100644 PyArcWelder/CMakeLists.txt create mode 100644 PyArcWelder/sourcelist.cmake create mode 100644 sourcelist.cmake diff --git a/.gitignore b/.gitignore index 8b1502c..212afe6 100644 --- a/.gitignore +++ b/.gitignore @@ -111,6 +111,10 @@ ipch/ # Visual Studio Trace Files *.e2e +# CMake Builds +/Builds +/out + # TFS 2012 Local Workspace $tf/ diff --git a/ArcWelder/ArcWelder.vcxproj b/ArcWelder/ArcWelder.vcxproj index 428e87b..a9afaa8 100644 --- a/ArcWelder/ArcWelder.vcxproj +++ b/ArcWelder/ArcWelder.vcxproj @@ -152,6 +152,12 @@ + + + + + + diff --git a/ArcWelder/ArcWelder.vcxproj.filters b/ArcWelder/ArcWelder.vcxproj.filters index e79f8a0..5b6f168 100644 --- a/ArcWelder/ArcWelder.vcxproj.filters +++ b/ArcWelder/ArcWelder.vcxproj.filters @@ -39,4 +39,10 @@ Source Files + + + + + + \ No newline at end of file diff --git a/ArcWelder/CMakeLists.txt b/ArcWelder/CMakeLists.txt new file mode 100644 index 0000000..822dee3 --- /dev/null +++ b/ArcWelder/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required (VERSION "3.16") + +project(ArcWelder C CXX) + +# add definitions from the GcodeProcessorLib project +add_definitions(${GcodeProcessorLib_DEFINITIONS}) + +# Include the GcodeProcessorLib's directories +include_directories(${GcodeProcessorLib_INCLUDE_DIRS}) + +# include sourcelist.cmake, which contains our source list and exposes it as the +# ArcWelderSources variable +include(sourcelist.cmake) + +# Add a library using our ArcWelderSources variable from our sourcelist file +add_library(${PROJECT_NAME} STATIC ${ArcWelderSources}) + +# Link the GcodeProcessorLib +target_link_libraries(${PROJECT_NAME} GcodeProcessorLib) + +# Expose the GcodeProcessorLib's Definitions +set(${PROJECT_NAME}_DEFINITIONS ${GcodeProcessorLib_DEFINITIONS} + CACHE INTERNAL "${PROJECT_NAME}: Definitions" FORCE) + +# Expose both the ArcWelder and GcodeProcessorLib's public includes +set(${PROJECT_NAME}_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/ + ${GcodeProcessorLib_INCLUDE_DIRS} + CACHE INTERNAL "${PROJECT_NAME}: Include Directories" FORCE) diff --git a/ArcWelder/sourcelist.cmake b/ArcWelder/sourcelist.cmake new file mode 100644 index 0000000..64bf1b0 --- /dev/null +++ b/ArcWelder/sourcelist.cmake @@ -0,0 +1,5 @@ +set(ArcWelderSources ${ArcWelderSources} + arc_welder.cpp + segmented_arc.cpp + segmented_shape.cpp +) \ No newline at end of file diff --git a/ArcWelderConsole/ArcWelderConsole.vcxproj b/ArcWelderConsole/ArcWelderConsole.vcxproj index 331e79b..06b6e76 100644 --- a/ArcWelderConsole/ArcWelderConsole.vcxproj +++ b/ArcWelderConsole/ArcWelderConsole.vcxproj @@ -155,6 +155,12 @@ {31478bae-104b-4cc3-9876-42fa90cbd5fe} + + + + + + diff --git a/ArcWelderConsole/ArcWelderConsole.vcxproj.filters b/ArcWelderConsole/ArcWelderConsole.vcxproj.filters index af91d71..e7b2735 100644 --- a/ArcWelderConsole/ArcWelderConsole.vcxproj.filters +++ b/ArcWelderConsole/ArcWelderConsole.vcxproj.filters @@ -24,4 +24,10 @@ Header Files + + + + + + \ No newline at end of file diff --git a/ArcWelderConsole/CMakeLists.txt b/ArcWelderConsole/CMakeLists.txt new file mode 100644 index 0000000..84058ec --- /dev/null +++ b/ArcWelderConsole/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required (VERSION "3.16") + +project(ArcWelderConsole C CXX) + +# add definitions from the GcodeProcessorLib and ArcWelder libraries +add_definitions(${GcodeProcessorLib_DEFINITIONS} ${ArcWelder_DEFINITIONS}) + +# Include the GcodeProcessorLib and ArcWelder's directories +include_directories(${GcodeProcessorLib_INCLUDE_DIRS} ${ArcWelder_INCLUDE_DIRS}) + +# include sourcelist.cmake, which contains our source list and exposes it as the +# ArcWelderConsoleSources variable +include(sourcelist.cmake) + +# Add an executable our ArcWelderConsoleSources variable from our sourcelist file +add_executable(${PROJECT_NAME} ${ArcWelderConsoleSources}) + +# specify linking to the GcodeProcessorLib and ArcWelder libraries +target_link_libraries(${PROJECT_NAME} GcodeProcessorLib ArcWelder) diff --git a/ArcWelderConsole/sourcelist.cmake b/ArcWelderConsole/sourcelist.cmake new file mode 100644 index 0000000..da77fe5 --- /dev/null +++ b/ArcWelderConsole/sourcelist.cmake @@ -0,0 +1,3 @@ +set(ArcWelderConsoleSources ${ArcWelderConsoleSources} + ArcWelderConsole.cpp +) \ No newline at end of file diff --git a/ArcWelderInverseProcessor/ArcWelderInverseProcessor.vcxproj b/ArcWelderInverseProcessor/ArcWelderInverseProcessor.vcxproj index f525571..0e93496 100644 --- a/ArcWelderInverseProcessor/ArcWelderInverseProcessor.vcxproj +++ b/ArcWelderInverseProcessor/ArcWelderInverseProcessor.vcxproj @@ -157,6 +157,12 @@ {31478bae-104b-4cc3-9876-42fa90cbd5fe} + + + + + + diff --git a/ArcWelderInverseProcessor/ArcWelderInverseProcessor.vcxproj.filters b/ArcWelderInverseProcessor/ArcWelderInverseProcessor.vcxproj.filters index 55a31a5..fe669d6 100644 --- a/ArcWelderInverseProcessor/ArcWelderInverseProcessor.vcxproj.filters +++ b/ArcWelderInverseProcessor/ArcWelderInverseProcessor.vcxproj.filters @@ -30,4 +30,10 @@ Source Files + + + + + + \ No newline at end of file diff --git a/ArcWelderInverseProcessor/CMakeLists.txt b/ArcWelderInverseProcessor/CMakeLists.txt new file mode 100644 index 0000000..ba8e2a6 --- /dev/null +++ b/ArcWelderInverseProcessor/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required (VERSION "3.16") + +project(ArcWelderInverseProcessor C CXX) + +# add definitions from the GcodeProcessorLib and ArcWelder libraries +add_definitions(${GcodeProcessorLib_DEFINITIONS} ${ArcWelder_DEFINITIONS}) + +# Include the GcodeProcessorLib and ArcWelder's directories +include_directories(${GcodeProcessorLib_INCLUDE_DIRS} ${ArcWelder_INCLUDE_DIRS}) + +# include sourcelist.cmake, which contains our source list and exposes it as the +# ArcWelderConsoleSources variable +include(sourcelist.cmake) + +# Add an executable our ArcWelderConsoleSources variable from our sourcelist file +add_executable(${PROJECT_NAME} ${ArcWelderInverseProcessorSources}) + +# specify linking to the GcodeProcessorLib and ArcWelder libraries +target_link_libraries(${PROJECT_NAME} GcodeProcessorLib ArcWelder) diff --git a/ArcWelderInverseProcessor/sourcelist.cmake b/ArcWelderInverseProcessor/sourcelist.cmake new file mode 100644 index 0000000..d0ea63c --- /dev/null +++ b/ArcWelderInverseProcessor/sourcelist.cmake @@ -0,0 +1,4 @@ +set(ArcWelderInverseProcessorSources ${ArcWelderInverseProcessorSources} + ArcWelderInverseProcessor.cpp + inverse_processor.cpp +) \ No newline at end of file diff --git a/ArcWelderLib.sln b/ArcWelderLib.sln index 9bfbb73..6776791 100644 --- a/ArcWelderLib.sln +++ b/ArcWelderLib.sln @@ -15,6 +15,14 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ArcWelderInverseProcessor", EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ArcWelderTest", "ArcWelderTest\ArcWelderTest.vcxproj", "{18D7E538-6ACE-44E4-B83E-31C3E44D4227}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4B744529-B248-475D-AE0D-0B5E1617837F}" + ProjectSection(SolutionItems) = preProject + .gitattributes = .gitattributes + .gitignore = .gitignore + CMakeLists.txt = CMakeLists.txt + sourcelist.cmake = sourcelist.cmake + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..4fe8293 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required (VERSION "3.16") +# You can tweak some common (for all subprojects) stuff here. For example: +project(Build C CXX) + +set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) +set(CMAKE_DISABLE_SOURCE_CHANGES ON) + +if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") + message(SEND_ERROR "In-source builds are not allowed.") +endif () + +set(CMAKE_VERBOSE_MAKEFILE ON) +set(CMAKE_COLOR_MAKEFILE ON) + +# Remove 'lib' prefix for shared libraries on Windows +if (WIN32) + set(CMAKE_SHARED_LIBRARY_PREFIX "") +endif () + +# add subdirectories to compile in order of inheritance +add_subdirectory(${CMAKE_SOURCE_DIR}/GcodeProcessorLib) +add_subdirectory(${CMAKE_SOURCE_DIR}/ArcWelder) +add_subdirectory(${CMAKE_SOURCE_DIR}/ArcWelderConsole) +add_subdirectory(${CMAKE_SOURCE_DIR}/ArcWelderInverseProcessor) +add_subdirectory(${CMAKE_SOURCE_DIR}/PyArcWelder) + + + diff --git a/GcodeProcessorLib/CMakeLists.txt b/GcodeProcessorLib/CMakeLists.txt new file mode 100644 index 0000000..7df5acc --- /dev/null +++ b/GcodeProcessorLib/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required (VERSION "3.16") + +project(GcodeProcessorLib C CXX) + +# include sourcelist.cmake, which contains our source list and exposes it as the +# GcodeProcessorLibSources variable +include(sourcelist.cmake) + +# Add a library using our GcodeProcessorLibSources variable from our sourcelist file +add_library(${PROJECT_NAME} STATIC ${GcodeProcessorLibSources}) + +# Required on Unix OS family to be able to be linked into shared libraries. +set_target_properties(${PROJECT_NAME} + PROPERTIES POSITION_INDEPENDENT_CODE ON) + +target_link_libraries(${PROJECT_NAME}) + +# Expose the public includes via a cache variable +set(${PROJECT_NAME}_INCLUDE_DIRS ${PROJECT_SOURCE_DIR} + CACHE INTERNAL "${PROJECT_NAME}: Include Directories" FORCE) + diff --git a/GcodeProcessorLib/GcodeProcessorLib.vcxproj b/GcodeProcessorLib/GcodeProcessorLib.vcxproj index 9d8c738..aba91bd 100644 --- a/GcodeProcessorLib/GcodeProcessorLib.vcxproj +++ b/GcodeProcessorLib/GcodeProcessorLib.vcxproj @@ -163,6 +163,12 @@ + + + + + + diff --git a/GcodeProcessorLib/GcodeProcessorLib.vcxproj.filters b/GcodeProcessorLib/GcodeProcessorLib.vcxproj.filters index 3981297..869d7ff 100644 --- a/GcodeProcessorLib/GcodeProcessorLib.vcxproj.filters +++ b/GcodeProcessorLib/GcodeProcessorLib.vcxproj.filters @@ -84,4 +84,10 @@ Source Files + + + + + + \ No newline at end of file diff --git a/GcodeProcessorLib/sourcelist.cmake b/GcodeProcessorLib/sourcelist.cmake new file mode 100644 index 0000000..ca1a9e7 --- /dev/null +++ b/GcodeProcessorLib/sourcelist.cmake @@ -0,0 +1,24 @@ +set(GcodeProcessorLibSources ${GcodeProcessorLibSources} + array_list.cpp + array_list.h + circular_buffer.cpp + circular_buffer.h + extruder.cpp + extruder.h + gcode_comment_processor.cpp + gcode_comment_processor.h + gcode_parser.cpp + gcode_parser.h + gcode_position.cpp + gcode_position.h + logger.cpp + logger.h + parsed_command.cpp + parsed_command.h + parsed_command_parameter.cpp + parsed_command_parameter.h + position.cpp + position.h + utilities.cpp + utilities.h +) \ No newline at end of file diff --git a/PyArcWelder/CMakeLists.txt b/PyArcWelder/CMakeLists.txt new file mode 100644 index 0000000..a26340d --- /dev/null +++ b/PyArcWelder/CMakeLists.txt @@ -0,0 +1,54 @@ +cmake_minimum_required (VERSION "3.16") + +project(PyArcWelder C CXX) + +# PythonLibs is required to build a python extension +find_package(PythonLibs REQUIRED) + +# Add definitions from ArcWelder and GcodeProcessorLib +add_definitions(${ArcWelder_DEFINITIONS} ${GcodeProcessorLib_DEFINITIONS}) + +# Include Python, ArcWelder and GcodeProcessorLib +include_directories(${PYTHON_INCLUDE_DIRS} ${ArcWelder_INCLUDE_DIRS} ${GcodeProcessorLib_INCLUDE_DIRS}) + +# include sourcelist.cmake, which contains our source list and exposes it as the +# PyArcWelderSources variable +include(sourcelist.cmake) + +# Create our library +add_library(${PROJECT_NAME} SHARED ${PyArcWelderSources}) + +set_target_properties( + ${PROJECT_NAME} + PROPERTIES + PREFIX "" + OUTPUT_NAME ${PROJECT_NAME} + LINKER_LANGUAGE C +) + +if(WIN32) + set_target_properties( + ${PROJECT_NAME} + PROPERTIES + SUFFIX ".pyd" + ) +endif() + +# Link to ArcWelder, GcodeProcessorLib and the Python Libraries +target_link_libraries(${PROJECT_NAME} ArcWelder GcodeProcessorLib) + +# On Windows, it is required to link to the Python libraries +if(WIN32) + target_link_libraries(${PROJECT_NAME} ArcWelder GcodeProcessorLib ${PYTHON_LIBRARIES}) +endif() + +# Expose the GcodeProcessorLib, and ArcWelder's Definitions. +set(${PROJECT_NAME}_DEFINITIONS ${GcodeProcessorLib_DEFINITIONS} + ${ArcWelder_DEFINITIONS} + CACHE INTERNAL "${PROJECT_NAME}: Definitions" FORCE) + +# Expose the GcodeProcessorLib, ArcWelder and PyArcWelder's Definitions. +set(${PROJECT_NAME}_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/ + ${ArcWelder_INCLUDE_DIRS} + ${GcodeProcessorLib_INCLUDE_DIRS} + CACHE INTERNAL "${PROJECT_NAME}: Include Directories" FORCE) diff --git a/PyArcWelder/PyArcWelder.vcxproj b/PyArcWelder/PyArcWelder.vcxproj index 1657d94..3f6138f 100644 --- a/PyArcWelder/PyArcWelder.vcxproj +++ b/PyArcWelder/PyArcWelder.vcxproj @@ -179,6 +179,12 @@ {31478bae-104b-4cc3-9876-42fa90cbd5fe} + + + + + + diff --git a/PyArcWelder/PyArcWelder.vcxproj.filters b/PyArcWelder/PyArcWelder.vcxproj.filters index 8544f81..96be875 100644 --- a/PyArcWelder/PyArcWelder.vcxproj.filters +++ b/PyArcWelder/PyArcWelder.vcxproj.filters @@ -42,4 +42,10 @@ Source Files + + + + + + \ No newline at end of file diff --git a/PyArcWelder/sourcelist.cmake b/PyArcWelder/sourcelist.cmake new file mode 100644 index 0000000..5be1348 --- /dev/null +++ b/PyArcWelder/sourcelist.cmake @@ -0,0 +1,6 @@ +set(PyArcWelderSources ${PyArcWelderSources} + py_arc_welder.cpp + py_arc_welder_extension.cpp + py_logger.cpp + python_helpers.cpp +) \ No newline at end of file diff --git a/sourcelist.cmake b/sourcelist.cmake new file mode 100644 index 0000000..fd40910 --- /dev/null +++ b/sourcelist.cmake @@ -0,0 +1,4 @@ + + + +