cmake: merge libs via virtual object libraries
CMake issued a warming about policy CMP0026: access of LOCATION target property at config time was disallowed. Offending code was the code that merged static libraries to generate libwallet_merged.a. This patch does that same merge task in a much simpler way. And, since it doesn't violate the policy, the warning went away.
This commit is contained in:
@@ -82,8 +82,13 @@ function (bitmonero_add_library name)
|
||||
FILES
|
||||
${ARGN})
|
||||
|
||||
add_library("${name}"
|
||||
${ARGN})
|
||||
# Define a ("virtual") object library and an actual library that links those
|
||||
# objects together. The virtual libraries can be arbitrarily combined to link
|
||||
# any subset of objects into one library archive. This is used for releasing
|
||||
# libwallet, which combines multiple components.
|
||||
set(objlib obj_${name})
|
||||
add_library(${objlib} OBJECT ${ARGN})
|
||||
add_library("${name}" STATIC $<TARGET_OBJECTS:${objlib}>)
|
||||
set_property(TARGET "${name}"
|
||||
PROPERTY
|
||||
FOLDER "libs")
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
# include (${PROJECT_SOURCE_DIR}/cmake/libutils.cmake)
|
||||
include (${PROJECT_SOURCE_DIR}/cmake/MergeStaticLibs.cmake)
|
||||
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
|
||||
@@ -76,7 +75,11 @@ target_link_libraries(wallet
|
||||
${EXTRA_LIBRARIES})
|
||||
|
||||
set(libs_to_merge wallet cryptonote_core mnemonics common crypto)
|
||||
merge_static_libs(wallet_merged "${libs_to_merge}")
|
||||
|
||||
foreach(lib ${libs_to_merge})
|
||||
list(APPEND objlibs $<TARGET_OBJECTS:obj_${lib}>) # matches naming convention in src/CMakeLists.txtA
|
||||
endforeach()
|
||||
add_library(wallet_merged STATIC ${objlibs})
|
||||
install(TARGETS wallet_merged
|
||||
ARCHIVE DESTINATION lib)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user