File tree Expand file tree Collapse file tree 2 files changed +50
-3
lines changed Expand file tree Collapse file tree 2 files changed +50
-3
lines changed Original file line number Diff line number Diff line change 11
2+ CMAKE = @CMAKE@
23R = @R@
34
45TBB_LIB = @TBB_LIB@
@@ -19,7 +20,10 @@ $(OBJECTS): tbb
1920# NOTE: TBB libraries are installed via install.libs.R.
2021# However, we need to copy headers here so that they are visible during compilation.
2122tbb: tbb-clean
22- @TBB_LIB="$(TBB_LIB)" TBB_INC="$(TBB_INC)" TBB_NAME="$(TBB_NAME)" @R@ -s -f install.libs.R --args build
23+ TBB_LIB="$(TBB_LIB)" TBB_INC="$(TBB_INC)" TBB_NAME="$(TBB_NAME)" \
24+ CC="$(CC)" CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" \
25+ CXX="$(CXX)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" \
26+ CMAKE="$(CMAKE)" "@R@" -s -f install.libs.R --args build
2327
2428# NOTE: we do not want to clean ../inst/lib or ../inst/libs here,
2529# as we may be writing to those locations in multiarch builds
Original file line number Diff line number Diff line change @@ -220,7 +220,6 @@ pkgLibs <- if (!is.na(tbbLib)) {
220220 " -l$(TBB_NAME)" ,
221221 " -ltbbmalloc"
222222 )
223-
224223} else {
225224
226225 c(
@@ -230,8 +229,52 @@ pkgLibs <- if (!is.na(tbbLib)) {
230229 )
231230
232231}
233-
232+
234233define(PKG_LIBS = paste(pkgLibs , collapse = " " ))
234+
235+ # if we're going to build tbb from sources, check for cmake
236+ define(CMAKE = " " )
237+ if (is.na(tbbLib )) {
238+
239+ cmake <- local({
240+
241+ # check for envvar
242+ cmake <- Sys.getenv(" CMAKE" , unset = NA )
243+ if (! is.na(cmake ))
244+ return (cmake )
245+
246+ # check for path
247+ cmake <- Sys.which(" cmake" )
248+ if (nzchar(cmake ))
249+ return (cmake )
250+
251+ # check for macOS cmake
252+ cmake <- " /Applications/CMake.app/Contents/bin/cmake"
253+ if (file.exists(cmake ))
254+ return (cmake )
255+
256+ stop(" cmake was not found" )
257+
258+ })
259+
260+ # make sure we have an appropriate version of cmake installed
261+ output <- system(" cmake --version" , intern = TRUE )[[1L ]]
262+ cmakeVersion <- numeric_version(sub(" cmake version " , " " , output ))
263+ if (cmakeVersion < " 3.5" ) {
264+ stop(" error: RcppParallel requires cmake (>= 3.6); you have " , cmakeVersion )
265+ }
266+
267+ define(CMAKE = cmake )
268+
269+ }
270+
271+ # set TBB_RPATH
272+ if (! is.na(tbbLib )) {
273+ define(TBB_RPATH = sprintf(" -Wl,-rpath,%s" , shQuote(tbbLib )))
274+ } else {
275+ define(TBB_RPATH = " " )
276+ }
277+
235278
236279# now, set up PKG_CPPFLAGS
237280if (! is.na(tbbLib )) {
You can’t perform that action at this time.
0 commit comments