Skip to content

Commit

Permalink
[2080,2154,irods/irods_7265] Minor reorganization + CMake TLC
Browse files Browse the repository at this point in the history
- Project tree structure reorganized to match that of main irods repo.
- Removed unused read_shared_memory.cpp.
- Fixed some system #includes not having angle brackets.
- Added quotes around paths in CMake files.
- Changed all instances of CMAKE_SOURCE_DIR to CMAKE_CURRENT_SOURCE_DIR.
- Removed CMAKE_SHARED_LINKER_FLAGS_INIT and
  CMAKE_SHARED_LINKER_FLAGS_RELEASE_INIT, as no shared libraries are built.
- Added IRODS_PLUGINS_DIRECTORY to
  CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION.
- Added CMAKE_EXE_LINKER_FLAGS_INIT and CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT
  for unit tests.
- [2080] Rewrote unit test cmake to match that of main irods repo.
- [2154] Replaced curl-devel package dependency declaration with libcurl
  • Loading branch information
SwooshyCueb committed Mar 6, 2024
1 parent aaf4ad8 commit 7945cb9
Show file tree
Hide file tree
Showing 29 changed files with 310 additions and 397 deletions.
164 changes: 33 additions & 131 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ set(IRODS_PACKAGE_REVISION "0")

include(IrodsCXXCompiler)
set(CMAKE_CXX_STANDARD ${IRODS_CXX_STANDARD})
set(CMAKE_EXE_LINKER_FLAGS_INIT "-Wl,--export-dynamic -Wl,--enable-new-dtags -Wl,--as-needed -Wl,-z,defs")
set(CMAKE_MODULE_LINKER_FLAGS_INIT "-Wl,--enable-new-dtags -Wl,--as-needed -Wl,-z,defs")
set(CMAKE_SHARED_LINKER_FLAGS_INIT "-Wl,--enable-new-dtags -Wl,--as-needed -Wl,-z,defs")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT "-Wl,--gc-sections -Wl,-z,combreloc")
set(CMAKE_MODULE_LINKER_FLAGS_RELEASE_INIT "-Wl,--gc-sections -Wl,-z,combreloc")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE_INIT "-Wl,--gc-sections -Wl,-z,combreloc")
include(IrodsRunpathDefaults)

project(irods_resource_plugin-s3
VERSION "${IRODS_PLUGIN_VERSION}"
LANGUAGES C CXX)

include(${IRODS_TARGETS_PATH})
include("${IRODS_TARGETS_PATH}")

include(GNUInstallDirs)

Expand All @@ -45,6 +45,10 @@ endif()

add_compile_options(-Wall -Wextra)

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fpermissive>)
endif()

