diff --git a/.github/workflows/test-linux.yml b/.github/workflows/test-linux.yml index 4b3b799c..cb29f35e 100644 --- a/.github/workflows/test-linux.yml +++ b/.github/workflows/test-linux.yml @@ -20,16 +20,13 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Cache Cargo - uses: actions/cache@v3 + - name: Setup pg_validate_extupgrade + uses: baptiste0928/cargo-install@v3 with: - path: ~/.cargo - key: ${{ runner.os }}-cargo-2024 + crate: pg_validate_extupgrade + git: https://github.com/rjuju/pg_validate_extupgrade - - name: Install pg_validate_extupgrade - run: cargo install --locked --git https://github.com/rjuju/pg_validate_extupgrade.git - - - name: Setup PostgreSQL ${{ matrix.pg }} + - name: Setup PostgreSQL run: | sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -p -i -v ${{ matrix.pg }} sudo apt-get -y install postgresql-${{ matrix.pg }}-postgis-3 diff --git a/.github/workflows/test-macos.yml b/.github/workflows/test-macos.yml index 738074ac..6522506a 100644 --- a/.github/workflows/test-macos.yml +++ b/.github/workflows/test-macos.yml @@ -11,27 +11,40 @@ jobs: strategy: matrix: config: [Release, Debug] - pg: [14] + pg: [17, 16, 15, 14, 13] - runs-on: macos-14 + runs-on: macos-13 + + name: macos 🐘${{ matrix.pg }} (${{ matrix.config }}) steps: - uses: actions/checkout@v3 - # - name: Cache Cargo - # uses: actions/cache@v3 - # with: - # path: ~/.cargo - # key: ${{ runner.os }}-cargo-2023 + - name: Setup pg_validate_extupgrade + uses: baptiste0928/cargo-install@v3 + with: + crate: pg_validate_extupgrade + git: https://github.com/rjuju/pg_validate_extupgrade + + - name: Setup PostgreSQL + run: | + brew install postgresql@${{ matrix.pg }} + brew unlink postgresql@${{ matrix.pg }} + brew link --overwrite postgresql@${{ matrix.pg }} + brew services run postgresql@${{ matrix.pg }} - # - name: Install pg_validate_extupgrade - # run: cargo install --locked --git https://github.com/rjuju/pg_validate_extupgrade.git + - name: Setup PostGIS + run: brew install postgis + if: ${{ matrix.pg == 17 || matrix.pg == 14 }} - - name: Install PostgreSQL and PostGIS - run: brew install postgresql@${{ matrix.pg }} postgis + - name: Fix gettext linkage for PostgreSQL >= 15 + run: | + brew unlink gettext && brew link --overwrite --force gettext + ls /usr/local/lib | grep libintl + if: ${{ matrix.pg >= 15 }} - name: Generate - run: cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.config }} + run: VERBOSE=true cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DCMAKE_CXX_FLAGS=-I/usr/local/include -DCMAKE_PREFIX_PATH=/opt/homebrew - name: Build run: cmake --build build --config ${{ matrix.config }} @@ -39,8 +52,8 @@ jobs: - name: Install run: sudo cmake --install build --component h3-pg --config ${{ matrix.config }} - - name: Prepare PostgreSQL - run: brew services start postgresql@${{ matrix.pg }} + - name: Create test database (for pg_validate_extupgrade) + run: createdb runner - name: Test run: ctest --test-dir build --output-on-failure --build-config ${{ matrix.config }} @@ -48,3 +61,7 @@ jobs: - name: Print regression diffs if: ${{ failure() }} run: cat build/*/regression.diffs + + env: # something wrong with gettext + CXXFLAGS: -I/usr/local/include + CPPFLAGS: -I/usr/local/include diff --git a/cmake/AddPostgreSQLExtension.cmake b/cmake/AddPostgreSQLExtension.cmake index e316ad39..a9a8cf77 100644 --- a/cmake/AddPostgreSQLExtension.cmake +++ b/cmake/AddPostgreSQLExtension.cmake @@ -31,9 +31,16 @@ function(PostgreSQL_add_extension LIBRARY_NAME) # Link extension to PostgreSQL target_link_libraries(${LIBRARY_NAME} PRIVATE PostgreSQL::PostgreSQL) - # Fix apple missing symbols + # Handle macOS specifics if(APPLE) + # Fix apple missing symbols set_target_properties(${LIBRARY_NAME} PROPERTIES LINK_FLAGS ${PostgreSQL_LINK_FLAGS}) + + # Since Postgres 16, the shared library extension on macOS is `dylib`, not `so`. + # Ref https://github.com/postgres/postgres/commit/b55f62abb2c2e07dfae99e19a2b3d7ca9e58dc1a + if (${PostgreSQL_VERSION_MAJOR} VERSION_GREATER_EQUAL "16") + set_target_properties (${LIBRARY_NAME} PROPERTIES SUFFIX ".dylib") + endif() endif() # Final touches on output file @@ -44,12 +51,6 @@ function(PostgreSQL_add_extension LIBRARY_NAME) PREFIX "" # Avoid lib* prefix on output file ) - # Since Postgres 16, the shared library extension on macOS is `dylib`, not `so`. - # Ref https://github.com/postgres/postgres/commit/b55f62abb2c2e07dfae99e19a2b3d7ca9e58dc1a - if (APPLE AND ${PostgreSQL_VERSION_MAJOR} VERSION_GREATER_EQUAL "16") - set_target_properties (${LIBRARY_NAME} PROPERTIES SUFFIX ".dylib") - endif() - # Install .so/.dll to pkglib-dir install( TARGETS ${LIBRARY_NAME} diff --git a/cmake/FindPostgreSQL.cmake b/cmake/FindPostgreSQL.cmake index 6d5b30e8..2144e657 100644 --- a/cmake/FindPostgreSQL.cmake +++ b/cmake/FindPostgreSQL.cmake @@ -39,6 +39,7 @@ execute_process(COMMAND ${PostgreSQL_CONFIG} --libdir OUTPUT_VARIABLE execute_process(COMMAND ${PostgreSQL_CONFIG} --pkglibdir OUTPUT_VARIABLE PostgreSQL_PKG_LIBRARY_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) # @TODO: Figure out if we need _INCLUDE_DIR and/or _PKG_INCLUDE_DIR +set(WIP_APPLE_INCLUDE_DIR "/usr/local/include") # Create include dirs list list(APPEND PostgreSQL_INCLUDE_DIRS "${PostgreSQL_INCLUDE_DIR}" "${PostgreSQL_PKG_INCLUDE_DIR}" "${PostgreSQL_SERVER_INCLUDE_DIR}") diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 81837359..458c2fd9 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -5,6 +5,6 @@ target_link_libraries(postgresql_h3_shared PRIVATE PostgreSQL::PostgreSQL ) target_include_directories(postgresql_h3_shared - INTERFACE ./ + INTERFACE ./ /usr/local/include ) set_target_properties(postgresql_h3_shared PROPERTIES POSITION_INDEPENDENT_CODE True)