@@ -46,35 +46,37 @@ tbbLibraryPath <- function(name = NULL) {
46
46
47
47
tbbCxxFlags <- function () {
48
48
49
- flags <- character ()
49
+ if (! TBB_ENABLED )
50
+ return (" -DRCPP_PARALLEL_USE_TBB=0" )
50
51
51
- # opt-in to TBB on Windows
52
- if (is_windows()) {
53
- enabled <- if (TBB_ENABLED ) " 1" else " 0"
54
- flags <- c(flags , sprintf(" -DRCPP_PARALLEL_USE_TBB=%s" , enabled ))
52
+ flags <- c(" -DRCPP_PARALLEL_USE_TBB=1" )
53
+
54
+ # TBB does not have assembly code for Windows ARM64
55
+ # so we need to use compiler builtins
56
+ if (TBB_ENABLED && is_windows()) {
55
57
if (R.version $ arch == " aarch64" ) {
56
- # TBB does not have assembly code for Windows ARM64
57
- # so we need to use compiler builtins
58
58
flags <- c(flags , " -DTBB_USE_GCC_BUILTINS" )
59
59
}
60
60
}
61
61
62
62
# if TBB_INC is set, apply those library paths
63
63
tbbInc <- Sys.getenv(" TBB_INC" , unset = TBB_INC )
64
64
if (! file.exists(tbbInc )) {
65
- tbbInc <- system.file(" include" , package = " Rcpp " )
65
+ tbbInc <- system.file(" include" , package = " RcppParallel " )
66
66
}
67
67
68
- if (nzchar(tbbInc )) {
69
-
70
- # add include path
71
- flags <- c(flags , paste0(" -I" , asBuildPath(tbbInc )))
68
+ # add include path
69
+ if (nzchar(tbbInc ) && file.exists(tbbInc )) {
72
70
73
- # prefer new interface if version.h exists
71
+ # prefer new interface if version.h exists -- we keep this
72
+ # for compatibility with packages like StanHeaders, rstan
74
73
versionPath <- file.path(tbbInc , " tbb/version.h" )
75
74
if (file.exists(versionPath ))
76
75
flags <- c(flags , " -DTBB_INTERFACE_NEW" )
77
76
77
+ # now add the include path
78
+ flags <- c(flags , paste0(" -I" , asBuildPath(tbbInc )))
79
+
78
80
}
79
81
80
82
# return flags as string
0 commit comments