1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-11-22 09:29:52 +03:00

Merge PR #761: CMake: build Cedar and Mayaqua as shared libraries, create "common" package

This commit is contained in:
Davide Beatrici 2018-10-20 14:38:59 +02:00 committed by GitHub
commit c1d6ddf361
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 16 deletions

View File

@ -36,7 +36,7 @@ set(BUILD_DIRECTORY ${SoftEtherVPN_SOURCE_DIR}/build)
add_subdirectory(src) add_subdirectory(src)
# Packaging # Packaging
set(CPACK_COMPONENTS_ALL vpnserver vpnclient vpnbridge vpncmd) set(CPACK_COMPONENTS_ALL common vpnserver vpnclient vpnbridge vpncmd)
set(CPACK_PACKAGE_DIRECTORY ${BUILD_DIRECTORY}) set(CPACK_PACKAGE_DIRECTORY ${BUILD_DIRECTORY})
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_PACKAGE_VENDOR "SoftEther") set(CPACK_PACKAGE_VENDOR "SoftEther")

View File

@ -1,22 +1,22 @@
file(GLOB SOURCES_CEDAR "*.c") file(GLOB SOURCES_CEDAR "*.c")
file(GLOB HEADERS_CEDAR "*.h") file(GLOB HEADERS_CEDAR "*.h")
add_library(cedar STATIC ${SOURCES_CEDAR} ${HEADERS_CEDAR}) add_library(cedar SHARED ${SOURCES_CEDAR} ${HEADERS_CEDAR})
set_target_properties(cedar set_target_properties(cedar
PROPERTIES PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/tmp/Cedar" ARCHIVE_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/tmp/Cedar" LIBRARY_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/tmp/Cedar" RUNTIME_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}"
) )
find_library(LIB_READLINE readline) find_library(LIB_READLINE readline)
find_package(Curses REQUIRED) find_package(Curses REQUIRED)
target_link_libraries(cedar ${LIB_READLINE} ${CURSES_LIBRARIES}) target_link_libraries(cedar PRIVATE ${LIB_READLINE} ${CURSES_LIBRARIES})
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
target_link_libraries(cedar pcap) target_link_libraries(cedar PRIVATE mayaqua pcap)
endif() endif()
# Version # Version
@ -54,3 +54,9 @@ message(STATUS "Build time: ${BUILD_HOUR}:${BUILD_MINUTE}:${BUILD_SECOND}")
add_definitions(-DBUILD_DATE_D=${BUILD_DAY} -DBUILD_DATE_M=${BUILD_MONTH} -DBUILD_DATE_Y=${BUILD_YEAR}) add_definitions(-DBUILD_DATE_D=${BUILD_DAY} -DBUILD_DATE_M=${BUILD_MONTH} -DBUILD_DATE_Y=${BUILD_YEAR})
add_definitions(-DBUILD_DATE_HO=${BUILD_HOUR} -DBUILD_DATE_MI=${BUILD_MINUTE} -DBUILD_DATE_SE=${BUILD_SECOND}) add_definitions(-DBUILD_DATE_HO=${BUILD_HOUR} -DBUILD_DATE_MI=${BUILD_MINUTE} -DBUILD_DATE_SE=${BUILD_SECOND})
install(TARGETS cedar
COMPONENT "common"
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)

View File

@ -1,15 +1,15 @@
file(GLOB SOURCES_MAYAQUA "*.c") file(GLOB SOURCES_MAYAQUA "*.c")
file(GLOB HEADERS_MAYAQUA "*.h") file(GLOB HEADERS_MAYAQUA "*.h")
add_library(mayaqua STATIC ${SOURCES_MAYAQUA} ${HEADERS_MAYAQUA}) add_library(mayaqua SHARED ${SOURCES_MAYAQUA} ${HEADERS_MAYAQUA})
target_include_directories(mayaqua PUBLIC .) target_include_directories(mayaqua PUBLIC .)
set_target_properties(mayaqua set_target_properties(mayaqua
PROPERTIES PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/tmp/Mayaqua" ARCHIVE_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/tmp/Mayaqua" LIBRARY_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/tmp/Mayaqua" RUNTIME_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}"
) )
find_package(OpenSSL REQUIRED) find_package(OpenSSL REQUIRED)
@ -21,27 +21,34 @@ find_library(LIB_ICONV iconv)
if(HAVE_SYS_AUXV) if(HAVE_SYS_AUXV)
add_subdirectory(cpu_features) add_subdirectory(cpu_features)
set_property(TARGET cpu_features PROPERTY POSITION_INDEPENDENT_CODE ON)
endif() endif()
target_include_directories(mayaqua PRIVATE cpu_features/include) target_include_directories(mayaqua PRIVATE cpu_features/include)
target_link_libraries(mayaqua OpenSSL::SSL OpenSSL::Crypto Threads::Threads ZLIB::ZLIB) target_link_libraries(mayaqua PRIVATE OpenSSL::SSL OpenSSL::Crypto Threads::Threads ZLIB::ZLIB)
if(HAVE_SYS_AUXV) if(HAVE_SYS_AUXV)
target_link_libraries(mayaqua cpu_features) target_link_libraries(mayaqua PRIVATE cpu_features)
else() else()
add_definitions(-DSKIP_CPU_FEATURES) add_definitions(-DSKIP_CPU_FEATURES)
endif() endif()
find_library(LIB_RT rt) find_library(LIB_RT rt)
if(LIB_RT) if(LIB_RT)
target_link_libraries(mayaqua rt) target_link_libraries(mayaqua PRIVATE ${LIB_RT})
endif() endif()
if(LIB_ICONV) if(LIB_ICONV)
target_link_libraries(mayaqua ${LIB_ICONV}) target_link_libraries(mayaqua PRIVATE ${LIB_ICONV})
endif() endif()
if(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS") if(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS")
target_link_libraries(mayaqua nsl socket) target_link_libraries(mayaqua PRIVATE nsl socket)
endif() endif()
install(TARGETS mayaqua
COMPONENT "common"
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)