From e863671dca0426077d31eb65b9475f6decdb1010 Mon Sep 17 00:00:00 2001 From: Deepak Rangarajan Date: Fri, 22 May 2020 23:25:39 -0400 Subject: [PATCH 1/2] cleaner conan cmake --- CMakeLists.txt | 4 +--- src/csg/CMakeLists.txt | 5 ++--- src/csg/impl/csg.cpp | 12 ++++++++++++ src/csg/tests/CMakeLists.txt | 3 ++- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 511dcc0..4d0c5ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,9 +30,7 @@ conan_cmake_run(REQUIRES catch2/2.12.1 cgal/5.0.2 pegtl/2.8.1@taocpp/stable - BASIC_SETUP) - -list(APPEND CMAKE_MODULE_PATH "${CONAN_LIB_DIRS_CATCH2}/cmake/Catch2") + BASIC_SETUP CMAKE_TARGETS) include(CTest) include(Catch) diff --git a/src/csg/CMakeLists.txt b/src/csg/CMakeLists.txt index 68d417d..5816252 100644 --- a/src/csg/CMakeLists.txt +++ b/src/csg/CMakeLists.txt @@ -14,8 +14,7 @@ target_sources(csg PRIVATE target_include_directories(csg INTERFACE ${CMAKE_SOURCE_DIR}) target_link_libraries(csg PRIVATE stdc++fs - ${CONAN_PKG_LIBS_CGAL} - ${CONAN_PKG_LIBS_MPIR} + CONAN_PKG::cgal ) -add_subdirectory(tests) \ No newline at end of file +add_subdirectory(tests) diff --git a/src/csg/impl/csg.cpp b/src/csg/impl/csg.cpp index 80fa8dd..eb61ac1 100644 --- a/src/csg/impl/csg.cpp +++ b/src/csg/impl/csg.cpp @@ -6,6 +6,12 @@ #include "csg_types.hpp" +#include +#include +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef K::Point_2 Point; +typedef CGAL::Polygon_2 Polygon_2; + namespace { const std::string csg_ext = ".csg"; @@ -15,6 +21,12 @@ bool has_ext(std::string filename, std::string extension) { } std::optional read_csg(std::string geom_file) { + // Demonstrate use of CGAL + Point points[] = {Point(0, 0), Point(5.1, 0), Point(1, 1), Point(0.5, 6)}; + Polygon_2 pgn(points, points + 4); + std::cout << "The polygon is " << (pgn.is_simple() ? "" : "not ") << "simple." << std::endl; + std::cout << "The polygon is " << (pgn.is_convex() ? "" : "not ") << "convex." << std::endl; + if (!has_ext(geom_file, csg_ext)) { std::cout << "Filename: " << geom_file << " must has extension .csg" << std::endl; diff --git a/src/csg/tests/CMakeLists.txt b/src/csg/tests/CMakeLists.txt index e7282df..5476ad7 100644 --- a/src/csg/tests/CMakeLists.txt +++ b/src/csg/tests/CMakeLists.txt @@ -19,10 +19,11 @@ add_executable(unit_tests_csg EXCLUDE_FROM_ALL target_include_directories(unit_tests_csg PRIVATE .. ../impl + ${CONAN_INCLUDE_DIRS_CATCH2} ) target_link_libraries(unit_tests_csg csg) add_test(NAME run_csg_unittests COMMAND ${CMAKE_COMMAND} -E env ${CMAKE_BINARY_DIR}/bin/unit_tests_csg - ) \ No newline at end of file + ) -- GitLab From 0d2e9704af00b4b73008ea8f88f87849a676a494 Mon Sep 17 00:00:00 2001 From: Deepak Rangarajan Date: Fri, 22 May 2020 23:30:37 -0400 Subject: [PATCH 2/2] remove demo example --- src/csg/impl/csg.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/csg/impl/csg.cpp b/src/csg/impl/csg.cpp index eb61ac1..80fa8dd 100644 --- a/src/csg/impl/csg.cpp +++ b/src/csg/impl/csg.cpp @@ -6,12 +6,6 @@ #include "csg_types.hpp" -#include -#include -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef K::Point_2 Point; -typedef CGAL::Polygon_2 Polygon_2; - namespace { const std::string csg_ext = ".csg"; @@ -21,12 +15,6 @@ bool has_ext(std::string filename, std::string extension) { } std::optional read_csg(std::string geom_file) { - // Demonstrate use of CGAL - Point points[] = {Point(0, 0), Point(5.1, 0), Point(1, 1), Point(0.5, 6)}; - Polygon_2 pgn(points, points + 4); - std::cout << "The polygon is " << (pgn.is_simple() ? "" : "not ") << "simple." << std::endl; - std::cout << "The polygon is " << (pgn.is_convex() ? "" : "not ") << "convex." << std::endl; - if (!has_ext(geom_file, csg_ext)) { std::cout << "Filename: " << geom_file << " must has extension .csg" << std::endl; -- GitLab