@@ -312,11 +312,20 @@ function(add_gaia_sdk_gtest)
312312
313313 # Unlike clang, gaiat isn't smart enough to know where system include dirs are
314314 # for intrinsics and stdlib headers, so we need to define them explicitly.
315- # Since our internal builds target only Ubuntu 20.04, we assume that the
316- # default version (9) of libstdc++ is installed.
317- set (CLANG_INCLUDE_DIR "/usr/include/clang/13/include/" )
318- set (LIBCXX_INCLUDE_DIR "/usr/lib/llvm-13/include/c++/v1/" )
319- set (LIBSTDCXX_INCLUDE_DIR "/usr/include/c++/9/" )
315+ set (GAIAT_INCLUDE_PATH "" )
316+
317+ # We use libc++ in debug and its header must be manually included.
318+ # Note: the order of inclusion is relevant and libc++ headers must be
319+ # defined first when libc++ is used.
320+ if (CMAKE_BUILD_TYPE STREQUAL "Debug" )
321+ set (LIBCXX_INCLUDE_DIR "/usr/lib/llvm-13/include/c++/v1/" )
322+ string (APPEND GAIAT_INCLUDE_PATH "-I;${LIBCXX_INCLUDE_DIR} ;" )
323+ endif ()
324+
325+ foreach (INCLUDE_PATH ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES} )
326+ # Have to use ; instead of space otherwise custom_command will try to escape it
327+ string (APPEND GAIAT_INCLUDE_PATH "-I;${INCLUDE_PATH} ;" )
328+ endforeach ()
320329
321330 add_custom_command (
322331 COMMENT "Compiling ${RULESET_FILE} ..."
@@ -329,9 +338,8 @@ function(add_gaia_sdk_gtest)
329338 -I ${FLATBUFFERS_INC}
330339 -I ${GAIA_SPDLOG_INC}
331340 -I ${DAC_INCLUDE}
341+ -I ${GAIAT_INCLUDE_PATH}
332342 -stdlib=$<IF:$<CONFIG:Debug>,libc++,libstdc++>
333- -I $<IF:$<CONFIG:Debug>,${LIBCXX_INCLUDE_DIR} ,${LIBSTDCXX_INCLUDE_DIR} >
334- -I ${CLANG_INCLUDE_DIR}
335343 -std=c++${CMAKE_CXX_STANDARD}
336344 COMMAND pkill -f -KILL gaia_db_server &
337345
0 commit comments