diff --git a/.github/workflows/vcpkg.yml b/.github/workflows/vcpkg.yml new file mode 100644 index 00000000..4eb59fc1 --- /dev/null +++ b/.github/workflows/vcpkg.yml @@ -0,0 +1,50 @@ +name: Build with vcpkg on Windows + +on: + push: + branches-ignore: + - '*' + pull_request: + branches: + - '*' + +jobs: + build: + runs-on: windows-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Cache vcpkg dependencies + uses: actions/cache@v2 + with: + path: vcpkg_installed + key: vcpkg-${{ runner.os }}-${{ hashFiles('vcpkg/vcpkg-export.txt') }} + + - name: Install vcpkg + run: | + git clone https://github.com/microsoft/vcpkg.git + cd vcpkg + .\bootstrap-vcpkg.bat + + - name: Install vcpkg dependencies + run: | + cd vcpkg + .\vcpkg install cgal + + - name: Export vcpkg installed packages + run: | + cd vcpkg + .\vcpkg list > vcpkg-export.txt + + - name: Set up vcpkg environment + run: | + echo "::add-path::${RUNNER_WORKSPACE}\\vcpkg" + + - name: Build project with vcpkg + run: | + cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DSFCGAL_BUILD_TESTS=ON -DCMAKE_TOOLCHAIN_FILE=${RUNNER_WORKSPACE}\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake + cmake --build build + ctest -V --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 3b8df34a..f2c894ff 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 350bbf4c..19a92ca9 100644 --- a/src/capi/sfcgal_c.cpp +++ b/src/capi/sfcgal_c.cpp @@ -23,7 +23,9 @@ #include #include +#if _MSC_VER && !__INTEL_COMPILER #include +#endif #include #include #include @@ -1216,6 +1218,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) @@ -1258,7 +1261,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 5d386425..33532104 100644 --- a/src/capi/sfcgal_c.h +++ b/src/capi/sfcgal_c.h @@ -1022,6 +1022,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 @@ -1044,6 +1045,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})