Skip to content

Commit

Permalink
Windows: use poppler from Rtools if found
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroen committed Feb 7, 2025
1 parent f786f24 commit b6c6f97
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ jobs:
config:
- {os: macOS-latest, r: 'release'}
- {os: windows-latest, r: 'devel'}
- {os: windows-latest, r: 'release'}
- {os: windows-latest, r: '4.4'}
- {os: windows-latest, r: '4.3'}
- {os: windows-latest, r: '4.2'}
- {os: windows-latest, r: '4.1'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
Expand Down
42 changes: 25 additions & 17 deletions src/Makevars.win
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
POPPLERDATA=share/poppler
RWINLIB=../windows/poppler
PKG_CXXFLAGS=-Dpoppler_cpp_EXPORTS -DBUNDLE_POPPLER_DATA
PKG_CPPFLAGS=-I$(RWINLIB)/include/poppler/cpp \
-I$(RWINLIB)/include/poppler \
-DSTRICT_R_HEADERS -DR_NO_REMAP
PKG_CONFIG_NAME = poppler-cpp
PKG_CONFIG ?= $(BINPREF)pkg-config
PKG_CXXFLAGS = -Dpoppler_cpp_EXPORTS -DBUNDLE_POPPLER_DATA -DSTRICT_R_HEADERS -DR_NO_REMAP
PKG_LIBS := $(shell $(PKG_CONFIG) --libs $(PKG_CONFIG_NAME))

PKG_LIBS= \
-L$(RWINLIB)/lib${subst gcc,,${COMPILED_BY}}${R_ARCH} \
-L$(RWINLIB)/lib \
-lpoppler-cpp -lpoppler -llcms2 -ljpeg -lpng16 -ltiff -lopenjp2 \
-lfreetype -lfreetype -lbz2 -liconv -lz
ifneq ($(PKG_LIBS),)
$(info using $(PKG_CONFIG_NAME) from Rtools)
PKG_CPPFLAGS := $(shell $(PKG_CONFIG) --cflags $(PKG_CONFIG_NAME))
POPPLERDATA := $(shell pkg-config --variable=poppler_datadir poppler-data)
else
RWINLIB = ../windows/poppler
PKG_CPPFLAGS = -I$(RWINLIB)/include/poppler/cpp -I$(RWINLIB)/include/poppler
PKG_LIBS = -L$(RWINLIB)/lib${subst gcc,,${COMPILED_BY}}${R_ARCH} -L$(RWINLIB)/lib \
-lpoppler-cpp -lpoppler -llcms2 -ljpeg -lpng16 -ltiff -lopenjp2 -lfreetype -lfreetype -lbz2 -liconv -lz
POPPLERDATA = $(RWINLIB)/share/poppler
endif

all: clean winlibs
all: $(SHLIB) $(copydata)

clean:
rm -f $(OBJECTS) $(SHLIB)
$(OBJECTS): $(RWINLIB)

winlibs:
$(RWINLIB):
"${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" "../tools/winlibs.R"

copydata:
rm -Rf ../inst/share && mkdir -p ../inst/share
cp -Rf $(RWINLIB)/$(POPPLERDATA) ../inst/share/poppler
cp -Rf $(POPPLERDATA) ../inst/share/poppler

clean:
rm -f $(SHLIB) $(OBJECTS)


.PHONY: all winlibs clean

0 comments on commit b6c6f97

Please sign in to comment.