Skip to content

Commit 996ad57

Browse files
committed
Add an option to determine if building all-in-one objects archive
1 parent 80f0dac commit 996ad57

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

CMakeLists.txt

+16-11
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ include(cmake/bundle_static.cmake)
8181
# Also we would like users to link a native cmake target, instead of a custom target for better
8282
# compatability.
8383
option(BUILD_SHARED_LIBS "Build shared instead of static library" ${PROJECT_IS_TOP_LEVEL})
84+
option(UNICORN_LEGACY_STATIC_ARCHIVE "Enable Unicorn v1 style all-in-one objects archive for libunicorn.a" ${PROJECT_IS_TOP_LEVEL})
8485
option(UNICORN_FUZZ "Enable fuzzing" OFF)
8586
option(UNICORN_LOGGING "Enable logging" OFF)
8687
option(UNICORN_BUILD_TESTS "Build unicorn tests" ${PROJECT_IS_TOP_LEVEL})
@@ -1442,16 +1443,18 @@ if (BUILD_SHARED_LIBS)
14421443
endif()
14431444

14441445
# Black magic for generating static archives...
1445-
if (BUILD_SHARED_LIBS)
1446-
if (MSVC)
1447-
# Avoid the import lib built by MVSC clash with our archive.
1448-
set_target_properties(unicorn PROPERTIES ARCHIVE_OUTPUT_NAME "unicorn-import")
1446+
if (UNICORN_LEGACY_STATIC_ARCHIVE)
1447+
if (BUILD_SHARED_LIBS)
1448+
if (MSVC)
1449+
# Avoid the import lib built by MVSC clash with our archive.
1450+
set_target_properties(unicorn PROPERTIES ARCHIVE_OUTPUT_NAME "unicorn-import")
1451+
endif()
1452+
bundle_static_library(unicorn_static unicorn_archive unicorn)
1453+
else()
1454+
# Rename the "static" lib to avoid filename clash.
1455+
set_target_properties(unicorn PROPERTIES OUTPUT_NAME "unicorn-static")
1456+
bundle_static_library(unicorn unicorn_archive unicorn)
14491457
endif()
1450-
bundle_static_library(unicorn_static unicorn_archive unicorn)
1451-
else()
1452-
# Rename the "static" lib to avoid filename clash.
1453-
set_target_properties(unicorn PROPERTIES OUTPUT_NAME "unicorn-static")
1454-
bundle_static_library(unicorn unicorn_archive unicorn)
14551458
endif()
14561459

14571460
if(UNICORN_FUZZ)
@@ -1514,8 +1517,10 @@ if(UNICORN_INSTALL AND NOT MSVC)
15141517
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
15151518
)
15161519
endif()
1517-
install(FILES $<TARGET_FILE:unicorn_archive> DESTINATION ${CMAKE_INSTALL_LIBDIR})
1518-
install(FILES $<TARGET_FILE_DIR:unicorn_archive>/$<TARGET_PROPERTY:unicorn_archive,SYMLINK_NAME> DESTINATION ${CMAKE_INSTALL_LIBDIR})
1520+
if (UNICORN_LEGACY_STATIC_ARCHIVE)
1521+
install(FILES $<TARGET_FILE:unicorn_archive> DESTINATION ${CMAKE_INSTALL_LIBDIR})
1522+
install(FILES $<TARGET_FILE_DIR:unicorn_archive>/$<TARGET_PROPERTY:unicorn_archive,SYMLINK_NAME> DESTINATION ${CMAKE_INSTALL_LIBDIR})
1523+
endif()
15191524
install(FILES ${UNICORN_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/unicorn)
15201525
if (ATOMIC_LINKAGE_FIX)
15211526
set(ATOMIC_LINK_PKG_CONFIG " -latomic")

0 commit comments

Comments
 (0)