diff --git a/CMakeLists.txt b/CMakeLists.txt index f589fb72f..b01852c71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,16 +82,18 @@ endif() add_subdirectory(lib_acl acl) add_subdirectory(lib_protocol protocol) add_subdirectory(lib_acl_cpp acl_cpp) + if (ACL_BUILD_SHARED MATCHES "YES") - add_dependencies(protocol acl) - add_dependencies(acl_cpp protocol acl) + add_dependencies(protocol_shared acl_shared) + add_dependencies(acl_cpp_shared protocol_shared acl_shared) endif() #if (CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Android") #if (CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Darwin") add_subdirectory(lib_fiber/c fiber) add_subdirectory(lib_fiber/cpp fiber_cpp) + if (ACL_BUILD_SHARED MATCHES "YES") - add_dependencies(fiber_cpp acl_cpp protocol acl fiber) + add_dependencies(fiber_cpp_shared acl_cpp_shared protocol_shared acl_shared fiber_shared) endif() #endif() diff --git a/android/acl_c++_shared/acl_c++_shared.iml b/android/acl_c++_shared/acl_c++_shared.iml index 70021466e..8a977cd63 100644 --- a/android/acl_c++_shared/acl_c++_shared.iml +++ b/android/acl_c++_shared/acl_c++_shared.iml @@ -98,6 +98,8 @@ + + diff --git a/android/acl_c++_shared/build.gradle b/android/acl_c++_shared/build.gradle index 8670f6299..319f5e593 100644 --- a/android/acl_c++_shared/build.gradle +++ b/android/acl_c++_shared/build.gradle @@ -58,7 +58,7 @@ android { cmake { //arguments '-DANDROID_PLATFORM=android-14','-DANDROID_TOOLCHAIN=clang' //targets 'acl_static', 'protocol_static', 'acl_cpp_static', 'fiber_static', 'fiber_cpp_static' // for ndk12b, ndk16b - targets 'acl_static', 'protocol_static', 'acl_cpp_static', 'fiber_static', 'fiber_cpp_static', 'acl', 'protocol', 'acl_cpp', 'fiber', 'fiber_cpp' // for ndk20 or above + targets 'acl_static', 'protocol_static', 'acl_cpp_static', 'fiber_static', 'fiber_cpp_static', 'acl_shared', 'protocol_shared', 'acl_cpp_shared', 'fiber_shared', 'fiber_cpp_shared' // for ndk20 or above } } } diff --git a/lib_acl/CMakeLists.txt b/lib_acl/CMakeLists.txt index 4e5550117..a24d07cd5 100644 --- a/lib_acl/CMakeLists.txt +++ b/lib_acl/CMakeLists.txt @@ -191,6 +191,21 @@ endif() link_directories(${lib_output_path}) +if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Darwin") + install(TARGETS acl_static + EXPORT acl_static-targets + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) +endif() + +if (CMAKE_INSTALL_INCLUDEDIR MATCHES "") + set(CMAKE_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_PREFIX}/include) +endif() + +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/acl-lib/acl/" +) + if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR AND ACL_BUILD_SHARED MATCHES "YES") if (CMAKE_SYSTEM_NAME MATCHES "Android") if (ANDROID_STL MATCHES "gnustl_shared") @@ -208,7 +223,21 @@ if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR AND ACL_BUILD_SHARED endif() set(CMAKE_SHARED_LINKER_FLAGS "${sys_ldflags}") - add_library(acl SHARED ${lib_src}) + add_library(acl_shared SHARED ${lib_src}) + + if (${WIN_OS}) + SET_TARGET_PROPERTIES(acl_shared PROPERTIES OUTPUT_NAME "libacl") + else() + SET_TARGET_PROPERTIES(acl_shared PROPERTIES OUTPUT_NAME "acl") + endif() + + if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Darwin") + install(TARGETS acl_shared + EXPORT acl_shared-targets + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) + endif() endif() + ############################################################################## diff --git a/lib_acl_cpp/CMakeLists.txt b/lib_acl_cpp/CMakeLists.txt index 7faa9ad2f..d9dfd9380 100644 --- a/lib_acl_cpp/CMakeLists.txt +++ b/lib_acl_cpp/CMakeLists.txt @@ -253,6 +253,21 @@ endif() link_directories(${lib_output_path}) +if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Darwin") + install(TARGETS acl_cpp_static + EXPORT acl_cpp_static-targets + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) +endif() + +if (CMAKE_INSTALL_INCLUDEDIR MATCHES "") + set(CMAKE_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_PREFIX}/include) +endif() + +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/acl_cpp/ + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/acl-lib/acl_cpp/" +) + if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR AND ACL_BUILD_SHARED MATCHES "YES") if (CMAKE_SYSTEM_NAME MATCHES "Android") if (ANDROID_STL MATCHES "gnustl_shared") @@ -279,12 +294,21 @@ if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR AND ACL_BUILD_SHARED if (ACL_BUILD_SHARED_ONE MATCHES "YES") set(lc_flags "${lib_output_path}/libprotocol.a ${lib_output_path}/libacl.a") set(CMAKE_SHARED_LINKER_FLAGS "${lc_flags} ${sys_ldflags}") - add_library(acl_cpp SHARED ${lib_src}) + add_library(acl_cpp_shared SHARED ${lib_src}) else() set(lc_flags "-Wl,-rpath,. -L${lib_output_path} -lprotocol -lacl") set(CMAKE_SHARED_LINKER_FLAGS "${lc_flags} ${sys_ldflags}") - add_library(acl_cpp SHARED ${lib_src}) - target_link_libraries(acl_cpp protocol acl) + add_library(acl_cpp_shared SHARED ${lib_src}) + target_link_libraries(acl_cpp_shared protocol acl) + endif() + + SET_TARGET_PROPERTIES(acl_cpp_shared PROPERTIES OUTPUT_NAME "acl_cpp") + + if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Darwin") + install(TARGETS acl_cpp_shared + EXPORT acl_cpp_shared-targets + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) endif() endif() diff --git a/lib_fiber/c/CMakeLists.txt b/lib_fiber/c/CMakeLists.txt index e6e1b7d2f..fafd5a43c 100644 --- a/lib_fiber/c/CMakeLists.txt +++ b/lib_fiber/c/CMakeLists.txt @@ -153,6 +153,21 @@ endif() link_directories(${lib_output_path}) +if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Darwin") + install(TARGETS fiber_static + EXPORT fiber_static-targets + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) +endif() + +if (CMAKE_INSTALL_INCLUDEDIR MATCHES "") + set(CMAKE_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_PREFIX}/include) +endif() + +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/fiber/ + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/acl-lib/fiber" +) + if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR AND ACL_BUILD_SHARED MATCHES "YES") if (CMAKE_SYSTEM_NAME MATCHES "Android") if (ANDROID_STL MATCHES "gnustl_shared") @@ -167,7 +182,15 @@ if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR AND ACL_BUILD_SHARED endif() set(CMAKE_SHARED_LINKER_FLAGS "${sys_ldflags}") - add_library(fiber SHARED ${lib_src}) + add_library(fiber_shared SHARED ${lib_src}) + SET_TARGET_PROPERTIES(fiber_shared PROPERTIES OUTPUT_NAME "fiber") + + if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Darwin") + install(TARGETS fiber_shared + EXPORT fiber_shared-targets + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) + endif() endif() ############################################################################## diff --git a/lib_fiber/cpp/CMakeLists.txt b/lib_fiber/cpp/CMakeLists.txt index a60ac4380..4bf53079c 100644 --- a/lib_fiber/cpp/CMakeLists.txt +++ b/lib_fiber/cpp/CMakeLists.txt @@ -139,6 +139,21 @@ endif() link_directories(${lib_output_path}) +if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Darwin") + install(TARGETS fiber_cpp_static + EXPORT fiber_cpp_static-targets + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) +endif() + +if (CMAKE_INSTALL_INCLUDEDIR MATCHES "") + set(CMAKE_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_PREFIX}/include) +endif() + +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/fiber/ + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/acl-lib/fiber_cpp" +) + if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR AND ACL_BUILD_SHARED MATCHES "YES") if (CMAKE_SYSTEM_NAME MATCHES "Android") if (ANDROID_STL MATCHES "gnustl_shared") @@ -161,12 +176,21 @@ if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR AND ACL_BUILD_SHARED if (ACL_BUILD_SHARED_ONE MATCHES "YES") set(lc_ldflags "${lib_output_path}/libacl_cpp.a ${lib_output_path}/libprotocol.a ${lib_output_path}/libacl.a ${lib_output_path}/libfiber.a") set(CMAKE_SHARED_LINKER_FLAGS "${lc_ldflags} ${sys_ldflags}") - add_library(fiber_cpp SHARED ${lib_src}) + add_library(fiber_cpp_shared SHARED ${lib_src}) else() set(lc_ldflags "-Wl,-rpath,. -L${lib_output_path} -lacl_cpp -lprotocol -lacl -lfiber") set(CMAKE_SHARED_LINKER_FLAGS "${lc_ldflags} ${sys_ldflags}") - add_library(fiber_cpp SHARED ${lib_src}) - target_link_libraries(fiber_cpp acl_cpp protocol acl fiber) + add_library(fiber_cpp_shared SHARED ${lib_src}) + target_link_libraries(fiber_cpp_shared acl_cpp protocol acl fiber) + endif() + + SET_TARGET_PROPERTIES(fiber_cpp_shared PROPERTIES OUTPUT_NAME "fiber_cpp") + + if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Darwin") + install(TARGETS fiber_cpp_shared + EXPORT fiber_cpp_shared-targets + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) endif() endif() diff --git a/lib_protocol/CMakeLists.txt b/lib_protocol/CMakeLists.txt index 8ef7edfc9..4fa469d39 100644 --- a/lib_protocol/CMakeLists.txt +++ b/lib_protocol/CMakeLists.txt @@ -139,6 +139,21 @@ endif() link_directories(${lib_output_path}) +if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Darwin") + install(TARGETS protocol_static + EXPORT protocol_static-targets + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) +endif() + +if (CMAKE_INSTALL_INCLUDEDIR MATCHES "") + set(CMAKE_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_PREFIX}/include) +endif() + +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/acl-lib/protocol/" +) + if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR AND ACL_BUILD_SHARED MATCHES "YES") if (CMAKE_SYSTEM_NAME MATCHES "Android") if (ANDROID_STL MATCHES "gnustl_shared") @@ -158,12 +173,21 @@ if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR AND ACL_BUILD_SHARED if (ACL_BUILD_SHARED_ONE MATCHES "YES") set(lc_flags "${lib_output_path}/libacl.a") set(CMAKE_SHARED_LINKER_FLAGS "${lc_flags} ${sys_ldflags}") - add_library(protocol SHARED ${lib_src}) + add_library(protocol_shared SHARED ${lib_src}) else() set(lc_flags "-Wl,-rpath,. -L${lib_output_path} -lacl") set(CMAKE_SHARED_LINKER_FLAGS "${lc_flags} ${sys_ldflags}") - add_library(protocol SHARED ${lib_src}) - target_link_libraries(protocol acl) + add_library(protocol_shared SHARED ${lib_src}) + target_link_libraries(protocol_shared acl) + endif() + + SET_TARGET_PROPERTIES(protocol_shared PROPERTIES OUTPUT_NAME "protocol") + + if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Darwin") + install(TARGETS protocol_shared + EXPORT protocol_shared-targets + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) endif() endif()