summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryangwei <[email protected]>2020-09-10 15:38:49 +0800
committeryangwei <[email protected]>2020-09-10 15:38:49 +0800
commitf15a1fd61717c8547249c0d512ff8976a5ad4cfc (patch)
tree99244f512978783dd4942513d676dc23c8b53e89
parentd42c5eeb0fe737aaef278c64f6838d82c1ec2efd (diff)
zlog使用动态链接
-rw-r--r--CMakeLists.txt4
-rw-r--r--zlog/CMakeLists.txt9
2 files changed, 7 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 03ce26c..689a8fb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -37,7 +37,7 @@ add_subdirectory(zlog)
# Shared Library Output
add_library(${lib_name}_shared SHARED src/MESA_handle_logger.c)
-target_link_libraries(${lib_name}_shared zlog-static)
+target_link_libraries(${lib_name}_shared zlog_shared)
set_target_properties(${lib_name}_shared PROPERTIES LINK_FLAGS
"-Wl,--version-script=${PROJECT_SOURCE_DIR}/src/version.map")
@@ -52,7 +52,7 @@ set_target_properties(${lib_name}_shared PROPERTIES SOVERSION ${LIB_MAJOR_VERSIO
# static Library Output
add_library(${lib_name}_static STATIC src/MESA_handle_logger.c)
-target_link_libraries(${lib_name}_static -Wl,--whole-archive zlog-static -Wl,--no-whole-archive)
+target_link_libraries(${lib_name}_static zlog_shared)
set_target_properties(${lib_name}_static PROPERTIES OUTPUT_NAME ${lib_name})
set(CMAKE_INSTALL_PREFIX /opt/MESA)
diff --git a/zlog/CMakeLists.txt b/zlog/CMakeLists.txt
index b36779f..574e936 100644
--- a/zlog/CMakeLists.txt
+++ b/zlog/CMakeLists.txt
@@ -14,10 +14,11 @@ ExternalProject_Get_Property(zlog SOURCE_DIR)
file(MAKE_DIRECTORY ${SOURCE_DIR}/src/)
-add_library(zlog-static STATIC IMPORTED GLOBAL)
-add_dependencies(zlog-static zlog)
-set_property(TARGET zlog-static PROPERTY IMPORTED_LOCATION ${SOURCE_DIR}/src/libzlog.a)
-set_property(TARGET zlog-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${SOURCE_DIR}/src)
+add_library(zlog_shared SHARED IMPORTED GLOBAL)
+add_dependencies(zlog_shared zlog)
+set_property(TARGET zlog_shared PROPERTY IMPORTED_LOCATION ${SOURCE_DIR}/src/libzlog.so)
+set_property(TARGET zlog_shared PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${SOURCE_DIR}/src)
install(PROGRAMS ${SOURCE_DIR}/src/zlog-chk-conf DESTINATION bin COMPONENT EXECUTABLE)
+install(PROGRAMS ${SOURCE_DIR}/src/libzlog.so DESTINATION lib COMPONENT LIBRARIES)