if (NOT DEFINED THREADS_PREFER_PTHREAD_FLAG)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
endif()
Expand All @@ -55,147 +59,43 @@ find_package(fmt "8.1.1"
find_package(CURL REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(LibXml2 REQUIRED)

include(ObjectTargetHelpers)

add_library(
libs3_obj
OBJECT
"${CMAKE_CURRENT_SOURCE_DIR}/libs3/src/bucket.c"
"${CMAKE_CURRENT_SOURCE_DIR}/libs3/src/bucket_metadata.c"
"${CMAKE_CURRENT_SOURCE_DIR}/libs3/src/error_parser.c"
"${CMAKE_CURRENT_SOURCE_DIR}/libs3/src/general.c"
"${CMAKE_CURRENT_SOURCE_DIR}/libs3/src/multipart.c"
"${CMAKE_CURRENT_SOURCE_DIR}/libs3/src/object.c"
"${CMAKE_CURRENT_SOURCE_DIR}/libs3/src/request.c"
"${CMAKE_CURRENT_SOURCE_DIR}/libs3/src/request_context.c"
"${CMAKE_CURRENT_SOURCE_DIR}/libs3/src/response_headers_handler.c"
"${CMAKE_CURRENT_SOURCE_DIR}/libs3/src/service.c"
"${CMAKE_CURRENT_SOURCE_DIR}/libs3/src/service_access_logging.c"
"${CMAKE_CURRENT_SOURCE_DIR}/libs3/src/simplexml.c"
"${CMAKE_CURRENT_SOURCE_DIR}/libs3/src/util.c"
)
target_link_libraries(
libs3_obj
PUBLIC
CURL::libcurl
LibXml2::LibXml2
OpenSSL::Crypto
Threads::Threads
)
target_include_directories(
libs3_obj
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/libs3/include>"
)
target_compile_definitions(
libs3_obj
PRIVATE
LIBS3_VER_MAJOR="4"
LIBS3_VER_MINOR="1"
__STRICT_ANSI__
_ISOC99_SOURCE
_POSIX_C_SOURCE=200112L
OPENSSL_API_COMPAT=10100
)
target_compile_options(libs3_obj PRIVATE -Wshadow)
set_target_properties(libs3_obj PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
set_target_properties(libs3_obj PROPERTIES INTERFACE_POSITION_INDEPENDENT_CODE TRUE)
set_target_properties(libs3_obj PROPERTIES EXCLUDE_FROM_ALL TRUE)
add_subdirectory(libs3)
add_subdirectory(s3_transport)
add_subdirectory(s3_resource)
add_subdirectory(unit_tests)

add_library(
irods_s3_plugin
MODULE
${CMAKE_SOURCE_DIR}/s3/libirods_s3.cpp
${CMAKE_SOURCE_DIR}/s3/s3_operations.cpp
${CMAKE_SOURCE_DIR}/s3/s3_transport/src/s3_transport.cpp
)
target_link_objects(irods_s3_plugin PRIVATE libs3_obj)
target_link_libraries(
irods_s3_plugin
PRIVATE
irods_server
irods_common
${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_system.so
${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_thread.so
${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_filesystem.so
Threads::Threads
nlohmann_json::nlohmann_json
fmt::fmt
rt
)
target_include_directories(
add_library(irods_s3_plugin MODULE)
target_link_objects(
irods_s3_plugin
PRIVATE
${IRODS_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/s3/s3_transport/include
${IRODS_EXTERNALS_FULLPATH_BOOST}/include
${IRODS_EXTERNALS_FULLPATH_S3}/include
)
target_compile_definitions(
irods_s3_plugin
PRIVATE
IRODS_QUERY_ENABLE_SERVER_SIDE_API
IRODS_ENABLE_SYSLOG
${IRODS_COMPILE_DEFINITIONS}
${IRODS_COMPILE_DEFINITIONS_PRIVATE}
BOOST_SYSTEM_NO_DEPRECATED
)
libs3_obj
s3_transport_obj
s3_resource_obj
)
set_property(TARGET irods_s3_plugin PROPERTY OUTPUT_NAME s3)

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(irods_s3_plugin PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-fpermissive>)
endif()

target_compile_options(irods_s3_plugin PRIVATE -Wno-unused-parameter)

# due to OPENSSL_NO_DEPRECATED_1_1_0
target_compile_options(irods_s3_plugin PRIVATE -Wno-unused-function)

include(CheckCXXCompilerFlag)

# due to boost headers
check_cxx_compiler_flag(-Wno-error=deprecated-copy CMAKE_CXX_COMPILER_W_DEPRECATED_COPY)
if (CMAKE_CXX_COMPILER_W_DEPRECATED_COPY)
target_compile_options(irods_s3_plugin PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Wno-error=deprecated-copy>)
endif()

install(
TARGETS
irods_s3_plugin
LIBRARY
DESTINATION ${IRODS_PLUGINS_DIRECTORY}/resources
)
DESTINATION "${IRODS_PLUGINS_DIRECTORY}/resources"
)

install(
FILES
${CMAKE_SOURCE_DIR}/packaging/test_irods_resource_plugin_s3.py
${CMAKE_SOURCE_DIR}/packaging/test_irods_resource_plugin_s3_minio.py
${CMAKE_SOURCE_DIR}/packaging/test_irods_resource_plugin_s3_ceph.py
${CMAKE_SOURCE_DIR}/packaging/test_irods_resource_plugin_s3_gcs.py
${CMAKE_SOURCE_DIR}/packaging/test_irods_resource_plugin_s3_fujifilm.py
${CMAKE_SOURCE_DIR}/packaging/resource_suite_s3_nocache.py
${CMAKE_SOURCE_DIR}/packaging/resource_suite_s3_cache.py
${CMAKE_SOURCE_DIR}/packaging/s3plugin_lib.py
DESTINATION ${IRODS_HOME_DIRECTORY}/scripts/irods/test
"${CMAKE_CURRENT_SOURCE_DIR}/packaging/test_irods_resource_plugin_s3.py"
"${CMAKE_CURRENT_SOURCE_DIR}/packaging/test_irods_resource_plugin_s3_minio.py"
"${CMAKE_CURRENT_SOURCE_DIR}/packaging/test_irods_resource_plugin_s3_ceph.py"
"${CMAKE_CURRENT_SOURCE_DIR}/packaging/test_irods_resource_plugin_s3_gcs.py"
"${CMAKE_CURRENT_SOURCE_DIR}/packaging/test_irods_resource_plugin_s3_fujifilm.py"
"${CMAKE_CURRENT_SOURCE_DIR}/packaging/resource_suite_s3_nocache.py"
"${CMAKE_CURRENT_SOURCE_DIR}/packaging/resource_suite_s3_cache.py"
"${CMAKE_CURRENT_SOURCE_DIR}/packaging/s3plugin_lib.py"
DESTINATION "${IRODS_HOME_DIRECTORY}/scripts/irods/test"
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)

if (IRODS_LINUX_DISTRIBUTION_NAME STREQUAL "ubuntu" OR IRODS_LINUX_DISTRIBUTION_NAME STREQUAL "debian")
if (NOT IRODS_PLUGIN_LINUX_DISTRIBUTION_VERSION_CODENAME)
execute_process(
COMMAND "lsb_release" "-s" "-c"
RESULT_VARIABLE IRODS_PLUGIN_EXECUTE_PROCESS_RESULT_LINUX_DISTRIBUTION_VERSION_CODENAME
OUTPUT_VARIABLE IRODS_PLUGIN_LINUX_DISTRIBUTION_VERSION_CODENAME
)
string(STRIP ${IRODS_PLUGIN_LINUX_DISTRIBUTION_VERSION_CODENAME} IRODS_PLUGIN_LINUX_DISTRIBUTION_VERSION_CODENAME)
if (NOT ${IRODS_PLUGIN_EXECUTE_PROCESS_RESULT_LINUX_DISTRIBUTION_VERSION_CODENAME} STREQUAL "0")
message(FATAL_ERROR "Linux lsb_release shortname detection failed\n${IRODS_PLUGIN_EXECUTE_PROCESS_RESULT_LINUX_DISTRIBUTION_VERSION_CODENAME}")
endif()
set(IRODS_PLUGIN_LINUX_DISTRIBUTION_VERSION_CODENAME ${IRODS_PLUGIN_LINUX_DISTRIBUTION_VERSION_CODENAME} CACHE STRING "Linux distribution version codename, e.g. {precise, wheezy, trusty, jessie, ...}." FORCE)
message(STATUS "Setting unspecified IRODS_PLUGIN_LINUX_DISTRIBUTION_VERSION_CODENAME to '${IRODS_PLUGIN_LINUX_DISTRIBUTION_VERSION_CODENAME}'")
endif()
endif()
)

if (NOT CPACK_GENERATOR)
set(CPACK_GENERATOR ${IRODS_CPACK_GENERATOR} CACHE STRING "CPack generator to use, e.g. {DEB, RPM, TGZ}." FORCE)
Expand All @@ -205,6 +105,8 @@ endif()
include(IrodsCPackCommon)

list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX}")
list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX}${IRODS_PLUGINS_DIRECTORY}")
list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX}${IRODS_PLUGINS_DIRECTORY}/resources")
list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX}${IRODS_HOME_DIRECTORY}/scripts")
list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX}${IRODS_HOME_DIRECTORY}/scripts/irods")
list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX}${IRODS_HOME_DIRECTORY}/scripts/irods/test")
Expand Down Expand Up @@ -257,9 +159,9 @@ endif ()

