cmake: fix some issues when building both shared and static versions of a library

This commit is contained in:
2026-03-06 20:15:05 +00:00
parent f47be0cd67
commit 1c89acddbf

View File

@@ -63,6 +63,7 @@ function(rosetta_add_library)
add_library(${static_lib_name} STATIC
${arg_SOURCES}
${arg_HEADERS})
set_target_properties(${static_lib_name} PROPERTIES OUTPUT_NAME "${lib_name}")
set(targets ${targets} ${static_lib_name})
if (arg_PUBLIC_INCLUDE_DIRS)
@@ -90,7 +91,10 @@ function(rosetta_add_library)
target_link_options(${shared_lib_name} PRIVATE -Wl,--soname,${soname})
endif()
target_include_directories(${targets} PUBLIC ${arg_PUBLIC_INCLUDE_DIRS})
foreach (target ${targets})
target_include_directories(${target} PUBLIC ${arg_PUBLIC_INCLUDE_DIRS})
endforeach (target)
set_target_properties(${targets} PROPERTIES
POSITION_INDEPENDENT_CODE ON
src_header_dir ${CMAKE_CURRENT_SOURCE_DIR}/include