@@ -89,21 +89,56 @@ useBundledTbb <- function() {
8989 useTbbPreamble(" tbb/include" )
9090 dir.create(" tbb/build-tbb" , showWarnings = FALSE )
9191
92+ cmake <- Sys.getenv(" CMAKE" , unset = " cmake" )
93+ buildType <- Sys.getenv(" CMAKE_BUILD_TYPE" , unset = " Release" )
94+ verbose <- Sys.getenv(" VERBOSE" , unset = " 0" )
95+
96+ cmakeFlags <- c(
97+ sprintf(" -DCMAKE_BUILD_TYPE=%s" , buildType ),
98+ " -DTBB_TEST=0" ,
99+ " -DTBB_EXAMPLES=0" ,
100+ " -DTBB_STRICT=0" ,
101+ " .."
102+ )
103+
92104 writeLines(" *** configuring tbb" )
93- status <- system(" cd tbb/build-tbb; cmake -DTBB_TEST=0 -DTBB_EXAMPLES=0 -DTBB_STRICT=0 .. > build.log 2>&1" )
94- if (status != 0L ) {
95- system(" cat build.log" )
105+ owd <- setwd(" tbb/build-tbb" )
106+ output <- system2(cmake , shQuote(cmakeFlags ), stdout = TRUE , stderr = TRUE )
107+ status <- attr(output , " status" )
108+ if (is.numeric(status ) && status != 0L ) {
109+ writeLines(output )
96110 stop(" error configuring tbb (status code " , status , " )" )
111+ } else if (! identical(verbose , " 0" )) {
112+ writeLines(output )
97113 }
114+ setwd(owd )
98115
99116 writeLines(" *** building tbb" )
100- status <- system(" cd tbb/build-tbb; cmake --build . > build.log 2>&1" )
101- if (status != 0L ) {
102- system(" cat build.log" )
117+ owd <- setwd(" tbb/build-tbb" )
118+ output <- system2(cmake , c(" --build" , " ." , " --config" , " release" ), stdout = TRUE , stderr = TRUE )
119+ status <- attr(output , " status" )
120+ if (is.numeric(status ) && status != 0L ) {
121+ writeLines(output )
103122 stop(" error building tbb (status code " , status , " )" )
123+ } else if (! identical(verbose , " 0" )) {
124+ writeLines(output )
104125 }
126+ setwd(owd )
127+
128+ shlibPattern <- switch (
129+ Sys.info()[[" sysname" ]],
130+ Windows = " ^tbb.*\\ .dll$" ,
131+ Darwin = " ^libtbb.*\\ .dylib$" ,
132+ " ^libtbb.*\\ .so.*$"
133+ )
134+
135+ tbbFiles <- list.files(
136+ " tbb/build-tbb" ,
137+ pattern = shlibPattern ,
138+ recursive = TRUE ,
139+ full.names = TRUE
140+ )
105141
106- tbbFiles <- list.files(pattern = " ^libtbb\\ .(so|dylib)" , recursive = TRUE )
107142 tbbDir <- dirname(tbbFiles [[1L ]])
108143
109144 dir.create(" tbb/build" , showWarnings = FALSE )
@@ -123,6 +158,8 @@ args <- commandArgs(trailingOnly = TRUE)
123158if (identical(args , " build" )) {
124159 if (nzchar(tbbLib ) && nzchar(tbbInc )) {
125160 useSystemTbb(tbbLib , tbbInc )
161+ } else if (.Platform $ OS.type == " windows" ) {
162+ writeLines(" ** building RcppParallel without tbb backend" )
126163 } else {
127164 useBundledTbb()
128165 }
0 commit comments