Skip to content

Commit

Permalink
[irods/irods_7265] Minor reorganization + CMake TLC
Browse files Browse the repository at this point in the history
- Project tree structure reorganized to resemble that of main irods repo.
- Added quotes around paths in CMake files.
- Removed CMAKE_SHARED_LINKER_FLAGS_INIT and
  CMAKE_SHARED_LINKER_FLAGS_RELEASE_INIT, as no shared libraries are built.
- Removed unused postinst script for nonexistent data_world package
- Removed rpm package dependency declaration on openssl
- Fixed postinst CPack variables
  • Loading branch information
SwooshyCueb committed Mar 12, 2024
1 parent 88bbf7b commit e174396
Show file tree
Hide file tree
Showing 23 changed files with 229 additions and 230 deletions.
57 changes: 27 additions & 30 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,59 +1,72 @@
cmake_minimum_required(VERSION 3.5.0 FATAL_ERROR) #CPACK_DEBIAN_<COMPONENT>_PACKAGE_NAME
cmake_minimum_required(VERSION 3.12.0 FATAL_ERROR)

find_package(IRODS 4.3.1 EXACT REQUIRED)
set(IRODS_MINIMUM_VERSION "4.3.1")
find_package(IRODS "${IRODS_MINIMUM_VERSION}" REQUIRED)
set(IRODS_PLUGIN_REVISION "0")
set(IRODS_PLUGIN_VERSION "${IRODS_VERSION}.${IRODS_PLUGIN_REVISION}")
set(IRODS_PLUGIN_VERSION "${IRODS_MINIMUM_VERSION}.${IRODS_PLUGIN_REVISION}")

set(IRODS_PACKAGE_REVISION "0")

include(IrodsCXXCompiler)
set(CMAKE_CXX_STANDARD ${IRODS_CXX_STANDARD})
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_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)

set(IRODS_TARGET_NAME_PREFIX irods_rule_engine_plugin)

project(irods_capability-indexing
VERSION "${IRODS_PLUGIN_VERSION}"
LANGUAGES CXX)
VERSION "${IRODS_PLUGIN_VERSION}"
LANGUAGES CXX)

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

include(GNUInstallDirs)
include(UseLibCXX)

if (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build {Debug, Release}." FORCE)
message(STATUS "Setting unspecified CMAKE_BUILD_TYPE to '${CMAKE_BUILD_TYPE}'")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build {Debug, Release}." FORCE)
message(STATUS "Setting unspecified CMAKE_BUILD_TYPE to '${CMAKE_BUILD_TYPE}'")
endif()

set(IRODS_BUILD_WITH_WERROR OFF CACHE BOOL "Choose whether to compile with -Werror.")

if (IRODS_BUILD_WITH_WERROR)
add_compile_options(-Werror)
add_compile_options(-Werror)
endif()

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

if (NOT DEFINED THREADS_PREFER_PTHREAD_FLAG)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
endif()
find_package(Threads REQUIRED)
find_package(nlohmann_json "3.6.1" REQUIRED)
find_package(OpenSSL REQUIRED)

add_subdirectory(common)
add_subdirectory(indexing)
add_subdirectory(elasticsearch)

if (NOT CPACK_GENERATOR)
set(CPACK_GENERATOR ${IRODS_CPACK_GENERATOR} CACHE STRING "CPack generator to use, e.g. {DEB, RPM, TGZ}." FORCE)
message(STATUS "Setting unspecified CPACK_GENERATOR to ${CPACK_GENERATOR}. This is the correct setting for normal builds.")
set(CPACK_GENERATOR ${IRODS_CPACK_GENERATOR} CACHE STRING "CPack generator to use, e.g. {DEB, RPM, TGZ}." FORCE)
message(STATUS "Setting unspecified CPACK_GENERATOR to ${CPACK_GENERATOR}. This is the correct setting for normal builds.")
endif()

# CPACK_DEBIAN_PACKAGE_VERSION was previously a cache variable. Evict it.
unset(CPACK_DEBIAN_PACKAGE_VERSION CACHE)

include(IrodsCPackCommon)

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}/rule_engines")
list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX}${IRODS_HOME_DIRECTORY}")
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")

