From 8bbf1d9ab648f002a3c27f6735843273abdff457 Mon Sep 17 00:00:00 2001 From: Claus Hunsen Date: Tue, 28 Aug 2018 12:06:12 +0200 Subject: [PATCH] Fix finding of CXX prefix When configuring the package, the finding of the correct CXX prefix is crucial (see the file 'tools/config/configure.R'). As the function call 'read_r_config' (and, thus, 'R CMD config') does not return 'NULL' (but an error message) if a constant is not configured, the wrong prefix is chosen. This results in compilation errors. To fix this problem, it needs to be checked whether the call to 'read_r_config' returns an error messsage or not. Additionally, remove trailing whitespace in 'tools/config/configure.R'. Signed-off-by: Claus Hunsen Signed-off-by: Thomas Bock --- tools/config/configure.R | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/config/configure.R b/tools/config/configure.R index b9313686..62c3556f 100644 --- a/tools/config/configure.R +++ b/tools/config/configure.R @@ -6,7 +6,7 @@ candidates <- c("CXX11", "CXX1X", "CXX") for (candidate in candidates) { config <- read_r_config(candidate, envir = NULL) value <- config[[candidate]] - if (!is.null(value)) { + if (!is.null(value) && !(startsWith(value, "ERROR:"))) { cxx <- candidate break } @@ -26,7 +26,7 @@ if (broken) # configuration of R switch( cxx, - + CXX11 = define( CC = "$(CC)", CXX11 = "$(CXX11)", @@ -34,7 +34,7 @@ switch( CXX11STD = "$(CXX11STD)", CXX11PICFLAGS = "$(CXX11PICFLAGS)" ), - + CXX1X = define( CC = "$(CC)", CXX11 = "$(CXX1X)", @@ -42,7 +42,7 @@ switch( CXX11STD = "$(CXX1XSTD)", CXX11PICFLAGS = "$(CXX1XPICFLAGS)" ), - + CXX = define( CC = "$(CC)", CXX11 = "$(CXX)", @@ -50,14 +50,14 @@ switch( CXX11STD = "-std=c++0x", CXX11PICFLAGS = "-fPIC" ), - + stop("Failed to infer C / C++ compilation flags") ) # define special flags for Windows db <- configure_database() if (Sys.info()[["sysname"]] == "Windows") { - + cygpath <- nzchar(Sys.which("cygpath")) fmt <- if (cygpath) "$(shell cygpath -m \"%s\")" else "%s" define(