Private
Public Access
2
0

javascript: update C++ standard to C++17 for compatibility with newer Node.js versions

When compiling mraa on Debian 13, the following error occurs:

```
/usr/include/node/node.h:696:8: error: ‘optional’ in namespace ‘std’ does not name a template type
  696 |   std::optional<std::string> builder_script_path;
      |        ^~~~~~~~
/usr/include/node/node.h:696:3: note: ‘std::optional’ is only available from C++17 onwards
  696 |   std::optional<std::string> builder_script_path;
      |   ^~~
```

Root cause: Node.js version on Debian 13 is 20+, which requires C++17 feature support.

Signed-off-by: Chun Jiao Zhao <chunjiao.zhao@siemens.com>
This commit is contained in:
Chun Jiao Zhao
2025-09-02 17:12:58 +08:00
committed by Tom Ingleby
parent 28fa501b6c
commit 31a352a32d
2 changed files with 29 additions and 6 deletions

View File

@@ -90,6 +90,17 @@ if (BUILDCPP)
message(FATAL_ERROR "Target '${targetname}' requires c++11 which is not supported by this compiler")
endif()
endfunction()
# This function adds the c++17 flag to a c++ target (if supported)
function(use_cxx_17 targetname)
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++17" COMPILER_SUPPORTS_CXX17)
if (COMPILER_SUPPORTS_CXX17)
set_target_properties(${targetname} PROPERTIES COMPILE_FLAGS "-std=c++17")
else()
message(FATAL_ERROR "Target '${targetname}' requires c++17 which is not supported by this compiler")
endif()
endfunction()
endif()
# Set CMAKE_INSTALL_LIBDIR if not defined