set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
set(CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY OFF)
set(CPACK_COMPONENTS_GROUPING IGNORE)
Expand All @@ -73,20 +86,4 @@ set(CPACK_RPM_FILE_NAME RPM-DEFAULT)

set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)

# CPACK names component package files as "${CPACK_PACKAGE_FILE_NAME}-${COMPONENT_NAME}"
# CPackDeb TO_UPPERs all the component names when checking the ${CPACK_DEBIAN_<COMPONENT>...} variables

include(${CMAKE_CURRENT_SOURCE_DIR}/indexing.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/elasticsearch.cmake)

list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX}${CMAKE_INSTALL_LIBDIR}/irods")
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}/rule_engines")
list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX}${CMAKE_INSTALL_LOCALSTATEDIR}")
list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX}${CMAKE_INSTALL_LOCALSTATEDIR}/lib")
list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX}${IRODS_HOME_DIRECTORY}")
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")

include(CPack)
36 changes: 36 additions & 0 deletions common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
add_library(
irods_cap_indexing_common_obj
OBJECT
"${CMAKE_CURRENT_SOURCE_DIR}/src/plugin_specific_configuration.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/configuration.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/utilities.cpp"
)
target_link_libraries(
irods_cap_indexing_common_obj
PUBLIC
irods_common
irods_server
nlohmann_json::nlohmann_json
PRIVATE
"${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_system.so"
"${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_filesystem.so"
"${IRODS_EXTERNALS_FULLPATH_FMT}/lib/libfmt.so"
)
target_include_directories(
irods_cap_indexing_common_obj
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
PRIVATE
"${IRODS_EXTERNALS_FULLPATH_BOOST}/include"
"${IRODS_EXTERNALS_FULLPATH_FMT}/include"
)
target_compile_definitions(
irods_cap_indexing_common_obj
PUBLIC
BOOST_SYSTEM_NO_DEPRECATED
RODS_SERVER
ENABLE_RE
PRIVATE
${IRODS_COMPILE_DEFINITIONS}
${IRODS_COMPILE_DEFINITIONS_PRIVATE}
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions configuration.cpp → common/src/configuration.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "configuration.hpp"
#include "irods/private/indexing/configuration.hpp"

#include "plugin_specific_configuration.hpp"
#include "irods/private/indexing/plugin_specific_configuration.hpp"

#include <irods/rodsLog.h>
#include <irods/irods_log.hpp>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "plugin_specific_configuration.hpp"
#include "irods/private/indexing/plugin_specific_configuration.hpp"

#include <irods/irods_exception.hpp>
#include <irods/irods_server_properties.hpp>
Expand Down
2 changes: 1 addition & 1 deletion utilities.cpp → common/src/utilities.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "utilities.hpp"
#include "irods/private/indexing/utilities.hpp"

#include <irods/rcMisc.h>

Expand Down
84 changes: 0 additions & 84 deletions elasticsearch.cmake

This file was deleted.

70 changes: 70 additions & 0 deletions elasticsearch/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
set(IRODS_POLICY_NAME "elasticsearch")
set(IRODS_PLUGIN_TARGET_NAME "${IRODS_TARGET_NAME_PREFIX}-${IRODS_POLICY_NAME}")

string(REPLACE "_" "-" IRODS_POLICY_NAME_HYPHENS "${IRODS_POLICY_NAME}")
set(IRODS_POLICY_PACKAGE_COMPONENT "${IRODS_POLICY_NAME_HYPHENS}")

include(ObjectTargetHelpers)

add_library(
"${IRODS_PLUGIN_TARGET_NAME}"
MODULE
"${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp"
)
target_link_objects(
"${IRODS_PLUGIN_TARGET_NAME}"
PRIVATE
irods_cap_indexing_common_obj
)
target_link_libraries(
"${IRODS_PLUGIN_TARGET_NAME}"
PRIVATE
irods_common
irods_server
nlohmann_json::nlohmann_json
"${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_system.so"
"${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_url.so"
"${IRODS_EXTERNALS_FULLPATH_FMT}/lib/libfmt.so"
)
target_include_directories(
"${IRODS_PLUGIN_TARGET_NAME}"
PRIVATE
"${IRODS_EXTERNALS_FULLPATH_BOOST}/include"
"${IRODS_EXTERNALS_FULLPATH_FMT}/include"
)
target_compile_definitions(
"${IRODS_PLUGIN_TARGET_NAME}"
PRIVATE
BOOST_SYSTEM_NO_DEPRECATED
RODS_SERVER
ENABLE_RE
${IRODS_COMPILE_DEFINITIONS}
${IRODS_COMPILE_DEFINITIONS_PRIVATE}
IRODS_PLUGIN_VERSION="${IRODS_PLUGIN_VERSION}"
)
target_compile_options(
"${IRODS_PLUGIN_TARGET_NAME}"
PRIVATE
-Wno-write-strings
)

install(
TARGETS
"${IRODS_PLUGIN_TARGET_NAME}"
LIBRARY
DESTINATION "${IRODS_PLUGINS_DIRECTORY}/rule_engines"
COMPONENT "${IRODS_POLICY_PACKAGE_COMPONENT}"
)

string(TOUPPER "${IRODS_POLICY_PACKAGE_COMPONENT}" IRODS_POLICY_PACKAGE_COMPONENT_UPPERCASE)
string(REPLACE "_" "-" IRODS_PLUGIN_TARGET_NAME_HYPHENS "${IRODS_PLUGIN_TARGET_NAME}")

# CPack variables need to be set with PARENT_SCOPE, so they will be in scope for CPack.

set(CPACK_DEBIAN_${IRODS_POLICY_PACKAGE_COMPONENT_UPPERCASE}_PACKAGE_NAME "${IRODS_PLUGIN_TARGET_NAME_HYPHENS}" PARENT_SCOPE)
set(CPACK_DEBIAN_${IRODS_POLICY_PACKAGE_COMPONENT_UPPERCASE}_PACKAGE_DEPENDS "irods-server (= ${IRODS_VERSION}), irods-runtime (= ${IRODS_VERSION}), libc6" PARENT_SCOPE)
set(CPACK_DEBIAN_${IRODS_POLICY_PACKAGE_COMPONENT_UPPERCASE}_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/packaging/postinst;" PARENT_SCOPE)

set(CPACK_RPM_${IRODS_POLICY_PACKAGE_COMPONENT_UPPERCASE}_PACKAGE_NAME "${IRODS_PLUGIN_TARGET_NAME_HYPHENS}" PARENT_SCOPE)
set(CPACK_RPM_${IRODS_POLICY_PACKAGE_COMPONENT_UPPERCASE}_PACKAGE_REQUIRES "irods-server = ${IRODS_VERSION}, irods-runtime = ${IRODS_VERSION}" PARENT_SCOPE)
set(CPACK_RPM_${IRODS_POLICY_PACKAGE_COMPONENT_UPPERCASE}_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/packaging/postinst" PARENT_SCOPE)
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "configuration.hpp"
#include "plugin_specific_configuration.hpp"
#include "utilities.hpp"
#include "irods/private/indexing/configuration.hpp"
#include "irods/private/indexing/plugin_specific_configuration.hpp"
#include "irods/private/indexing/utilities.hpp"

#include <irods/MD5Strategy.hpp>
#include <irods/irods_hasher_factory.hpp>
Expand Down
Loading

0 comments on commit e174396

Please sign in to comment.