Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake: Handle generator expressions requiring a target for pkg-config #1433

Closed
wants to merge 1 commit into from
Closed
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
9 changes: 8 additions & 1 deletion CMake/GenPkgConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,14 @@ function(gen_pkgconfig_vars)

# Set the output variables
string(REPLACE ";" " " cflags "${cflags}")
set("${var_prefix}_CFLAGS" "${cflags}" PARENT_SCOPE)
string(REPLACE ";" " " private_libs "${private_libs}")

# Since CMake 3.18 FindThreads may include a generator expression requiring a target, which gets propagated to us through INTERFACE_COMPILE_OPTIONS.
# Before CMake 3.19 there's no way to solve this in a general way, so we work around the specific case. See #1414 and CMake bug #21074.
if(CMAKE_VERSION VERSION_LESS 3.19)
string(REPLACE "<COMPILE_LANG_AND_ID:CUDA,NVIDIA>" "<COMPILE_LANGUAGE:CUDA>" cflags "${cflags}")
endif()

set("${var_prefix}_CFLAGS" "${cflags}" PARENT_SCOPE)
set("${var_prefix}_PRIVATE_LIBS" "${private_libs}" PARENT_SCOPE)
endfunction()
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -436,10 +436,17 @@ configure_file(
${CMAKE_CURRENT_BINARY_DIR}/libfolly.pc.gen
@ONLY
)

# Specify target to allow resolving generator expressions requiring a target for CMake >=3.19. See #1414.
if(CMAKE_VERSION VERSION_GREATER 3.18)
tambry marked this conversation as resolved.
Show resolved Hide resolved
set(target_arg TARGET folly_deps)
endif()

file(
GENERATE
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/libfolly.pc
INPUT ${CMAKE_CURRENT_BINARY_DIR}/libfolly.pc.gen
${target_arg}
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/libfolly.pc
Expand Down