|
1 | | -if (Sys.info()[["sysname"]] == "Windows" && getRversion() < "3.1.0") { |
2 | | - define( |
| 1 | + |
| 2 | +# Figure out the appropriate CXX prefix for the current |
| 3 | +# version of R + configuration. |
| 4 | +cxx <- NULL |
| 5 | +candidates <- c("CXX11", "CXX1X", "CXX") |
| 6 | +for (candidate in candidates) { |
| 7 | + config <- read_r_config(candidate, envir = NULL) |
| 8 | + value <- config[[candidate]] |
| 9 | + if (!is.null(value)) { |
| 10 | + cxx <- candidate |
| 11 | + break |
| 12 | + } |
| 13 | +} |
| 14 | + |
| 15 | +# define the set of flags appropriate to the current |
| 16 | +# configuration of R |
| 17 | +switch( |
| 18 | + cxx, |
| 19 | + |
| 20 | + CXX11 = define( |
3 | 21 | CC = "$(CC)", |
4 | | - CXX11 = "$(CXX)", |
5 | | - CXX11STD = "-std=c++0x", |
6 | | - CXX11PICFLAGS = "-fPIC" |
7 | | - ) |
8 | | -} else if (getRversion() < "3.4.0") { |
9 | | - define( |
| 22 | + CXX11 = "$(CXX11)", |
| 23 | + CXX11FLAGS = "$(CXX11FLAGS)", |
| 24 | + CXX11STD = "$(CXX11STD)", |
| 25 | + CXX11PICFLAGS = "$(CXX11PICFLAGS)" |
| 26 | + ), |
| 27 | + |
| 28 | + CXX1X = define( |
10 | 29 | CC = "$(CC)", |
11 | 30 | CXX11 = "$(CXX1X)", |
| 31 | + CXX11FLAGS = "$(CXX1XFLAGS)", |
12 | 32 | CXX11STD = "$(CXX1XSTD)", |
13 | 33 | CXX11PICFLAGS = "$(CXX1XPICFLAGS)" |
14 | | - ) |
15 | | -} else { |
16 | | - define( |
| 34 | + ), |
| 35 | + |
| 36 | + CXX = define( |
17 | 37 | CC = "$(CC)", |
18 | | - CXX11 = "$(CXX11)", |
19 | | - CXX11STD = "$(CXX11STD)", |
20 | | - CXX11PICFLAGS = "$(CXX11PICFLAGS)" |
21 | | - ) |
22 | | -} |
| 38 | + CXX11 = "$(CXX)", |
| 39 | + CXX11FLAGS = "$(CXXFLAGS)", |
| 40 | + CXX11STD = "-std=c++0x", |
| 41 | + CXX11PICFLAGS = "-fPIC" |
| 42 | + ), |
| 43 | + |
| 44 | + stop("Failed to infer C / C++ compilation flags") |
| 45 | +) |
23 | 46 |
|
24 | 47 | # use c++0x for compatibility with older compilers |
25 | 48 | define(STDVER = "c++0x") |
|
0 commit comments