mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-11-30 21:13:49 -06:00
cmake: do not quote variables for config.h anymore
v2: incorporate Roland's nitpicks (I hope) v3: It was decided that it's better to change the default behavior v4: make sure the CMake syntax is correct even if the value of the variable contains spaces (if it contains double quotes it's a different matter, but that's pretty much a corner case, IMHO) v5: properly escape backslash and double quote characters in the cmake syntax
This commit is contained in:
parent
a64118cb81
commit
fd781af125
@ -93,21 +93,15 @@ function (configure_vars obj syntax filename verb)
|
||||
file (APPEND "${filename}" "/* #undef ${_var} */\n")
|
||||
endif ("${syntax}" STREQUAL "CMAKE")
|
||||
else ((NOT DEFINED ${_var}) OR ("${${_var}}" STREQUAL ""))
|
||||
|
||||
# integer variables (specifically 0 and 1) are written as they are,
|
||||
# whereas everything else (including version numbers, which could
|
||||
# be interpreted as floats) are quoted as strings
|
||||
if (${_var} MATCHES "^[0-9]+$")
|
||||
set (_quoted "${${_var}}")
|
||||
else (${_var} MATCHES "^[0-9]+$")
|
||||
set (_quoted "\"${${_var}}\"")
|
||||
endif (${_var} MATCHES "^[0-9]+$")
|
||||
|
||||
# write to file using the correct syntax
|
||||
if ("${syntax}" STREQUAL "CMAKE")
|
||||
file (APPEND "${filename}" "set (${_var} ${_quoted})\n")
|
||||
# escape backslash and double quote characters
|
||||
string (REPLACE "\\" "\\\\" _quoted "${${_var}}")
|
||||
string (REPLACE "\"" "\\\"" _quoted "${_quoted}")
|
||||
|
||||
file (APPEND "${filename}" "set (${_var} \"${_quoted}\")\n")
|
||||
else ("${syntax}" STREQUAL "CMAKE")
|
||||
file (APPEND "${filename}" "#define ${_var} ${_quoted}\n")
|
||||
file (APPEND "${filename}" "#define ${_var} ${${_var}}\n")
|
||||
endif ("${syntax}" STREQUAL "CMAKE")
|
||||
|
||||
endif ((NOT DEFINED ${_var}) OR ("${${_var}}" STREQUAL ""))
|
||||
|
@ -74,6 +74,13 @@ CHECK_CXX_SOURCE_COMPILES("
|
||||
" HAVE_SHARED_PTR
|
||||
)
|
||||
|
||||
# this is required by dune-common to avoid linker errors. "fun"!
|
||||
if (HAVE_SHARED_PTR)
|
||||
set(HAVE_MAKE_SHARED 1)
|
||||
set(SHARED_PTR_HEADER "<memory>")
|
||||
set(SHARED_PTR_NAMESPACE "std")
|
||||
endif()
|
||||
|
||||
# nullptr
|
||||
CHECK_CXX_SOURCE_COMPILES("
|
||||
#include <memory>
|
||||
|
@ -56,6 +56,8 @@ int main (void) {
|
||||
HAVE_NULLPTR;
|
||||
HAVE_STATIC_ASSERT;
|
||||
HAVE_SHARED_PTR;
|
||||
SHARED_PTR_HEADER;
|
||||
SHARED_PTR_NAMESPACE;
|
||||
HAVE_TYPE_TRAITS;
|
||||
HAVE_TR1_TUPLE;
|
||||
HAVE_TUPLE;
|
||||
|
@ -336,14 +336,8 @@ function (config_cmd_line varname defs)
|
||||
foreach (_var IN LISTS ${defs})
|
||||
# only generate an entry if the define was actually set
|
||||
if ((DEFINED ${_var}) AND (NOT "${${_var}}" STREQUAL ""))
|
||||
# numbers are not quoted, strings are
|
||||
if (${_var} MATCHES "[0-9]+")
|
||||
set (_quoted "${${_var}}")
|
||||
else (${_var} MATCHES "[0-9]+")
|
||||
set (_quoted "\"${${_var}}\"")
|
||||
endif (${_var} MATCHES "[0-9]+")
|
||||
# add command-line option to define this variable
|
||||
list (APPEND _cmdline "-D${_var}=${_quoted}")
|
||||
list (APPEND _cmdline "-D${_var}=${${_var}}")
|
||||
endif ((DEFINED ${_var}) AND (NOT "${${_var}}" STREQUAL ""))
|
||||
endforeach (_var)
|
||||
# return the resulting command-line options for defining vars
|
||||
|
Loading…
Reference in New Issue
Block a user