From bd5f565d99091929928ee138b21cefcfa19df0f4 Mon Sep 17 00:00:00 2001 From: Mark Meredith Date: Tue, 26 May 2020 13:11:08 +0000 Subject: [PATCH] Reorganize functions --- .gitlab-ci.yml | 2 +- CMakeLists.txt | 8 ++++---- {src/csg => include}/csg.hpp | 0 {src/inputs => include}/solver.hpp | 2 +- meson.build | 14 +------------- src/csg/CMakeLists.txt | 15 ++++++--------- 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 | 12 ++++++------ src/csg/tests/levelset/extrude.t.cpp | 2 +- src/csg/tests/levelset/transform.t.cpp | 2 +- src/csg/tests/meson.build | 6 +++--- .../{parser/main.cpp => unit_tests_csg.main.cpp} | 0 ...rix_functions.hpp => csg_matrix_functions.hpp} | 0 src/{csg/impl => }/csg_types.hpp | 2 +- src/inputs/meson.build | 10 ++++++++++ src/{main.cpp => inputs/mfix-parser.main.cpp} | 0 src/inputs/tests/meson.build | 2 +- src/inputs/tests/solver.t.cpp | 2 +- .../{main.cpp => unit_tests_inputs.main.cpp} | 0 src/{inputs => }/solver_impl.hpp | 0 src/{inputs/inputs.hpp => solver_inputs.hpp} | 0 26 files changed, 45 insertions(+), 49 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/tests/{parser/main.cpp => unit_tests_csg.main.cpp} (100%) rename src/{csg/impl/matrix_functions.hpp => csg_matrix_functions.hpp} (100%) rename src/{csg/impl => }/csg_types.hpp (99%) rename src/{main.cpp => inputs/mfix-parser.main.cpp} (100%) rename src/inputs/tests/{main.cpp => unit_tests_inputs.main.cpp} (100%) rename src/{inputs => }/solver_impl.hpp (100%) rename src/{inputs/inputs.hpp => solver_inputs.hpp} (100%) 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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d0c5ce..f6798e3 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") @@ -37,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/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..a2fbacd 100644 --- a/meson.build +++ b/meson.build @@ -8,19 +8,7 @@ pegtl = dependency('pegtl', method: 'pkg-config') catch2 = dependency('catch2', method: 'pkg-config') cgal = dependency('cgal', method: 'pkg-config') -parser_inc = include_directories( - 'src/csg', - 'src/csg/impl', - 'src/inputs') +parser_inc = include_directories('include', 'src') 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..52452cc 100644 --- a/src/csg/CMakeLists.txt +++ b/src/csg/CMakeLists.txt @@ -1,17 +1,14 @@ ################################################################################ # CSG Parser ################################################################################ -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 +add_library(csg + csg.cpp + levelset_2d.cpp + levelset_3d.cpp + matrix_functions.cpp + parser.cpp ) -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..7ba26c7 100644 --- a/src/csg/tests/CMakeLists.txt +++ b/src/csg/tests/CMakeLists.txt @@ -4,21 +4,21 @@ 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 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/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/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/inputs/meson.build b/src/inputs/meson.build index 3e993c7..ecc7383 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', + 'mfix-parser.main.cpp', + include_directories: parser_inc, + link_with: [ + lib_csg_parser, + lib_inputs_parser, + ]) + subdir('tests') diff --git a/src/main.cpp b/src/inputs/mfix-parser.main.cpp similarity index 100% rename from src/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/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/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 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