Skip to content

Commit cba304d

Browse files
Provide DPCTL_ENABLE_GLOG cmake option to turn on logging
1 parent 4f4effa commit cba304d

File tree

1 file changed

+47
-10
lines changed

1 file changed

+47
-10
lines changed

libsyclinterface/CMakeLists.txt

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ option(DPCTL_BUILD_CAPI_TESTS
3838
"Build dpctl C API google tests"
3939
OFF
4040
)
41+
# Option to turn on logging support for dpctl C API
42+
option(DPCTL_ENABLE_GLOG
43+
"Enable the Google logging module"
44+
OFF
45+
)
4146

4247
# Minimum version requirement only when oneAPI dpcpp is used.
4348
if(DPCTL_DPCPP_FROM_ONEAPI)
@@ -156,17 +161,49 @@ add_library(DPCTLSyclInterface
156161
${helper_sources}
157162
)
158163

159-
target_include_directories(DPCTLSyclInterface
160-
PRIVATE
161-
${CMAKE_CURRENT_SOURCE_DIR}/include/
162-
${CMAKE_CURRENT_SOURCE_DIR}/helper/include/
163-
${IntelSycl_SYCL_INCLUDE_DIR}
164-
)
164+
if(DPCTL_ENABLE_GLOG)
165+
find_path(GLOG_INCLUDE_DIR NAMES glog/logging.h)
166+
find_library(GLOG_LIBRARY NAMES glog)
167+
if(GLOG_INCLUDE_DIR AND GLOG_LIBRARY)
168+
message(STATUS "Found GLog:")
169+
message(STATUS " Headers: ${GLOG_INCLUDE_DIR}")
170+
message(STATUS " Library: ${GLOG_LIBRARY}")
171+
else()
172+
message(FATAL_ERROR "GLog not found")
173+
endif()
174+
175+
find_package(glog REQUIRED)
176+
177+
target_include_directories(DPCTLSyclInterface
178+
PRIVATE
179+
${CMAKE_CURRENT_SOURCE_DIR}/include/
180+
${CMAKE_CURRENT_SOURCE_DIR}/helper/include/
181+
${IntelSycl_SYCL_INCLUDE_DIR}
182+
${GLOG_INCLUDE_DIR}
183+
)
184+
185+
target_compile_definitions(DPCTLSyclInterface PUBLIC ENABLE_GLOG)
186+
187+
target_link_libraries(DPCTLSyclInterface
188+
PRIVATE ${IntelSycl_SYCL_LIBRARY}
189+
PRIVATE ${IntelSycl_OPENCL_LIBRARY}
190+
${GLOG_LIBRARY}
191+
)
192+
193+
else()
194+
target_include_directories(DPCTLSyclInterface
195+
PRIVATE
196+
${CMAKE_CURRENT_SOURCE_DIR}/include/
197+
${CMAKE_CURRENT_SOURCE_DIR}/helper/include/
198+
${IntelSycl_SYCL_INCLUDE_DIR}
199+
)
200+
target_link_libraries(DPCTLSyclInterface
201+
PRIVATE ${IntelSycl_SYCL_LIBRARY}
202+
PRIVATE ${IntelSycl_OPENCL_LIBRARY}
203+
)
204+
205+
endif()
165206

166-
target_link_libraries(DPCTLSyclInterface
167-
PRIVATE ${IntelSycl_SYCL_LIBRARY}
168-
PRIVATE ${IntelSycl_OPENCL_LIBRARY}
169-
)
170207

171208
include(GetProjectVersion)
172209
# the get_version function is defined in the GetProjectVersion module and

0 commit comments

Comments
 (0)