Skip to content

Commit

Permalink
Fixed pkg-config files generation
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-lavrenov authored and lisanna-dettwyler committed Dec 20, 2024
1 parent d13942a commit ddce767
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion samples/zello_world/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if(MSVC)
)
endif()

target_link_libraries(${TARGET_NAME}
target_link_libraries(${TARGET_NAME} PRIVATE
${TARGET_LOADER_NAME}
${CMAKE_DL_LIBS}
)
15 changes: 6 additions & 9 deletions source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,25 @@ add_subdirectory(loader)
add_subdirectory(layers)
add_subdirectory(drivers)
add_subdirectory(utils)
target_include_directories(${TARGET_LOADER_NAME} PRIVATE utils)

set_target_properties(${TARGET_LOADER_NAME} PROPERTIES
VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}"
SOVERSION "${PROJECT_VERSION_MAJOR}"
)

target_link_libraries(${TARGET_LOADER_NAME}
${CMAKE_DL_LIBS}
)
target_link_libraries(${TARGET_LOADER_NAME} PRIVATE ${CMAKE_DL_LIBS} level_zero_utils)

if (UNIX)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
target_link_libraries (${TARGET_LOADER_NAME} Threads::Threads)
target_link_libraries (${TARGET_LOADER_NAME} PRIVATE Threads::Threads)
endif()

if(WIN32)
target_link_libraries (${TARGET_LOADER_NAME} cfgmgr32.lib)
target_link_libraries (${TARGET_LOADER_NAME} PRIVATE cfgmgr32.lib)
endif()

# Link against utility sublibrary
target_link_libraries(${TARGET_LOADER_NAME} utils)

install(TARGETS ze_loader
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT level-zero-devel
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT level-zero
Expand All @@ -56,6 +50,9 @@ install(TARGETS ze_loader
)

if(UNIX)
file(RELATIVE_PATH ze_loader_include_dir "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig" "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
file(RELATIVE_PATH ze_loader_lib_dir "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig" "${CMAKE_INSTALL_FULL_LIBDIR}")

configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/libze_loader.pc.in
${CMAKE_CURRENT_BINARY_DIR}/libze_loader.pc
Expand Down
5 changes: 3 additions & 2 deletions source/level-zero.pc.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
pc_path=${pcfiledir}
includedir=${pc_path}/@ze_loader_include_dir@
libdir=${pc_path}/@ze_loader_lib_dir@


Name: Level Zero
Expand Down
5 changes: 3 additions & 2 deletions source/libze_loader.pc.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
pc_path=${pcfiledir}
includedir=${pc_path}/@ze_loader_include_dir@
libdir=${pc_path}/@ze_loader_lib_dir@


Name: Level Zero Loader
Expand Down
11 changes: 7 additions & 4 deletions source/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
# SPDX-License-Identifier: MIT

set(logging_files logging.h logging.cpp)
add_library(utils STATIC ${logging_files})
add_library(level_zero_utils STATIC ${logging_files})

if(SYSTEM_SPDLOG)
target_link_libraries(utils PUBLIC spdlog::spdlog)
target_link_libraries(level_zero_utils PUBLIC spdlog::spdlog)
else()
target_include_directories(utils PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third_party/spdlog_headers>)
target_include_directories(level_zero_utils PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third_party/spdlog_headers>)
endif()
set_property(TARGET utils PROPERTY POSITION_INDEPENDENT_CODE ON)

target_include_directories(level_zero_utils PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

set_property(TARGET level_zero_utils PROPERTY POSITION_INDEPENDENT_CODE ON)

0 comments on commit ddce767

Please sign in to comment.