Skip to content

Commit

Permalink
Remove dependency on libpng
Browse files Browse the repository at this point in the history
There is an import of `png.h` that turns out to not be used.
I have patched to remove this and SQuadGen now builds and runs
without requiring `libpng`.
  • Loading branch information
xylar committed May 12, 2024
1 parent 5ac82c8 commit be575bf
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
20 changes: 20 additions & 0 deletions recipes/squadgen/0001-remove-png-h.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff -ruN squadgen-1.2.1/src/SQuadGen.cpp squadgen-1.2.1-patch/src/SQuadGen.cpp
--- squadgen-1.2.1/src/SQuadGen.cpp 2024-05-11 15:31:02.000000000 -0600
+++ squadgen-1.2.1-patch/src/SQuadGen.cpp 2024-05-12 11:20:44.022644614 -0600
@@ -14,7 +14,6 @@
/// or implied warranty.
/// </remarks>

-#include <png.h>
#include "netcdfcpp.h"

#include <string>
@@ -195,7 +194,7 @@
if ((nRefinementLevel > 0) &&
((strRefineRect != "") || (strRefineFile != "") || (fLoadCSRefinementMap))
) {
- int nCommandLineCount =
+ int nCommandLineCount =
((strRefineRect != "")?(1):(0))
+ ((strRefineFile != "")?(1):(0))
+ (fLoadCSRefinementMap?(1):(0));
7 changes: 1 addition & 6 deletions recipes/squadgen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ find_package(NETCDF REQUIRED)
message(STATUS "netcdf_c_incdir=${netcdf_c_incdir}")
message(STATUS "netcdf_c_libs=${netcdf_c_libs}")

find_package(PNG REQUIRED)
message(STATUS "PNG_INCLUDE_DIR=${PNG_INCLUDE_DIR}")
message(STATUS "PNG_LIBRARIES=${PNG_LIBRARIES}")

SET(SRC ${CMAKE_SOURCE_DIR}/src)
set(SQUADGEN_SRC ${SRC}/SQuadGen.cpp
${SRC}/GridElements.cpp
Expand All @@ -34,11 +30,10 @@ set(SQUADGEN_SRC ${SRC}/SQuadGen.cpp
${SRC}/netcdf.cpp
${SRC}/ncvalues.cpp)

include_directories(${PNG_INCLUDE_DIR})
include_directories(${netcdf_c_incdir})

include_directories(${SRC})
add_executable(SQuadGen ${SQUADGEN_SRC})
target_link_libraries(SQuadGen PUBLIC ${netcdf_c_libs} ${PNG_LIBRARIES})
target_link_libraries(SQuadGen ${netcdf_c_libs})

install(TARGETS SQuadGen DESTINATION bin)
3 changes: 3 additions & 0 deletions recipes/squadgen/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ set -e

cp -r ${RECIPE_DIR}/cmake ${RECIPE_DIR}/cmake_macros ${RECIPE_DIR}/CMakeLists.txt .

# remove static libpng and zlib to prevent static linking
rm -rf ${PREFIX}/lib/libpng.a ${PREFIX}/lib/libz.a

rm -rf build
mkdir build
cd build
Expand Down
5 changes: 2 additions & 3 deletions recipes/squadgen/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ package:
source:
url: https://github.com/ClimateGlobalChange/squadgen/archive/refs/tags/v{{ version }}.tar.gz
sha256: a39f9f467563e796c1b0a53c7bf7d046f50110a030d92350754a60ada4eda053
patches:
- 0001-remove-png-h.patch

build:
skip: true # [not linux]
number: 0
ignore_run_exports:
- libpng

requirements:
build:
Expand All @@ -25,7 +25,6 @@ requirements:
host:
- libnetcdf
- libnetcdf * nompi_*
- libpng

test:
files:
Expand Down

0 comments on commit be575bf

Please sign in to comment.