Skip to content

Commit

Permalink
Fix issue #112
Browse files Browse the repository at this point in the history
Add compiler flags for packages that target CXX14, CXX17, and CXX20
  • Loading branch information
const-ae authored and gaborcsardi committed Dec 8, 2021
1 parent 6025fab commit 13c7714
Showing 1 changed file with 32 additions and 22 deletions.
54 changes: 32 additions & 22 deletions R/compiler-flags.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,40 @@
compiler_flags <- function(debug = FALSE) {
res <-
if (Sys.info()[["sysname"]] == "SunOS") {
c(
CFLAGS = "-g",
CXXFLAGS = "-g",
CXX11FLAGS = "-g"
)
} else if (debug) {
c(
CFLAGS = "-UNDEBUG -Wall -pedantic -g -O0",
CXXFLAGS = "-UNDEBUG -Wall -pedantic -g -O0",
CXX11FLAGS = "-UNDEBUG -Wall -pedantic -g -O0",
FFLAGS = "-g -O0",
FCFLAGS = "-g -O0"
)
} else {
c(
CFLAGS = "-Wall -pedantic",
CXXFLAGS = "-Wall -pedantic",
CXX11FLAGS = "-Wall -pedantic"
)
}
c(
CFLAGS = "-g",
CXXFLAGS = "-g",
CXX11FLAGS = "-g",
CXX14FLAGS = "-g",
CXX17FLAGS = "-g",
CXX20FLAGS = "-g"
)
} else if (debug) {
c(
CFLAGS = "-UNDEBUG -Wall -pedantic -g -O0",
CXXFLAGS = "-UNDEBUG -Wall -pedantic -g -O0",
CXX11FLAGS = "-UNDEBUG -Wall -pedantic -g -O0",
CXX14FLAGS = "-UNDEBUG -Wall -pedantic -g -O0",
CXX17FLAGS = "-UNDEBUG -Wall -pedantic -g -O0",
CXX20FLAGS = "-UNDEBUG -Wall -pedantic -g -O0",
FFLAGS = "-g -O0",
FCFLAGS = "-g -O0"
)
} else {
c(
CFLAGS = "-Wall -pedantic",
CXXFLAGS = "-Wall -pedantic",
CXX11FLAGS = "-Wall -pedantic",
CXX14FLAGS = "-Wall -pedantic",
CXX17FLAGS = "-Wall -pedantic",
CXX20FLAGS = "-Wall -pedantic"
)
}

if (crayon::has_color() && has_compiler_colored_diagnostics()) {
res[c("CFLAGS", "CXXFLAGS", "CXX11FLAGS")] <-
paste(res[c("CFLAGS", "CXXFLAGS", "CXX11FLAGS")], "-fdiagnostics-color=always")
flags <- c("CFLAGS", "CXXFLAGS", "CXX11FLAGS",
"CXX14FLAGS", "CXX17FLAGS", "CXX20FLAGS")
res[flags] <- paste(res[flags], "-fdiagnostics-color=always")
}
res
}
Expand Down

0 comments on commit 13c7714

Please # to comment.