set(CPACK_RPM_PACKAGE_NAME "irods-resource-plugin-s3")
if (IRODS_LINUX_DISTRIBUTION_NAME STREQUAL "opensuse")
set(CPACK_RPM_PACKAGE_REQUIRES "irods-runtime = ${IRODS_VERSION}, curl-devel, libopenssl1_0_0")
set(CPACK_RPM_PACKAGE_REQUIRES "irods-runtime = ${IRODS_VERSION}, libcurl, libopenssl1_0_0")
else()
set(CPACK_RPM_PACKAGE_REQUIRES "irods-runtime = ${IRODS_VERSION}, curl-devel, libxml2")
set(CPACK_RPM_PACKAGE_REQUIRES "irods-runtime = ${IRODS_VERSION}, libcurl, libxml2")
endif()

include(CPack)
49 changes: 49 additions & 0 deletions libs3/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
add_library(
libs3_obj
OBJECT
"${CMAKE_CURRENT_SOURCE_DIR}/src/bucket.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/bucket_metadata.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/error_parser.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/general.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/multipart.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/object.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/request.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/request_context.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/response_headers_handler.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/service.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/service_access_logging.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/simplexml.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/util.c"
)
target_link_libraries(
libs3_obj
PUBLIC
CURL::libcurl
LibXml2::LibXml2
OpenSSL::Crypto
)
target_include_directories(
libs3_obj
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
)
target_compile_definitions(
libs3_obj
PRIVATE
LIBS3_VER_MAJOR="4"
LIBS3_VER_MINOR="1"
__STRICT_ANSI__
_ISOC99_SOURCE
_POSIX_C_SOURCE=200112L
OPENSSL_API_COMPAT=10100
)
target_compile_options(
libs3_obj
PRIVATE
-Wshadow
-Wno-unused-function # due to OPENSSL_NO_DEPRECATED_1_1_0
)
set_target_properties(libs3_obj PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
set_target_properties(libs3_obj PROPERTIES INTERFACE_POSITION_INDEPENDENT_CODE TRUE)

set_target_properties(libs3_obj PROPERTIES EXCLUDE_FROM_ALL TRUE)
61 changes: 0 additions & 61 deletions s3/s3_transport/read_shared_memory.cpp

This file was deleted.

Loading

0 comments on commit 7945cb9

Please sign in to comment.