Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow aliases in middlewares [12151] #158

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
166 changes: 89 additions & 77 deletions core/cmake/is_install_middleware_plugin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
# [DEPENDENCIES <middleware dependencies>]
# [EXTENSIONS <files_of_config_extensions>]
# [BUILD_DIR <relative_directory>]
# [ALIAS <system_alias>]
# )
#
# MIDDLEWARE: The name of the middleware. The resulting package will be called
Expand Down Expand Up @@ -51,6 +52,9 @@
# BUILD_DIR: The absolute path where the mix files for this middleware should be
# configured and where the library will be placed. If this argument is not
# specified, the default will be ${CMAKE_BINARY_DIR}/is/<middleware-name>/lib.
#
# ALIAS: The alias given in this parameter will be used as other name for the
# middleware and will create the .mix file associated.
include(GNUInstallDirs)

function(is_install_middleware_plugin)
Expand All @@ -60,104 +64,112 @@ function(is_install_middleware_plugin)
_ARG # prefix
"NO_CONFIG" # options
"MIDDLEWARE;TARGET;BUILD_DIR" # one-value arguments
"TYPES;DEPENDENCIES;EXTENSIONS" # multi-value arguments
"TYPES;DEPENDENCIES;EXTENSIONS;ALIAS" # multi-value arguments
${ARGN}
)

set(middleware ${_ARG_MIDDLEWARE})
set(plugin_library_target ${_ARG_TARGET})

if(NOT _ARG_TYPES)
set(system_types ${middleware})
else()
set(system_types ${_ARG_TYPES})
endif()
message(STATUS "#! is_install_middleware_plugin called with aliases ${_ARG_ALIAS}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
message(STATUS "#! is_install_middleware_plugin called with aliases ${_ARG_ALIAS}")
message(STATUS "The macro is_install_middleware_plugin is called for the middleware ${_ARG_MIDDLEWARE} with aliases ${_ARG_ALIAS}")


install(
TARGETS ${plugin_library_target}
EXPORT ${plugin_library_target}
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT ${plugin_library_target}
)
# Make the process once per valid name of the middleware
set(_MIDDLEWARE_ALIASES ${_ARG_MIDDLEWARE} ${_ARG_ALIAS})
foreach(middleware_name ${_MIDDLEWARE_ALIASES})

if(_ARG_BUILD_DIR)
set(mix_build_dir "${_ARG_BUILD_DIR}")
else()
set(mix_build_dir "${CMAKE_BINARY_DIR}/is/${middleware}/lib")
endif()

set_target_properties(${plugin_library_target} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${mix_build_dir}
)
set(middleware ${middleware_name})
set(plugin_library_target ${_ARG_TARGET})

set(plugin_library_extension $<IF:$<PLATFORM_ID:Windows>,"dll","dl">)
if(NOT _ARG_TYPES)
set(system_types ${middleware})
else()
set(system_types ${_ARG_TYPES})
endif()

foreach(type ${system_types})
set(plugin_library_mix_template "${mix_build_dir}/is/${type}/${type}.mix.gen")
set(plugin_library_directory "../..")
configure_file(
"${IS_TEMPLATE_DIR}/plugin_library.mix.in"
"${plugin_library_mix_template}"
@ONLY
install(
TARGETS ${plugin_library_target}
EXPORT ${plugin_library_target}
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT ${plugin_library_target}
)

set(plugin_library_mix "${mix_build_dir}/is/${type}/${type}.mix")
set(plugin_library_install_mix "${CMAKE_INSTALL_PREFIX}/lib/is/${type}/${type}.mix")

file(GENERATE
OUTPUT ${plugin_library_mix}
INPUT ${plugin_library_mix_template}
)
if(_ARG_BUILD_DIR)
set(mix_build_dir "${_ARG_BUILD_DIR}")
else()
set(mix_build_dir "${CMAKE_BINARY_DIR}/is/${middleware}/lib")
endif()

file(GENERATE
OUTPUT ${plugin_library_install_mix}
INPUT ${plugin_library_mix_template}
set_target_properties(${plugin_library_target} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${mix_build_dir}
)

endforeach()
set(plugin_library_extension $<IF:$<PLATFORM_ID:Windows>,"dll","dl">)

if(NOT _ARG_NO_CONFIG)
foreach(type ${system_types})
set(plugin_library_mix_template "${mix_build_dir}/is/${type}/${type}.mix.gen")
set(plugin_library_directory "../..")
configure_file(
"${IS_TEMPLATE_DIR}/plugin_library.mix.in"
"${plugin_library_mix_template}"
@ONLY
)

set(config_install_dir ${CMAKE_INSTALL_LIBDIR}/cmake/is-${middleware})
set(plugin_library_mix "${mix_build_dir}/is/${type}/${type}.mix")
set(plugin_library_install_mix "${CMAKE_INSTALL_PREFIX}/lib/is/${type}/${type}.mix")

set(extensions)
foreach(extension ${_ARG_EXTENSIONS})
get_filename_component(ext_filename ${extension} NAME)
list(APPEND extensions ${ext_filename})
endforeach()
file(GENERATE
OUTPUT ${plugin_library_mix}
INPUT ${plugin_library_mix_template}
)

export(
TARGETS
${plugin_library_target}
FILE
${CMAKE_INSTALL_PREFIX}/lib/cmake/is-${middleware}/${plugin_library_target}-target.cmake
NAMESPACE is::
)
file(GENERATE
OUTPUT ${plugin_library_install_mix}
INPUT ${plugin_library_mix_template}
)

include(CMakePackageConfigHelpers)
set(config_file_input "${IS_TEMPLATE_DIR}/middleware-config.cmake.in")
set(config_file_output "${mix_build_dir}/is-${middleware}Config.cmake")
configure_package_config_file(
${config_file_input}
${config_file_output}
INSTALL_DESTINATION ${config_install_dir}
)
endforeach()

file(
COPY
if(NOT _ARG_NO_CONFIG)

set(config_install_dir ${CMAKE_INSTALL_LIBDIR}/cmake/is-${middleware})

set(extensions)
foreach(extension ${_ARG_EXTENSIONS})
get_filename_component(ext_filename ${extension} NAME)
list(APPEND extensions ${ext_filename})
endforeach()

export(
TARGETS
${plugin_library_target}
FILE
${CMAKE_INSTALL_PREFIX}/lib/cmake/is-${middleware}/${plugin_library_target}-target.cmake
NAMESPACE is::
)

include(CMakePackageConfigHelpers)
set(config_file_input "${IS_TEMPLATE_DIR}/middleware-config.cmake.in")
set(config_file_output "${mix_build_dir}/is-${middleware}Config.cmake")
configure_package_config_file(
${config_file_input}
${config_file_output}
DESTINATION
${CMAKE_INSTALL_PREFIX}/lib/cmake/is-${middleware}
)
INSTALL_DESTINATION ${config_install_dir}
)

file(
COPY
${config_file_output}
DESTINATION
${CMAKE_INSTALL_PREFIX}/lib/cmake/is-${middleware}
)

if(_ARG_EXTENSIONS)
install(
FILES ${_ARG_EXTENSIONS}
DESTINATION ${config_install_dir}/extensions
COMPONENT ${plugin_library_target}
)
endif()

if(_ARG_EXTENSIONS)
install(
FILES ${_ARG_EXTENSIONS}
DESTINATION ${config_install_dir}/extensions
COMPONENT ${plugin_library_target}
)
endif()

endif()
endforeach()

endfunction()