Skip to content

Commit

Permalink
build: prioritize public headers to avoid clash
Browse files Browse the repository at this point in the history
  • Loading branch information
densamoilov committed Oct 4, 2023
1 parent dc66df7 commit 08fea71
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,13 @@ endif()

enable_testing()

include_directories_with_host_compiler(${PROJECT_SOURCE_DIR}/include)
include_directories_with_host_compiler_before(${PROJECT_SOURCE_DIR}/include)

configure_file(
"${PROJECT_SOURCE_DIR}/include/oneapi/dnnl/dnnl_config.h.in"
"${PROJECT_BINARY_DIR}/include/oneapi/dnnl/dnnl_config.h"
)
include_directories_with_host_compiler(${PROJECT_BINARY_DIR}/include)
include_directories_with_host_compiler_before(${PROJECT_BINARY_DIR}/include)

configure_file(
"${PROJECT_SOURCE_DIR}/README.binary.in"
Expand Down
21 changes: 18 additions & 3 deletions cmake/utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,17 @@ endmacro()
macro(append_host_compiler_options var opts)
if(NOT DNNL_DPCPP_HOST_COMPILER STREQUAL "DEFAULT")
if(${var} MATCHES "-fsycl-host-compiler-options")
string(REGEX REPLACE
"(.*)(-fsycl-host-compiler-options=)\"(.*)\"(.*)"
"\\1\\2\"\\3 ${opts}\"\\4" ${var} ${${var}})
if("${ARGV2}" STREQUAL "BEFORE") # prepend
string(REGEX REPLACE
"(.*)(-fsycl-host-compiler-options=)\"(.*)\"(.*)"
"\\1\\2\"${opts} \\3\"\\4" ${var} ${${var}})
elseif("${ARGV2}" STREQUAL "") # append
string(REGEX REPLACE
"(.*)(-fsycl-host-compiler-options=)\"(.*)\"(.*)"
"\\1\\2\"\\3 ${opts}\"\\4" ${var} ${${var}})
else()
message(FATAL_ERROR "Unknown argument: ${ARGV2}")
endif()
else()
append(${var} "-fsycl-host-compiler-options=\"${opts}\"")
endif()
Expand All @@ -112,6 +120,13 @@ macro(include_directories_with_host_compiler)
endforeach()
endmacro()

macro(include_directories_with_host_compiler_before)
foreach(inc_dir ${ARGV})
include_directories(BEFORE ${inc_dir})
append_host_compiler_options(CMAKE_CXX_FLAGS "-I${inc_dir}" BEFORE)
endforeach()
endmacro()

macro(add_definitions_with_host_compiler)
foreach(def ${ARGV})
add_definitions(${def})
Expand Down

0 comments on commit 08fea71

Please # to comment.