From 3394b4c30809fd2bf69c4190ef831cb0b016530b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bartoletti?= Date: Mon, 11 Dec 2023 15:31:31 +0100 Subject: [PATCH] Add github actions for vcpkg and disable Alpha Shapes on MSVC I've added a new file on GitHub to assist in testing compilation with VCPKG. This addition aims to streamline the process and ensure smoother compatibility checks. Additionally, I disabled the alpha shapes algorithm on MSVC. This adjustment was necessary to address compatibility issues within the MSVC environment (https://github.com/CGAL/cgal/issues/7667). --- .github/workflows/vcpkg.yml | 33 +++++++++++++++++++++++++++++++++ .gitignore | 3 +++ src/CMakeLists.txt | 5 +++++ src/capi/sfcgal_c.cpp | 4 ++++ src/capi/sfcgal_c.h | 2 ++ test/unit/CMakeLists.txt | 5 +++++ 6 files changed, 52 insertions(+) create mode 100644 .github/workflows/vcpkg.yml diff --git a/.github/workflows/vcpkg.yml b/.github/workflows/vcpkg.yml new file mode 100644 index 00000000..e8446892 --- /dev/null +++ b/.github/workflows/vcpkg.yml @@ -0,0 +1,33 @@ +name: Build with vcpkg on Windows + +on: [push, pull_request] + +jobs: + msvc: + name: MSVC + runs-on: windows-latest + env: + VCPKG_VERSION: a42af01b72c28a8e1d7b48107b33e4f286a55ef6 + vcpkg_packages: cgal boost-program-options boost-timer boost-test + steps: + - uses: actions/checkout@v3 + + - name: Restore from cache and run vcpkg + uses: lukka/run-vcpkg@v7 + with: + vcpkgArguments: ${{env.vcpkg_packages}} + vcpkgDirectory: '${{ github.workspace }}\vcpkg' + appendedCacheKey: x64-windows + vcpkgGitCommitId: ${{ env.VCPKG_VERSION }} + vcpkgTriplet: x64-windows + + - name: Configure project with vcpkg/cmake + run: | + cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DSFCGAL_BUILD_TESTS=ON -DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}\vcpkg\scripts\buildsystems\vcpkg.cmake" + + - name: Build SFCGAL + run: cmake --build build --config Release + + # - name: Test SFCGAL + # run: ctest -VV --output-on-failure --test-dir build + diff --git a/.gitignore b/.gitignore index 01a4931c..060880e5 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,6 @@ test/unit/unit-test-SFCGAL */.DS_Store build +/.vs +/out/install/x64-Debug/include/SFCGAL +/CMakeSettings.json diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bd1fb386..efa256c4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,11 @@ file( GLOB_RECURSE SFCGAL_SOURCES "*.cpp" ) file( GLOB_RECURSE SFCGAL_HEADERS "*.h" ) +if (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC ) + list(REMOVE_ITEM SFCGAL_SOURCES ${CMAKE_SOURCE_DIR}/src/algorithm/alphaShapes.cpp) + list(REMOVE_ITEM SFCGAL_HEADERS ${CMAKE_SOURCE_DIR}/src/algorithm/alphaShapes.h) +endif() + file( GLOB_RECURSE SFCGAL_HEADERS_COPIED RELATIVE ${CMAKE_SOURCE_DIR}/src "*.h" ) add_custom_target(copy) foreach (header ${SFCGAL_HEADERS_COPIED}) diff --git a/src/capi/sfcgal_c.cpp b/src/capi/sfcgal_c.cpp index 9398e418..d61ea42e 100644 --- a/src/capi/sfcgal_c.cpp +++ b/src/capi/sfcgal_c.cpp @@ -24,7 +24,9 @@ #include #include +#if !_MSC_VER #include +#endif #include #include #include @@ -1279,6 +1281,7 @@ sfcgal_geometry_line_sub_string(const sfcgal_geometry_t *geom, double start, return ls.release(); } +#if !_MSC_VER extern "C" sfcgal_geometry_t * sfcgal_geometry_alpha_shapes(const sfcgal_geometry_t *geom, double alpha, bool allow_holes) @@ -1321,6 +1324,7 @@ sfcgal_geometry_optimal_alpha_shapes(const sfcgal_geometry_t *geom, return result.release(); } +#endif extern "C" sfcgal_geometry_t * sfcgal_y_monotone_partition_2(const sfcgal_geometry_t *geom) diff --git a/src/capi/sfcgal_c.h b/src/capi/sfcgal_c.h index 9d9678a8..c90d8229 100644 --- a/src/capi/sfcgal_c.h +++ b/src/capi/sfcgal_c.h @@ -1061,6 +1061,7 @@ SFCGAL_API sfcgal_geometry_t * sfcgal_geometry_line_sub_string(const sfcgal_geometry_t *geom, double start, double end); +#if !_MSC_VER /** * Returns the alpha shapes of geom * @pre isValid(geom) == true @@ -1083,6 +1084,7 @@ sfcgal_geometry_alpha_shapes(const sfcgal_geometry_t *geom, double alpha, SFCGAL_API sfcgal_geometry_t * sfcgal_geometry_optimal_alpha_shapes(const sfcgal_geometry_t *geom, bool allow_holes, size_t nb_components); +#endif /** * Returns the y monotone partition of a geometry (polygon without hole) diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index 60aa0373..63c86d52 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -7,6 +7,11 @@ if( SFCGAL_USE_STATIC_LIBS ) endif() file( GLOB_RECURSE SFCGAL_UNIT_TEST_SOURCES *.cpp ) + +if (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC ) + list(REMOVE_ITEM SFCGAL_UNIT_TEST_SOURCES ${CMAKE_SOURCE_DIR}/test/unit/SFCGAL/algorithm/AlphaShapesTest.cpp) +endif() + add_executable( unit-test-SFCGAL ${SFCGAL_UNIT_TEST_SOURCES} ) target_link_libraries( unit-test-SFCGAL SFCGAL) target_link_libraries(unit-test-SFCGAL ${CGAL_3RD_PARTY_LIBRARIES} ${Boost_LIBRARIES})