Skip to content

Commit

Permalink
Merge branch 'vcpkg' into 'master'
Browse files Browse the repository at this point in the history
Add github actions for vcpkg and disable Alpha Shapes on MSVC

See merge request sfcgal/SFCGAL!298
  • Loading branch information
lbartoletti committed Dec 15, 2023
2 parents cefb8f3 + 3394b4c commit d60dc13
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/vcpkg.yml
Original file line number Diff line number Diff line change
@@ -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

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ test/unit/unit-test-SFCGAL
*/.DS_Store

build
/.vs
/out/install/x64-Debug/include/SFCGAL
/CMakeSettings.json
5 changes: 5 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})
Expand Down
4 changes: 4 additions & 0 deletions src/capi/sfcgal_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
#include <SFCGAL/io/wkb.h>
#include <SFCGAL/io/wkt.h>

#if !_MSC_VER
#include <SFCGAL/algorithm/alphaShapes.h>
#endif
#include <SFCGAL/algorithm/area.h>
#include <SFCGAL/algorithm/convexHull.h>
#include <SFCGAL/algorithm/covers.h>
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/capi/sfcgal_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions test/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down

0 comments on commit d60dc13

Please sign in to comment.