1# SPDX-License-Identifier: Apache-2.0
2
3# Configures CMake for using GCC
4
5find_program(CMAKE_C_COMPILER gcc)
6
7if(CONFIG_CPP)
8  set(cplusplus_compiler g++)
9else()
10  if(EXISTS g++)
11    set(cplusplus_compiler g++)
12  else()
13    # When the toolchain doesn't support C++, and we aren't building
14    # with C++ support just set it to something so CMake doesn't
15    # crash, it won't actually be called
16    set(cplusplus_compiler ${CMAKE_C_COMPILER})
17  endif()
18endif()
19find_program(CMAKE_CXX_COMPILER ${cplusplus_compiler}     CACHE INTERNAL " " FORCE)
20
21set(NOSTDINC "")
22
23# Note that NOSYSDEF_CFLAG may be an empty string, and
24# set_ifndef() does not work with empty string.
25if(NOT DEFINED NOSYSDEF_CFLAG)
26  set(NOSYSDEF_CFLAG -undef)
27endif()
28
29foreach(file_name include/stddef.h)
30  execute_process(
31    COMMAND ${CMAKE_C_COMPILER} --print-file-name=${file_name}
32    OUTPUT_VARIABLE _OUTPUT
33    )
34  get_filename_component(_OUTPUT "${_OUTPUT}" DIRECTORY)
35  string(REGEX REPLACE "\n" "" _OUTPUT "${_OUTPUT}")
36
37  list(APPEND NOSTDINC ${_OUTPUT})
38endforeach()
39
40list(APPEND LLEXT_EDK_REMOVE_FLAGS
41    --sysroot=.*
42    -fmacro-prefix-map=.*
43    )
44
45list(APPEND LLEXT_EDK_APPEND_FLAGS
46    -nodefaultlibs
47    )
48