Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,30 @@ function(join_paths joined_path first_path_segment)
set(${joined_path} "${temp_path}" PARENT_SCOPE)
endfunction()

# In-place rewrite a list of strings `requires` into a comma separated string.
#
# TODO: Replace function with list(JOIN) when updating to CMake 3.12
function(join_pkg_config_requires requires)
set(_requires "${${requires}}") # avoid shadowing issues, e.g. "${requires}"=len
list(LENGTH "${requires}" len)
set(idx 1)
foreach(req IN LISTS _requires)
string(APPEND acc "${req}")
if(idx LESS len)
string(APPEND acc ", ")
endif()
math(EXPR idx "${idx} + 1")
endforeach()
set("${requires}" "${acc}" PARENT_SCOPE)
endfunction()

# calculate pkg-config requirements
if(BLAKE3_USE_TBB)
list(APPEND PKG_CONFIG_REQUIRES "tbb >= ${TBB_VERSION}")
endif()

# pkg-config support
join_pkg_config_requires(PKG_CONFIG_REQUIRES)
join_paths(PKG_CONFIG_INSTALL_LIBDIR "\${prefix}" "${CMAKE_INSTALL_LIBDIR}")
join_paths(PKG_CONFIG_INSTALL_INCLUDEDIR "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
configure_file(libblake3.pc.in libblake3.pc @ONLY)
Expand Down
11 changes: 10 additions & 1 deletion c/blake3-config.cmake.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
@PACKAGE_INIT@

include(CMakeFindDependencyMacro)

# Remember TBB option state
set(BLAKE3_USE_TBB @BLAKE3_USE_TBB@)

if(BLAKE3_USE_TBB)
find_dependency(TBB @TBB_VERSION@)
endif()

include("${CMAKE_CURRENT_LIST_DIR}/blake3-targets.cmake")

check_required_components(blake3)
check_required_components(blake3)
2 changes: 1 addition & 1 deletion c/libblake3.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ Name: @PROJECT_NAME@
Description: @PROJECT_DESCRIPTION@
Version: @PROJECT_VERSION@

Requires:
Requires: @PKG_CONFIG_REQUIRES@
Libs: -L"${libdir}" -lblake3
Cflags: -I"${includedir}" @BLAKE3_PKGCONFIG_CFLAGS@