From fc733629e2aa5559f5922cbd3d2c08a61a2f1a02 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Thu, 20 Jun 2024 14:41:49 -0400 Subject: [PATCH] Add esma_add_fortran_submodules (v3) --- CHANGELOG.md | 6 +++++ .../esma_add_fortran_submodules.cmake | 27 +++++++++++++++++++ esma_support/esma_support.cmake | 1 + 3 files changed, 34 insertions(+) create mode 100644 esma_support/esma_add_fortran_submodules.cmake diff --git a/CHANGELOG.md b/CHANGELOG.md index a683b2a..403ca91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Deprecated +## [3.46.0] - 2024-06-21 + +### Added + +- Add the file `esma_add_fortran_submodules.cmake` in the `esma_support` folder. The file contains a function that prevents conflicts when several submodule files have the same name. + ## [3.45.3] - 2024-06-14 ### Fixed diff --git a/esma_support/esma_add_fortran_submodules.cmake b/esma_support/esma_add_fortran_submodules.cmake new file mode 100644 index 0000000..7da31b1 --- /dev/null +++ b/esma_support/esma_add_fortran_submodules.cmake @@ -0,0 +1,27 @@ +# Function to avoid conflicts with files (in separate folders) with the same name. +# The function is necessary for submodule files. + +function(esma_add_fortran_submodules) + set(options) + set(oneValueArgs TARGET SUBDIRECTORY) + set(multiValueArgs SOURCES) + cmake_parse_arguments( + ARG "${options}" "${oneValueArgs}" + "${multiValueArgs}" ${ARGN} + ) + + foreach(file ${ARG_SOURCES}) + + set(input ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_SUBDIRECTORY}/${file}) + set(output ${CMAKE_CURRENT_BINARY_DIR}/${ARG_SUBDIRECTORY}_${file}) + add_custom_command( + OUTPUT ${output} + COMMAND ${CMAKE_COMMAND} -E copy ${input} ${output} + DEPENDS ${input} + ) + set_property(SOURCE ${output} PROPERTY GENERATED 1) + target_sources(${ARG_TARGET} PRIVATE ${output}) + + endforeach() + +endfunction() diff --git a/esma_support/esma_support.cmake b/esma_support/esma_support.cmake index 7e2e6fc..c874a55 100644 --- a/esma_support/esma_support.cmake +++ b/esma_support/esma_support.cmake @@ -8,6 +8,7 @@ include (esma_add_library) include (esma_generate_automatic_code) include (esma_create_stub_component) include (esma_fortran_generator_list) +include (esma_add_fortran_submodules) # Testing include (esma_enable_tests)