Skip to content

Commit 095231d

Browse files
authored
cmake : fix transient definitions in find pkg (#3411)
1 parent ea55295 commit 095231d

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,7 @@ set(LLAMA_BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR}
705705
set(LLAMA_BUILD_NUMBER ${BUILD_NUMBER})
706706
set(LLAMA_BUILD_COMMIT ${BUILD_COMMIT})
707707
set(LLAMA_INSTALL_VERSION 0.0.${BUILD_NUMBER})
708+
get_directory_property(LLAMA_TRANSIENT_DEFINES COMPILE_DEFINITIONS)
708709

709710
configure_package_config_file(
710711
${CMAKE_CURRENT_SOURCE_DIR}/scripts/LlamaConfig.cmake.in

examples/main-cmake-pkg/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ configure_file(${_common_path}/../build-info.h
2828
target_include_directories(common PUBLIC ${LLAMA_INCLUDE_DIR}
2929
${CMAKE_CURRENT_BINARY_DIR})
3030

31+
# If the common project was part of "main-cmake-pkg" the transient
32+
# defines would automatically be attached. Because the common func-
33+
# tionality is separate, but dependent upon the defines, it must be
34+
# explicitly extracted from the "llama" target.
35+
#
36+
get_target_property(_llama_transient_defines llama
37+
INTERFACE_COMPILE_DEFINITIONS)
38+
39+
target_compile_definitions(common PRIVATE "${_llama_transient_defines}")
40+
3141
add_executable(${TARGET} ${CMAKE_CURRENT_LIST_DIR}/../main/main.cpp)
3242
target_include_directories(${TARGET} PRIVATE ${_common_path})
3343
install(TARGETS ${TARGET} RUNTIME)

scripts/LlamaConfig.cmake.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,13 @@ find_library(llama_LIBRARY llama
5656
HINTS ${LLAMA_LIB_DIR})
5757

5858
set(_llama_link_deps "Threads::Threads" "@LLAMA_EXTRA_LIBS@")
59+
set(_llama_transient_defines "@LLAMA_TRANSIENT_DEFINES@")
5960
add_library(llama UNKNOWN IMPORTED)
6061
set_target_properties(llama
6162
PROPERTIES
6263
INTERFACE_INCLUDE_DIRECTORIES "${LLAMA_INCLUDE_DIR}"
6364
INTERFACE_LINK_LIBRARIES "${_llama_link_deps}"
65+
INTERFACE_COMPILE_DEFINITIONS "${_llama_transient_defines}"
6466
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
6567
IMPORTED_LOCATION "${llama_LIBRARY}"
6668
INTERFACE_COMPILE_FEATURES cxx_std_11

0 commit comments

Comments
 (0)