Skip to content

don't patch the CMakeLists.txt by hard typing line code numbers when building NetCDF4 #42

@lazarusA

Description

@lazarusA

This should be more robust, otherwise updating to new versions is tricky!

log "Patching CMakeLists.txt to bypass CHECK_LIBRARY_EXISTS calls..."

# Apply CMakeLists.txt patches before CMake configuration
    log "Patching CMakeLists.txt to bypass CHECK_LIBRARY_EXISTS calls..."

    # Determine sed syntax for in-place editing
    if sed --version >/dev/null 2>&1; then
        # GNU sed (Linux)
        SED_INPLACE=(-i)
    else
        # BSD sed (macOS)
        SED_INPLACE=(-i '')
    fi

    # Comment out all CHECK_LIBRARY_EXISTS calls that cause issues in Emscripten
    sed "${SED_INPLACE[@]}" '933s/^/  # /' CMakeLists.txt || error_exit "Failed to patch CHECK_LIBRARY_EXISTS H5Pget_fapl_mpio"
    sed "${SED_INPLACE[@]}" '941s/^/  # /' CMakeLists.txt || error_exit "Failed to comment CHECK_LIBRARY_EXISTS H5Pset_all_coll_metadata_ops"
    sed "${SED_INPLACE[@]}" '950s/^/  # /' CMakeLists.txt || error_exit "Failed to comment CHECK_LIBRARY_EXISTS H5Dread_chunk"
    sed "${SED_INPLACE[@]}" '953s/^/  # /' CMakeLists.txt || error_exit "Failed to comment CHECK_LIBRARY_EXISTS H5Pset_fapl_ros3"

    # Set bypass variables for the features
    sed "${SED_INPLACE[@]}" '943s/SET(HDF5_HAS_COLL_METADATA_OPS ON)/SET(HDF5_HAS_COLL_METADATA_OPS OFF)/' CMakeLists.txt || error_exit "Failed to set HDF5_HAS_COLL_METADATA_OPS to OFF"
    sed "${SED_INPLACE[@]}" '950a\
    # Set HAS_READCHUNKS to OFF for Emscripten\
    SET(HAS_READCHUNKS OFF)' CMakeLists.txt || error_exit "Failed to set HAS_READCHUNKS"
    sed "${SED_INPLACE[@]}" '953a\
    # Set HAS_HDF5_ROS3 to OFF for Emscripten\
    SET(HAS_HDF5_ROS3 OFF)' CMakeLists.txt || error_exit "Failed to set HAS_HDF5_ROS3"

    log "CMakeLists.txt patches applied"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions