this repo has no description
1# Detect the location of compiler-specific header files
2# such as stdbool.h or xmmintrin.h
3function(GetCompilerInclude OutputVar)
4 file(WRITE "${CMAKE_BINARY_DIR}/cinctest.c" "#include <cpuid.h>")
5 execute_process(COMMAND "${CMAKE_C_COMPILER}" -M "${CMAKE_BINARY_DIR}/cinctest.c"
6 RESULT_VARIABLE BuildResult
7 OUTPUT_VARIABLE BuildOutput
8 )
9
10 if (BuildResult)
11 message(FATAL_ERROR "Cannot detect compiler header include path")
12 endif (BuildResult)
13
14 separate_arguments(BuildOutput)
15
16 foreach (str ${BuildOutput})
17 string(REGEX REPLACE "\n$" "" str "${str}")
18 # message(STATUS "Output: ${str}")
19
20 if (str MATCHES "cpuid.h$")
21 # message(STATUS "Str matched: ${str}")
22 string(REGEX REPLACE "cpuid\\.h" "" IncPath "${str}")
23 endif (str MATCHES "cpuid.h$")
24 endforeach (str)
25
26 if (NOT IncPath)
27 message(FATAL_ERROR "Cannot parse compiler output to detect include path")
28 endif (NOT IncPath)
29
30 set(${OutputVar} ${IncPath} PARENT_SCOPE)
31endfunction(GetCompilerInclude)
32