Skip to content
Permalink
Browse files

cmake: compiler: gcc: Explicitly spell out stddef.h and limits.h

Depending on how compiler is built, it prints a different include
directory with `--print-file-name=include`.  What we want, instead, is
directories with `stddef.h` and `include-fixed/limits.h`.

This commit explicitly specify the header files we want to use, then
take the directory from the returned path.

Signed-off-by: Yasushi SHOJI <y-shoji@ispace-inc.com>
  • Loading branch information...
yashi authored and carlescufi committed May 9, 2019
1 parent 9336e3e commit 209a9104be8454d158434bea4b605633b42de710
@@ -20,11 +20,12 @@ find_program(CMAKE_CXX_COMPILER clang++ ${find_program_clang_args})

if(NOT "${ARCH}" STREQUAL "posix")

foreach(file_name include include-fixed)
foreach(file_name include/stddef.h include-fixed/limits.h)
execute_process(
COMMAND ${CMAKE_C_COMPILER} --print-file-name=${file_name}
OUTPUT_VARIABLE _OUTPUT
)
get_filename_component(_OUTPUT "${_OUTPUT}" DIRECTORY)
string(REGEX REPLACE "\n" "" _OUTPUT ${_OUTPUT})

list(APPEND NOSTDINC ${_OUTPUT})
@@ -29,11 +29,12 @@ if(NOT DEFINED NOSYSDEF_CFLAG)
set(NOSYSDEF_CFLAG -undef)
endif()

foreach(file_name include include-fixed)
foreach(file_name include/stddef.h include-fixed/limits.h)
execute_process(
COMMAND ${CMAKE_C_COMPILER} --print-file-name=${file_name}
OUTPUT_VARIABLE _OUTPUT
)
get_filename_component(_OUTPUT "${_OUTPUT}" DIRECTORY)
string(REGEX REPLACE "\n" "" _OUTPUT "${_OUTPUT}")

list(APPEND NOSTDINC ${_OUTPUT})
@@ -60,11 +60,12 @@ if(NOT DEFINED NOSYSDEF_CFLAG)
set(NOSYSDEF_CFLAG -undef)
endif()

foreach(file_name include)
foreach(file_name include/stddef.h)
execute_process(
COMMAND ${CMAKE_C_COMPILER} --print-file-name=${file_name}
OUTPUT_VARIABLE _OUTPUT
)
get_filename_component(_OUTPUT "${_OUTPUT}" DIRECTORY)
string(REGEX REPLACE "\n" "" _OUTPUT "${_OUTPUT}")

list(APPEND NOSTDINC ${_OUTPUT})
@@ -29,11 +29,12 @@ if(NOT DEFINED NOSYSDEF_CFLAG)
set(NOSYSDEF_CFLAG -undef)
endif()

foreach(file_name include include-fixed)
foreach(file_name include/stddef.h include-fixed/limits.h)
execute_process(
COMMAND ${CMAKE_C_COMPILER} --print-file-name=${file_name}
OUTPUT_VARIABLE _OUTPUT
)
get_filename_component(_OUTPUT "${_OUTPUT}" DIRECTORY)
string(REGEX REPLACE "\n" "" _OUTPUT "${_OUTPUT}")

list(APPEND NOSTDINC ${_OUTPUT})

0 comments on commit 209a910

Please sign in to comment.
You can’t perform that action at this time.