From b1530779cb78a8d9e5155175616792484085e318 Mon Sep 17 00:00:00 2001 From: Mark Meredith Date: Mon, 25 May 2020 21:24:38 -0400 Subject: [PATCH 1/7] Reorganize functions --- {src/csg => include}/csg.hpp | 0 {src/inputs => include}/solver.hpp | 2 +- meson.build | 13 ++----------- src/csg/CMakeLists.txt | 16 ++++++++++------ src/csg/{impl => }/csg.cpp | 2 +- src/csg/{impl => }/levelset_2d.cpp | 0 src/csg/{impl => }/levelset_3d.cpp | 0 src/csg/{impl => }/matrix_functions.cpp | 2 +- src/csg/meson.build | 11 ++++++----- src/csg/{impl => }/parser.cpp | 0 src/csg/tests/CMakeLists.txt | 6 +++--- src/csg/tests/levelset/extrude.t.cpp | 2 +- src/csg/tests/levelset/transform.t.cpp | 2 +- ...ix_functions.hpp => csg_matrix_functions.hpp} | 0 src/{csg/impl => }/csg_types.hpp | 2 +- src/{ => inputs}/main.cpp | 0 src/inputs/meson.build | 10 ++++++++++ src/inputs/tests/solver.t.cpp | 2 +- src/{inputs => }/solver_impl.hpp | 0 src/{inputs/inputs.hpp => solver_inputs.hpp} | 0 20 files changed, 38 insertions(+), 32 deletions(-) rename {src/csg => include}/csg.hpp (100%) rename {src/inputs => include}/solver.hpp (97%) rename src/csg/{impl => }/csg.cpp (98%) rename src/csg/{impl => }/levelset_2d.cpp (100%) rename src/csg/{impl => }/levelset_3d.cpp (100%) rename src/csg/{impl => }/matrix_functions.cpp (97%) rename src/csg/{impl => }/parser.cpp (100%) rename src/{csg/impl/matrix_functions.hpp => csg_matrix_functions.hpp} (100%) rename src/{csg/impl => }/csg_types.hpp (99%) rename src/{ => inputs}/main.cpp (100%) rename src/{inputs => }/solver_impl.hpp (100%) rename src/{inputs/inputs.hpp => solver_inputs.hpp} (100%) diff --git a/src/csg/csg.hpp b/include/csg.hpp similarity index 100% rename from src/csg/csg.hpp rename to include/csg.hpp diff --git a/src/inputs/solver.hpp b/include/solver.hpp similarity index 97% rename from src/inputs/solver.hpp rename to include/solver.hpp index 0245e1d..de49c86 100644 --- a/src/inputs/solver.hpp +++ b/include/solver.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include namespace solver { diff --git a/meson.build b/meson.build index 4cd3c59..59f24b5 100644 --- a/meson.build +++ b/meson.build @@ -9,18 +9,9 @@ catch2 = dependency('catch2', method: 'pkg-config') cgal = dependency('cgal', method: 'pkg-config') parser_inc = include_directories( - 'src/csg', - 'src/csg/impl', + 'include', + 'src', 'src/inputs') subdir('src/csg') subdir('src/inputs') - -executable( - 'mfix-parser', - 'src/main.cpp', - include_directories: parser_inc, - link_with: [ - lib_csg_parser, - lib_inputs_parser, - ]) diff --git a/src/csg/CMakeLists.txt b/src/csg/CMakeLists.txt index 5816252..ab14f9d 100644 --- a/src/csg/CMakeLists.txt +++ b/src/csg/CMakeLists.txt @@ -4,14 +4,18 @@ add_library(csg) target_sources(csg PRIVATE - impl/parser.cpp - impl/levelset_3d.cpp - impl/levelset_2d.cpp - impl/csg.cpp - impl/matrix_functions.cpp + parser.cpp + levelset_3d.cpp + levelset_2d.cpp + csg.cpp + matrix_functions.cpp + ) + +target_include_directories(csg + PUBLIC ${CMAKE_SOURCE_DIR}/include + PRIVATE ${CMAKE_SOURCE_DIR}/src ) -target_include_directories(csg INTERFACE ${CMAKE_SOURCE_DIR}) target_link_libraries(csg PRIVATE stdc++fs CONAN_PKG::cgal diff --git a/src/csg/impl/csg.cpp b/src/csg/csg.cpp similarity index 98% rename from src/csg/impl/csg.cpp rename to src/csg/csg.cpp index 80fa8dd..8b7c174 100644 --- a/src/csg/impl/csg.cpp +++ b/src/csg/csg.cpp @@ -2,7 +2,7 @@ #include #include -#include "../csg.hpp" +#include "csg.hpp" #include "csg_types.hpp" diff --git a/src/csg/impl/levelset_2d.cpp b/src/csg/levelset_2d.cpp similarity index 100% rename from src/csg/impl/levelset_2d.cpp rename to src/csg/levelset_2d.cpp diff --git a/src/csg/impl/levelset_3d.cpp b/src/csg/levelset_3d.cpp similarity index 100% rename from src/csg/impl/levelset_3d.cpp rename to src/csg/levelset_3d.cpp diff --git a/src/csg/impl/matrix_functions.cpp b/src/csg/matrix_functions.cpp similarity index 97% rename from src/csg/impl/matrix_functions.cpp rename to src/csg/matrix_functions.cpp index 4c0159d..4294716 100644 --- a/src/csg/impl/matrix_functions.cpp +++ b/src/csg/matrix_functions.cpp @@ -1,4 +1,4 @@ -#include "matrix_functions.hpp" +#include "csg_matrix_functions.hpp" namespace { double determinant(const matrix::Mat2d &m) { diff --git a/src/csg/meson.build b/src/csg/meson.build index a65bc68..c9f7140 100644 --- a/src/csg/meson.build +++ b/src/csg/meson.build @@ -1,10 +1,11 @@ lib_csg_parser = static_library( 'csg-parser', - 'impl/csg.cpp', - 'impl/levelset_3d.cpp', - 'impl/levelset_2d.cpp', - 'impl/parser.cpp', - 'impl/matrix_functions.cpp', + 'csg.cpp', + 'levelset_3d.cpp', + 'levelset_2d.cpp', + 'parser.cpp', + 'matrix_functions.cpp', + include_directories: parser_inc, dependencies: [pegtl, cgal], install : true) diff --git a/src/csg/impl/parser.cpp b/src/csg/parser.cpp similarity index 100% rename from src/csg/impl/parser.cpp rename to src/csg/parser.cpp diff --git a/src/csg/tests/CMakeLists.txt b/src/csg/tests/CMakeLists.txt index 5476ad7..7f2cb0b 100644 --- a/src/csg/tests/CMakeLists.txt +++ b/src/csg/tests/CMakeLists.txt @@ -16,9 +16,9 @@ add_executable(unit_tests_csg EXCLUDE_FROM_ALL parser/extrude.t.cpp ) -target_include_directories(unit_tests_csg PRIVATE - .. - ../impl +target_include_directories(unit_tests_csg + PUBLIC ${CMAKE_SOURCE_DIR}/include + PRIVATE ${CMAKE_SOURCE_DIR}/src ${CONAN_INCLUDE_DIRS_CATCH2} ) diff --git a/src/csg/tests/levelset/extrude.t.cpp b/src/csg/tests/levelset/extrude.t.cpp index 6629bed..74404cf 100644 --- a/src/csg/tests/levelset/extrude.t.cpp +++ b/src/csg/tests/levelset/extrude.t.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include namespace { diff --git a/src/csg/tests/levelset/transform.t.cpp b/src/csg/tests/levelset/transform.t.cpp index 1461750..99bf3ef 100644 --- a/src/csg/tests/levelset/transform.t.cpp +++ b/src/csg/tests/levelset/transform.t.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include namespace { diff --git a/src/csg/impl/matrix_functions.hpp b/src/csg_matrix_functions.hpp similarity index 100% rename from src/csg/impl/matrix_functions.hpp rename to src/csg_matrix_functions.hpp diff --git a/src/csg/impl/csg_types.hpp b/src/csg_types.hpp similarity index 99% rename from src/csg/impl/csg_types.hpp rename to src/csg_types.hpp index 0cf2549..5077100 100644 --- a/src/csg/impl/csg_types.hpp +++ b/src/csg_types.hpp @@ -1,7 +1,7 @@ #ifndef CSG_TYPES_H_ #define CSG_TYPES_H_ -#include "matrix_functions.hpp" +#include "csg_matrix_functions.hpp" #include #include diff --git a/src/main.cpp b/src/inputs/main.cpp similarity index 100% rename from src/main.cpp rename to src/inputs/main.cpp diff --git a/src/inputs/meson.build b/src/inputs/meson.build index 3e993c7..f8c7dd1 100644 --- a/src/inputs/meson.build +++ b/src/inputs/meson.build @@ -5,7 +5,17 @@ lib_inputs_parser = static_library( 'parser.cpp', 'solver.cpp', 'time.cpp', + include_directories: parser_inc, dependencies: [pegtl], install : true) +executable( + 'mfix-parser', + 'main.cpp', + include_directories: parser_inc, + link_with: [ + lib_csg_parser, + lib_inputs_parser, + ]) + subdir('tests') diff --git a/src/inputs/tests/solver.t.cpp b/src/inputs/tests/solver.t.cpp index c7343f4..5801752 100644 --- a/src/inputs/tests/solver.t.cpp +++ b/src/inputs/tests/solver.t.cpp @@ -1,6 +1,6 @@ #include "catch2/catch.hpp" -#include +#include #include TEST_CASE("GeometrySettings", "[]") { diff --git a/src/inputs/solver_impl.hpp b/src/solver_impl.hpp similarity index 100% rename from src/inputs/solver_impl.hpp rename to src/solver_impl.hpp diff --git a/src/inputs/inputs.hpp b/src/solver_inputs.hpp similarity index 100% rename from src/inputs/inputs.hpp rename to src/solver_inputs.hpp -- GitLab From e7e2c3fb1a5f78e0ed08735cf5a8575488d55bad Mon Sep 17 00:00:00 2001 From: Mark Meredith Date: Tue, 26 May 2020 07:21:57 -0400 Subject: [PATCH 2/7] Rename mains --- src/csg/tests/CMakeLists.txt | 6 +++--- src/csg/tests/meson.build | 6 +++--- src/csg/tests/{parser/main.cpp => unit_tests_csg.main.cpp} | 0 src/inputs/meson.build | 2 +- src/inputs/{main.cpp => mfix-parser.main.cpp} | 0 src/inputs/tests/meson.build | 2 +- src/inputs/tests/{main.cpp => unit_tests_inputs.main.cpp} | 0 7 files changed, 8 insertions(+), 8 deletions(-) rename src/csg/tests/{parser/main.cpp => unit_tests_csg.main.cpp} (100%) rename src/inputs/{main.cpp => mfix-parser.main.cpp} (100%) rename src/inputs/tests/{main.cpp => unit_tests_inputs.main.cpp} (100%) diff --git a/src/csg/tests/CMakeLists.txt b/src/csg/tests/CMakeLists.txt index 7f2cb0b..7ba26c7 100644 --- a/src/csg/tests/CMakeLists.txt +++ b/src/csg/tests/CMakeLists.txt @@ -4,16 +4,16 @@ add_executable(unit_tests_csg EXCLUDE_FROM_ALL levelset/boolean.t.cpp + levelset/extrude.t.cpp levelset/primitives.t.cpp levelset/transform.t.cpp - levelset/extrude.t.cpp parser/boolean.t.cpp - parser/main.cpp + parser/extrude.t.cpp parser/nest.cpp parser/other.t.cpp parser/primitives.t.cpp parser/transform.t.cpp - parser/extrude.t.cpp + unit_tests_csg.main.cpp ) target_include_directories(unit_tests_csg diff --git a/src/csg/tests/meson.build b/src/csg/tests/meson.build index b4f9e61..3051eab 100644 --- a/src/csg/tests/meson.build +++ b/src/csg/tests/meson.build @@ -1,16 +1,16 @@ test_csg = executable( 'unit_tests_csg', 'levelset/boolean.t.cpp', + 'levelset/extrude.t.cpp', 'levelset/primitives.t.cpp', 'levelset/transform.t.cpp', - 'levelset/extrude.t.cpp', 'parser/boolean.t.cpp', - 'parser/main.cpp', + 'parser/extrude.t.cpp', 'parser/nest.cpp', 'parser/other.t.cpp', 'parser/primitives.t.cpp', 'parser/transform.t.cpp', - 'parser/extrude.t.cpp', + 'unit_tests_csg.main.cpp', include_directories: [parser_inc], dependencies: [catch2, cgal], link_with: lib_csg_parser, diff --git a/src/csg/tests/parser/main.cpp b/src/csg/tests/unit_tests_csg.main.cpp similarity index 100% rename from src/csg/tests/parser/main.cpp rename to src/csg/tests/unit_tests_csg.main.cpp diff --git a/src/inputs/meson.build b/src/inputs/meson.build index f8c7dd1..ecc7383 100644 --- a/src/inputs/meson.build +++ b/src/inputs/meson.build @@ -11,7 +11,7 @@ lib_inputs_parser = static_library( executable( 'mfix-parser', - 'main.cpp', + 'mfix-parser.main.cpp', include_directories: parser_inc, link_with: [ lib_csg_parser, diff --git a/src/inputs/main.cpp b/src/inputs/mfix-parser.main.cpp similarity index 100% rename from src/inputs/main.cpp rename to src/inputs/mfix-parser.main.cpp diff --git a/src/inputs/tests/meson.build b/src/inputs/tests/meson.build index 0d0fa24..68dfcaf 100644 --- a/src/inputs/tests/meson.build +++ b/src/inputs/tests/meson.build @@ -2,7 +2,7 @@ test_inputs = executable( 'unit_tests_inputs', 'parser.t.cpp', 'solver.t.cpp', - 'main.cpp', + 'unit_tests_inputs.main.cpp', include_directories: [parser_inc], dependencies: [catch2], link_with: lib_inputs_parser diff --git a/src/inputs/tests/main.cpp b/src/inputs/tests/unit_tests_inputs.main.cpp similarity index 100% rename from src/inputs/tests/main.cpp rename to src/inputs/tests/unit_tests_inputs.main.cpp -- GitLab From 5c10e52e053b647b114b61a88ddfb655074d92f6 Mon Sep 17 00:00:00 2001 From: Mark Meredith Date: Tue, 26 May 2020 07:23:46 -0400 Subject: [PATCH 3/7] cleanup --- meson.build | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/meson.build b/meson.build index 59f24b5..a2fbacd 100644 --- a/meson.build +++ b/meson.build @@ -8,10 +8,7 @@ pegtl = dependency('pegtl', method: 'pkg-config') catch2 = dependency('catch2', method: 'pkg-config') cgal = dependency('cgal', method: 'pkg-config') -parser_inc = include_directories( - 'include', - 'src', - 'src/inputs') +parser_inc = include_directories('include', 'src') subdir('src/csg') subdir('src/inputs') -- GitLab From ebc0f442b4d9083816bcb2df7e6280012ed629bc Mon Sep 17 00:00:00 2001 From: Mark Meredith Date: Tue, 26 May 2020 07:28:15 -0400 Subject: [PATCH 4/7] simplify --- src/csg/CMakeLists.txt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/csg/CMakeLists.txt b/src/csg/CMakeLists.txt index ab14f9d..0ef27ea 100644 --- a/src/csg/CMakeLists.txt +++ b/src/csg/CMakeLists.txt @@ -1,14 +1,12 @@ ################################################################################ # CSG Parser ################################################################################ -add_library(csg) - -target_sources(csg PRIVATE - parser.cpp - levelset_3d.cpp - levelset_2d.cpp +add_library(csg csg.cpp + levelset_2d.cpp + levelset_3d.cpp matrix_functions.cpp + parser.cpp ) target_include_directories(csg -- GitLab From 1b58867b36f534bfdd120c15bba03f8ae2ffa1dd Mon Sep 17 00:00:00 2001 From: Mark Meredith Date: Tue, 26 May 2020 07:30:51 -0400 Subject: [PATCH 5/7] Run CTest verbose --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 89dc2b2..5c1aec5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,6 +20,6 @@ test:cmake: - cmake -S. -Bbuild -GNinja -DCMAKE_BUILD_TYPE=Debug - cmake --build build --target unit_tests_csg - cd build - - ctest + - ctest --verbose tags: - mfix-exa -- GitLab From 41d72d87a89261f4d90c6fb5fbe90d8f0420a6e2 Mon Sep 17 00:00:00 2001 From: Mark Meredith Date: Tue, 26 May 2020 07:36:12 -0400 Subject: [PATCH 6/7] Cleanup --- CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d0c5ce..7e0fa82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,8 +15,6 @@ if(CCACHE_FOUND) set( CMAKE_CXX_COMPILER_LAUNCHER ccache ) endif() -option(ENABLE_CSG "Build with CSG support" OFF) - # Download automatically, you can also just copy the conan.cmake file if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake") message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan") -- GitLab From 7598ee3b41340a9f0242991ad82c20d283c832b3 Mon Sep 17 00:00:00 2001 From: Mark Meredith Date: Tue, 26 May 2020 08:30:09 -0400 Subject: [PATCH 7/7] More cleanup --- CMakeLists.txt | 6 ++++-- src/csg/CMakeLists.txt | 5 ----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e0fa82..f6798e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,9 @@ include(Catch) add_subdirectory(src/csg) -target_include_directories(csg PRIVATE - ${CONAN_INCLUDE_DIRS_PEGTL}) +target_include_directories(csg + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ${CONAN_INCLUDE_DIRS_PEGTL} + ) target_compile_features(csg PRIVATE cxx_std_17) diff --git a/src/csg/CMakeLists.txt b/src/csg/CMakeLists.txt index 0ef27ea..52452cc 100644 --- a/src/csg/CMakeLists.txt +++ b/src/csg/CMakeLists.txt @@ -9,11 +9,6 @@ add_library(csg parser.cpp ) -target_include_directories(csg - PUBLIC ${CMAKE_SOURCE_DIR}/include - PRIVATE ${CMAKE_SOURCE_DIR}/src - ) - target_link_libraries(csg PRIVATE stdc++fs CONAN_PKG::cgal -- GitLab