cmake: add different parameters to add_monero_library.

1. LINKS flag, will link publicly the libraries provided.
2. PRIVATE_LINKS flag, will link privately the libraries provided.
3. INCLUDES flag, will includes publicly the dirs provided.
4. PRIVATE_INCLUDES flag, will include privately the libraries provided.
This commit is contained in:
0xFFFC0000 2024-06-13 10:26:46 +00:00
parent 5074a543a4
commit b91ead9025
No known key found for this signature in database
GPG Key ID: 650F7C2B7BDA3819

View File

@ -643,7 +643,7 @@ function (monero_add_library name)
endfunction()
function (monero_add_library_with_deps)
cmake_parse_arguments(MONERO_ADD_LIBRARY "" "NAME" "DEPENDS;SOURCES" ${ARGN})
cmake_parse_arguments(MONERO_ADD_LIBRARY "" "NAME" "DEPENDS;LINKS;PRIVATE_LINKS;INCLUDES;PRIVATE_INCLUDES;SOURCES" ${ARGN})
source_group("${MONERO_ADD_LIBRARY_NAME}" FILES ${MONERO_ADD_LIBRARY_SOURCES})
# Define a ("virtual") object library and an actual library that links those
@ -658,6 +658,22 @@ function (monero_add_library_with_deps)
if (MONERO_ADD_LIBRARY_DEPENDS)
add_dependencies(${objlib} ${MONERO_ADD_LIBRARY_DEPENDS})
endif()
if (MONERO_ADD_LIBRARY_LINKS)
target_link_libraries(${objlib} PUBLIC ${MONERO_ADD_LIBRARY_LINKS})
target_link_libraries(${MONERO_ADD_LIBRARY_NAME} PUBLIC ${MONERO_ADD_LIBRARY_LINKS})
endif()
if (MONERO_ADD_LIBRARY_PRIVATE_LINKS)
target_link_libraries(${objlib} PRIVATE ${MONERO_ADD_LIBRARY_PRIVATE_LINKS})
target_link_libraries(${MONERO_ADD_LIBRARY_NAME} PRIVATE ${MONERO_ADD_LIBRARY_PRIVATE_LINKS})
endif()
if (MONERO_ADD_LIBRARY_INCLUDES)
target_include_directories(${objlib} PUBLIC ${MONERO_ADD_LIBRARY_INCLUDES})
target_include_directories(${MONERO_ADD_LIBRARY_NAME} PUBLIC ${MONERO_ADD_LIBRARY_INCLUDES})
endif()
if (MONERO_ADD_LIBRARY_PRIVATE_INCLUDES)
target_include_directories(${objlib} PRIVATE ${MONERO_ADD_LIBRARY_PRIVATE_INCLUDES})
target_include_directories(${MONERO_ADD_LIBRARY_NAME} PRIVATE ${MONERO_ADD_LIBRARY_PRIVATE_INCLUDES})
endif()
set_property(TARGET "${MONERO_ADD_LIBRARY_NAME}" PROPERTY FOLDER "libs")
target_compile_definitions(${objlib}
PRIVATE $<TARGET_PROPERTY:${MONERO_ADD_LIBRARY_NAME},INTERFACE_COMPILE_DEFINITIONS>)