From edec46e8c3fba475c8ac9f3d3be32fceb6c85c45 Mon Sep 17 00:00:00 2001 From: David Hummel <6109326+hummeltech@users.noreply.github.com> Date: Fri, 17 Mar 2023 10:15:18 -0700 Subject: [PATCH 1/9] Fixed check for '__cpp_lib_filesystem' always false until after '#include ' --- include/mapnik/filesystem.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/mapnik/filesystem.hpp b/include/mapnik/filesystem.hpp index 09a3731e4..90f81ec16 100644 --- a/include/mapnik/filesystem.hpp +++ b/include/mapnik/filesystem.hpp @@ -23,6 +23,8 @@ #ifndef MAPNIK_FILESYSTEM_HPP #define MAPNIK_FILESYSTEM_HPP +#include + #if defined(__cpp_lib_filesystem) && !defined(USE_BOOST_FILESYSTEM) #include #else From e4557c016f0b8c99a58a3b12f30c760c04d2a257 Mon Sep 17 00:00:00 2001 From: David Hummel <6109326+hummeltech@users.noreply.github.com> Date: Fri, 17 Mar 2023 10:31:30 -0700 Subject: [PATCH 2/9] Oops, it looks like does not exist until C++20 --- include/mapnik/filesystem.hpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/mapnik/filesystem.hpp b/include/mapnik/filesystem.hpp index 90f81ec16..10a275806 100644 --- a/include/mapnik/filesystem.hpp +++ b/include/mapnik/filesystem.hpp @@ -23,9 +23,7 @@ #ifndef MAPNIK_FILESYSTEM_HPP #define MAPNIK_FILESYSTEM_HPP -#include - -#if defined(__cpp_lib_filesystem) && !defined(USE_BOOST_FILESYSTEM) +#if (__cplusplus >= 201703L) && !defined(USE_BOOST_FILESYSTEM) #include #else #include // for absolute, exists, etc From 0e9996dde044a44dc4bd51e95837ceea24e3c9e2 Mon Sep 17 00:00:00 2001 From: David Hummel <6109326+hummeltech@users.noreply.github.com> Date: Fri, 17 Mar 2023 10:51:15 -0700 Subject: [PATCH 3/9] Add build & test for CXX_STANDARD=17 to GitHub Actions --- .github/workflows/build_and_test.yml | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index a9e9b7bbd..d28a67069 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -25,7 +25,12 @@ jobs: - uses: pre-commit/action@v3.0.0 buildAndTest: - name: Build and Test + name: >- + Build & Test + (${{ matrix.os }}) + (C++ ${{ matrix.cxx-standard }}) + ${{ matrix.memory-mapped == 'OFF' && '(USE_MEMORY_MAPPED_FILE=OFF)' || '' }} + ${{ matrix.static-build == 'OFF' && '(BUILD_SHARED_LIBS=OFF)' || '' }} needs: checkSource strategy: fail-fast: false @@ -33,11 +38,20 @@ jobs: os: [macos-latest, windows-latest, ubuntu-latest] memory-mapped: ["OFF", "ON"] static-build: ["OFF", "ON"] + cxx-standard: [14] include: - os: ubuntu-latest mono: mono - os: macos-latest mono: mono + - os: macos-latest + cxx-standard: 17 + mono: mono + - os: ubuntu-latest + cxx-standard: 17 + mono: mono + - os: windows-latest + cxx-standard: 17 runs-on: ${{ matrix.os }} @@ -78,12 +92,18 @@ jobs: string: ${{ runner.os }} - name: set lower case runner os - shell: "bash" + shell: bash run: | echo "PRESET=${{ steps.lc_platform.outputs.lowercase }}-ci" >>${GITHUB_ENV} - name: Configure CMake - run: cmake -DUSE_MEMORY_MAPPED_FILE=${{ matrix.memory-mapped }} -DBUILD_SHARED_LIBS=${{ matrix.static-build }} --preset ${{ env.PRESET }} + shell: bash + run: | + cmake \ + -DBUILD_SHARED_LIBS:BOOL=${{ matrix.static-build || 'ON' }} \ + -DCMAKE_CXX_STANDARD=${{ matrix.cxx-standard || '14' }} \ + -DUSE_MEMORY_MAPPED_FILE:BOOL=${{ matrix.memory-mapped || 'ON' }} \ + --preset ${{ env.PRESET }} - name: Build run: cmake --build --preset ${{ env.PRESET }} From f6cd056552f1ab3b90609bf95a3f5b12a76ee8b6 Mon Sep 17 00:00:00 2001 From: David Hummel <6109326+hummeltech@users.noreply.github.com> Date: Sat, 18 Mar 2023 09:06:34 -0700 Subject: [PATCH 4/9] Attempting to fix Windows build with C++17 --- CMakePresets.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakePresets.json b/CMakePresets.json index bc5a7c995..d037839a7 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -83,7 +83,8 @@ ], "cacheVariables": { "CMAKE_C_COMPILER": "cl", - "CMAKE_CXX_COMPILER": "cl" + "CMAKE_CXX_COMPILER": "cl", + "CMAKE_CXX_FLAGS": "/Zc:__cplusplus" } }, { From 9f88d4c3a481b0c82efa79c28bf898cbdcd380af Mon Sep 17 00:00:00 2001 From: Hummeltech <6109326+hummeltech@users.noreply.github.com> Date: Sun, 19 Mar 2023 09:38:27 -0700 Subject: [PATCH 5/9] Revert `CMAKE_CXX_FLAGS` msvc-cl change --- CMakePresets.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index d037839a7..bc5a7c995 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -83,8 +83,7 @@ ], "cacheVariables": { "CMAKE_C_COMPILER": "cl", - "CMAKE_CXX_COMPILER": "cl", - "CMAKE_CXX_FLAGS": "/Zc:__cplusplus" + "CMAKE_CXX_COMPILER": "cl" } }, { From 93e488a6cf1f1873a387b4ed6aa7efa224ddea7b Mon Sep 17 00:00:00 2001 From: Hummeltech <6109326+hummeltech@users.noreply.github.com> Date: Sun, 19 Mar 2023 09:39:13 -0700 Subject: [PATCH 6/9] Only test for `!defined(USE_BOOST_FILESYSTEM)` in `filesystem.hpp` --- include/mapnik/filesystem.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/mapnik/filesystem.hpp b/include/mapnik/filesystem.hpp index 10a275806..ff4b41a22 100644 --- a/include/mapnik/filesystem.hpp +++ b/include/mapnik/filesystem.hpp @@ -23,7 +23,7 @@ #ifndef MAPNIK_FILESYSTEM_HPP #define MAPNIK_FILESYSTEM_HPP -#if (__cplusplus >= 201703L) && !defined(USE_BOOST_FILESYSTEM) +#if !defined(USE_BOOST_FILESYSTEM) #include #else #include // for absolute, exists, etc @@ -31,7 +31,7 @@ #endif namespace mapnik { -#if defined(__cpp_lib_filesystem) && !defined(USE_BOOST_FILESYSTEM) +#if !defined(USE_BOOST_FILESYSTEM) namespace fs = std::filesystem; using error_code = std::error_code; #else From bb280a2815e13d86a5f9b0c7013ce0cc8d2bdca7 Mon Sep 17 00:00:00 2001 From: Hummeltech <6109326+hummeltech@users.noreply.github.com> Date: Sun, 19 Mar 2023 13:39:20 -0700 Subject: [PATCH 7/9] Fixing issues with USE_BOOST_FILESYSTEM definition --- CMakeLists.txt | 8 ++++---- include/mapnik/filesystem.hpp | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fe1243f03..3a5bee6b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,7 +49,7 @@ mapnik_option(USE_PROJ "adds proj support" ON) mapnik_option(USE_GRID_RENDERER "adds grid renderer" ON) mapnik_option(USE_SVG_RENDERER "adds svg renderer" ON) mapnik_option(USE_BIGINT "uses 64 bit instead of 32" ON) -mapnik_option(USE_BOOST_FILESYSTEM "use boost::filesytem even if `std::filesystem` is avaible (since c++17)" OFF) +mapnik_option(USE_BOOST_FILESYSTEM "use boost::filesytem even if `std::filesystem` is available (since c++17)" OFF) mapnik_option(USE_MEMORY_MAPPED_FILE "uses file cache" ON) mapnik_option(USE_MULTITHREADED "enables the multithreaded features (threadsafe)" ON) mapnik_option(USE_NO_ATEXIT "disable atexit" OFF) @@ -156,11 +156,11 @@ mapnik_find_threads() mapnik_find_package(ICU REQUIRED COMPONENTS uc i18n data) mapnik_find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS regex) -if(CMAKE_CXX_STANDARD LESS 17) - set(USE_BOOST_FILESYSTEM ON) +if(CMAKE_CXX_STANDARD VERSION_LESS 17) + set(USE_BOOST_FILESYSTEM ON CACHE BOOL "Use boost::filesystem" FORCE) endif() if(USE_BOOST_FILESYSTEM) -mapnik_find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS filesystem system) + mapnik_find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS filesystem system) endif() list(APPEND MAPNIK_COMPILE_DEFS BOOST_REGEX_HAS_ICU) diff --git a/include/mapnik/filesystem.hpp b/include/mapnik/filesystem.hpp index ff4b41a22..98ec5f8e2 100644 --- a/include/mapnik/filesystem.hpp +++ b/include/mapnik/filesystem.hpp @@ -23,20 +23,20 @@ #ifndef MAPNIK_FILESYSTEM_HPP #define MAPNIK_FILESYSTEM_HPP -#if !defined(USE_BOOST_FILESYSTEM) -#include -#else +#ifdef USE_BOOST_FILESYSTEM #include // for absolute, exists, etc #include // for path, operator/ +#else +#include #endif namespace mapnik { -#if !defined(USE_BOOST_FILESYSTEM) -namespace fs = std::filesystem; -using error_code = std::error_code; -#else +#ifdef USE_BOOST_FILESYSTEM namespace fs = boost::filesystem; using error_code = boost::system::error_code; +#else +namespace fs = std::filesystem; +using error_code = std::error_code; #endif } // namespace mapnik From bc09efb8f514f8fa221703616e12f364d58a0d47 Mon Sep 17 00:00:00 2001 From: Hummeltech <6109326+hummeltech@users.noreply.github.com> Date: Sun, 19 Mar 2023 14:01:14 -0700 Subject: [PATCH 8/9] Fixed typo USE_BOOST_FILESYSYTEM --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a5bee6b6..ffb86d4ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -266,7 +266,7 @@ if(USE_BIGINT) endif() if(USE_BOOST_FILESYSTEM) - list(APPEND MAPNIK_COMPILE_DEFS USE_BOOST_FILESYSYTEM) + list(APPEND MAPNIK_COMPILE_DEFS USE_BOOST_FILESYSTEM) list(APPEND MAPNIK_OPTIONAL_LIBS Boost::filesystem) endif() From 63f33eed4b8ce7fe012cf0154ea4af0a3814f767 Mon Sep 17 00:00:00 2001 From: Hummeltech <6109326+hummeltech@users.noreply.github.com> Date: Sun, 19 Mar 2023 14:05:58 -0700 Subject: [PATCH 9/9] List advanced cached variables in CI [skip ci] --- .github/workflows/build_and_test.yml | 1 + .github/workflows/release_linux.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index d28a67069..9184ab16b 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -103,6 +103,7 @@ jobs: -DBUILD_SHARED_LIBS:BOOL=${{ matrix.static-build || 'ON' }} \ -DCMAKE_CXX_STANDARD=${{ matrix.cxx-standard || '14' }} \ -DUSE_MEMORY_MAPPED_FILE:BOOL=${{ matrix.memory-mapped || 'ON' }} \ + -LA \ --preset ${{ env.PRESET }} - name: Build diff --git a/.github/workflows/release_linux.yml b/.github/workflows/release_linux.yml index b331f54e3..4db73dc3c 100644 --- a/.github/workflows/release_linux.yml +++ b/.github/workflows/release_linux.yml @@ -40,7 +40,7 @@ jobs: libboost-regex-dev - name: Configure CMake - run: cmake --preset ${{ env.PRESET }} + run: cmake -LA --preset ${{ env.PRESET }} - name: Build run: cmake --build --preset ${{ env.PRESET }}