diff --git a/.github/workflows/test-macos.yml b/.github/workflows/test-macos.yml index 738074ac..1d5b732c 100644 --- a/.github/workflows/test-macos.yml +++ b/.github/workflows/test-macos.yml @@ -11,10 +11,12 @@ jobs: strategy: matrix: config: [Release, Debug] - pg: [14] + pg: [16, 15, 14, 13, 12, 11] runs-on: macos-14 + name: macos 🐘${{ matrix.pg }} (${{ matrix.config }}) + steps: - uses: actions/checkout@v3 @@ -27,11 +29,18 @@ jobs: # - name: Install pg_validate_extupgrade # run: cargo install --locked --git https://github.com/rjuju/pg_validate_extupgrade.git - - name: Install PostgreSQL and PostGIS - run: brew install postgresql@${{ matrix.pg }} postgis + - name: Install (& link) PostgreSQL + run: | + brew install postgresql@${{ matrix.pg }} + brew link postgresql@${{ matrix.pg }} + # brew link --force gettext #building pg>=15 fails without this + + # - name: Fix gettext linkage for PostgreSQL >= 15 + # if: ${{ matrix.pg >= 15 }} + # run: brew unlink gettext && brew link -n --force gettext - 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 - name: Build run: cmake --build build --config ${{ matrix.config }} @@ -48,3 +57,53 @@ 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 + + # ----- PostGIS tests ----- + # I postgis on homebrew is pg@14 only, so I'm keeping this test separate + macos-12-postgis: + strategy: + matrix: + config: [Release, Debug] + runs-on: macos-12 + + name: macos 🐘14 w/ postgis@3 (homebrew) + + steps: + - uses: actions/checkout@v3 + + - name: Cache Cargo + uses: actions/cache@v3 + with: + path: ~/.cargo + key: ${{ runner.os }}-cargo-2023 + + - name: Install pg_validate_extupgrade + run: cargo install --locked --git https://github.com/rjuju/pg_validate_extupgrade.git + + - name: Install PostGIS + run: brew install postgis + + - name: Generate + run: cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.config }} + + - name: Build + run: cmake --build build --config ${{ matrix.config }} + + - name: Install + run: sudo cmake --install build --component h3-pg --config ${{ matrix.config }} + + - name: Prepare PostgreSQL + run: | + pg_ctl start -D /usr/local/var/postgresql@14 --wait + createdb runner + + - name: Test + run: ctest --test-dir build --output-on-failure --build-config ${{ matrix.config }} + + - name: Print regression diffs + if: ${{ failure() }} + run: cat build/*/regression.diffs 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..e5d803a6 100644 --- a/cmake/FindPostgreSQL.cmake +++ b/cmake/FindPostgreSQL.cmake @@ -4,7 +4,11 @@ # https://www.postgresql.org/support/versioning/ set(PostgreSQL_SUPPORTED_VERSIONS ${PostgreSQL_ADDITIONAL_VERSIONS} +<<<<<<< HEAD "17" "16" "15" "14" "13") +======= + "16" "15" "14" "13" "12" "11") +>>>>>>> 1880bf9 (libintl troubles) # Use `FIND_VERSION` to locate specific version of pg_config, or fallback to known versions if(PostgreSQL_FIND_VERSION) @@ -41,7 +45,7 @@ execute_process(COMMAND ${PostgreSQL_CONFIG} --pkglibdir OUTPUT_VARIABLE # @TODO: Figure out if we need _INCLUDE_DIR and/or _PKG_INCLUDE_DIR # Create include dirs list -list(APPEND PostgreSQL_INCLUDE_DIRS "${PostgreSQL_INCLUDE_DIR}" "${PostgreSQL_PKG_INCLUDE_DIR}" "${PostgreSQL_SERVER_INCLUDE_DIR}") +list(APPEND PostgreSQL_INCLUDE_DIRS "${PostgreSQL_INCLUDE_DIR}" "/usr/local/include" "${PostgreSQL_PKG_INCLUDE_DIR}" "${PostgreSQL_SERVER_INCLUDE_DIR}") list(APPEND PostgreSQL_LIBRARY_DIRS "${PostgreSQL_LIBRARY_DIR}") # Set library to search for (which is different on WIN32) 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)