From e184ad08b5465217a11e0db76e2d9fef8318aa4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A1lint=20Aradi?= Date: Fri, 27 Sep 2024 13:30:55 +0200 Subject: [PATCH] Simplify config variable names --- .github/workflows/ci.yml | 14 +++++----- CMakeLists.txt | 46 ++++++++++--------------------- cmake/FortunoHelpers.cmake | 12 ++++---- example/CMakeLists.txt | 6 ++-- example/coarray/meson.build | 8 +++--- example/meson.build | 6 ++-- include/CMakeLists.txt | 4 +-- meson.build | 34 +++++++++++------------ meson.options | 16 +++++------ src/CMakeLists.txt | 6 ++-- test/export/coarray/meson.build | 10 +++---- test/export/coarray/meson.options | 4 +-- 12 files changed, 74 insertions(+), 92 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9cfa305..c937ae8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -126,27 +126,27 @@ jobs: - name: Setup serial interface options if: ${{ contains(matrix.interface, 'serial') }} run: | - echo "CMAKE_OPTIONS=-DFORTUNO_BUILD_SERIAL_INTERFACE=ON" >> ${GITHUB_ENV} + echo "CMAKE_OPTIONS=-DFORTUNO_WITH_SERIAL=ON" >> ${GITHUB_ENV} echo "MESON_OPTIONS_NOFALLBACK=" >> ${GITHUB_ENV} - echo "MESON_OPTIONS_FALLBACK=-Dfortuno:build_serial_interface=true" >> ${GITHUB_ENV} + echo "MESON_OPTIONS_FALLBACK=-Dfortuno:with_serial=true" >> ${GITHUB_ENV} echo "INTERFACE=serial" >> ${GITHUB_ENV} echo "RUN_PREFIX=" >> ${GITHUB_ENV} - name: Setup mpi interface options if: ${{ contains(matrix.interface, 'mpi') }} run: | - echo "CMAKE_OPTIONS=-DFORTUNO_BUILD_MPI_INTERFACE=ON" >> ${GITHUB_ENV} + echo "CMAKE_OPTIONS=-DFORTUNO_WITH_MPI=ON" >> ${GITHUB_ENV} echo "MESON_OPTIONS_NOFALLBACK=" >> ${GITHUB_ENV} - echo "MESON_OPTIONS_FALLBACK=-Dfortuno:build_mpi_interface=true" >> ${GITHUB_ENV} + echo "MESON_OPTIONS_FALLBACK=-Dfortuno:with_mpi=true" >> ${GITHUB_ENV} echo "INTERFACE=mpi" >> ${GITHUB_ENV} echo "RUN_PREFIX=mpirun -n 2" >> ${GITHUB_ENV} - name: Setup coarray interface options if: ${{ contains(matrix.interface, 'coarray') }} run: | - echo "CMAKE_OPTIONS=-DFORTUNO_BUILD_COARRAY_INTERFACE=ON -DFORTUNO_COARRAY_COMPILE_FLAGS='-coarray' -DFORTUNO_COARRAY_LINK_FLAGS='-coarray'" >> ${GITHUB_ENV} - echo "MESON_OPTIONS_NOFALLBACK=-Dcoarray_compile_flags=-coarray -Dcoarray_link_flags=-coarray" >> ${GITHUB_ENV} - echo "MESON_OPTIONS_FALLBACK=-Dcoarray_compile_flags=-coarray -Dcoarray_link_flags=-coarray -Dfortuno:build_coarray_interface=true -Dfortuno:coarray_compile_flags=-coarray -Dfortuno:coarray_link_flags=-coarray" >> ${GITHUB_ENV} + echo "CMAKE_OPTIONS=-DFORTUNO_WITH_COARRAY=ON -DFORTUNO_FFLAGS_COARRAY='-coarray' -DFORTUNO_LDFLAGS_COARRAY='-coarray'" >> ${GITHUB_ENV} + echo "MESON_OPTIONS_NOFALLBACK=-Dfflags_coarray=-coarray -Dldflags_coarray=-coarray" >> ${GITHUB_ENV} + echo "MESON_OPTIONS_FALLBACK=-Dfflags_coarray=-coarray -Dldflags_coarray=-coarray -Dfortuno:with_coarray=true -Dfortuno:fflags_coarray=-coarray -Dfortuno:ldflags_coarray=-coarray" >> ${GITHUB_ENV} echo "FPM_FFLAGS=${FPM_FFLAGS} -coarray" >> ${GITHUB_ENV} echo "FPM_LDFLAGS=${FPM_LDFLAGS} -coarray" >> ${GITHUB_ENV} echo "INTERFACE=coarray" >> ${GITHUB_ENV} diff --git a/CMakeLists.txt b/CMakeLists.txt index 319be94..3cacc67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,33 +29,15 @@ include(CMakeDependentOption) option(FORTUNO_BUILD_SHARED_LIBS "Fortuno: Build as shared library" ${PROJECT_IS_TOP_LEVEL}) -option( - FORTUNO_BUILD_SERIAL_INTERFACE - "Fortuno: whether serial interface should be built" - ON -) +option(FORTUNO_WITH_SERIAL "Fortuno: whether the library with serial interface should be built" ON) -option( - FORTUNO_BUILD_MPI_INTERFACE - "Fortuno: whether MPI interface should be built" - OFF -) +option(FORTUNO_WITH_MPI "Fortuno: whether the library with MPI interface should be built" OFF) -option( - FORTUNO_BUILD_COARRAY_INTERFACE - "Fortuno: whether the coarray interface should be built" - OFF -) +option(FORTUNO_WITH_COARRAY "Fortuno: whether library with coarray interface should be built" OFF) -cmake_dependent_option( - FORTUNO_BUILD_TESTS "Fortuno: Build test suite" ${PROJECT_IS_TOP_LEVEL} - "FORTUNO_BUILD_SERIAL_INTERFACE" OFF -) +option(FORTUNO_WITH_TESTS "Fortuno: whether to build test suite" ${PROJECT_IS_TOP_LEVEL}) -cmake_dependent_option( - FORTUNO_BUILD_EXAMPLES "Fortuno: Build example apps" ${PROJECT_IS_TOP_LEVEL} - "FORTUNO_BUILD_SERIAL_INTERFACE" OFF -) +option(FORTUNO_WITH_EXAMPLES "Fortuno: whether to build example apps" ${PROJECT_IS_TOP_LEVEL}) option(FORTUNO_INSTALL "Fortuno: Install project" ${PROJECT_IS_TOP_LEVEL}) @@ -65,22 +47,22 @@ set( ) set( - FORTUNO_THREAD_SAFE_COMPILE_FLAGS "" CACHE STRING + FORTUNO_FFLAGS_THREADSAFE "" CACHE STRING "Fortuno: Flags needed to enforce thread-safe build during compilation" ) set( - FORTUNO_THREAD_SAFE_LINK_FLAGS "" CACHE STRING + FORTUNO_LDFLAGS_THREADSAFE "" CACHE STRING "Fortuno: Flags neeeded to enforce thread-safe build during linking" ) set( - FORTUNO_COARRAY_COMPILE_FLAGS "" CACHE STRING + FORTUNO_FFLAGS_COARRAY "" CACHE STRING "Fortuno: Flags needed for coarray features when compling" ) set( - FORTUNO_COARRAY_LINK_FLAGS "" CACHE STRING + FORTUNO_LDFLAGS_COARRAY "" CACHE STRING "Fortuno: Flags neeeded for coarray features when linking" ) @@ -102,7 +84,7 @@ find_program(FYPP fypp) set(BUILD_SHARED_LIBS ${FORTUNO_BUILD_SHARED_LIBS}) fortuno_setup_build_type("RelWithDebInfo") -if (FORTUNO_BUILD_MPI_INTERFACE) +if (FORTUNO_WITH_MPI) find_package(MPI REQUIRED) if(NOT MPI_FORTRAN_FOUND) message(FATAL_ERROR "Failed to detect MPI-framework for Fortran") @@ -115,7 +97,7 @@ endif () add_subdirectory(include) add_subdirectory(src) -if (FORTUNO_BUILD_EXAMPLES) +if (FORTUNO_WITH_EXAMPLES) add_subdirectory(example) endif () @@ -133,7 +115,7 @@ if (FORTUNO_INSTALL) COMPONENT Fortuno_development ) - if (FORTUNO_BUILD_SERIAL_INTERFACE) + if (FORTUNO_WITH_SERIAL) configure_file(cmake/fortuno-serial.pc.in fortuno-serial.pc @ONLY) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/fortuno-serial.pc @@ -142,7 +124,7 @@ if (FORTUNO_INSTALL) ) endif () - if (FORTUNO_BUILD_MPI_INTERFACE) + if (FORTUNO_WITH_MPI) configure_file(cmake/fortuno-mpi.pc.in fortuno-mpi.pc @ONLY) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/fortuno-mpi.pc @@ -151,7 +133,7 @@ if (FORTUNO_INSTALL) ) endif () - if (FORTUNO_BUILD_COARRAY_INTERFACE) + if (FORTUNO_WITH_COARRAY) configure_file(cmake/fortuno-coarray.pc.in fortuno-coarray.pc @ONLY) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/fortuno-coarray.pc diff --git a/cmake/FortunoHelpers.cmake b/cmake/FortunoHelpers.cmake index b719dd5..74c7d74 100644 --- a/cmake/FortunoHelpers.cmake +++ b/cmake/FortunoHelpers.cmake @@ -28,14 +28,14 @@ endfunction() function (fortuno_create_thread_safe_build_target) if (NOT TARGET ThreadSafeBuild) - if (FORTUNO_THREAD_SAFE_COMPILE_FLAGS) - set(_compiler_flags "${FORTUNO_THREAD_SAFE_COMPILE_FLAGS}") + if (FORTUNO_FFLAGS_THREADSAFE) + set(_compiler_flags "${FORTUNO_FFLAGS_THREADSAFE}") elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "NAG") set(_compiler_flags "-thread_safe") endif () - if (FORTUNO_THREAD_SAFE_LINK_FLAGS) - set(_linker_flags "${FORTUNO_THREAD_SAFE_LINK_FLAGS}") + if (FORTUNO_LDFLAGS_THREADSAFE) + set(_linker_flags "${FORTUNO_LDFLAGS_THREADSAFE}") elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "NAG") set(_linker_flags "-thread_safe") endif () @@ -105,11 +105,11 @@ function (fortuno_create_coarray_build_target) add_library(CoarrayBuildInterface INTERFACE) target_compile_options( CoarrayBuildInterface INTERFACE - ${FORTUNO_COARRAY_COMPILE_FLAGS} + ${FORTUNO_FFLAGS_COARRAY} ) target_link_options( CoarrayBuildInterface INTERFACE - ${FORTUNO_COARRAY_LINK_FLAGS} + ${FORTUNO_LDFLAGS_COARRAY} ) endif () diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 140fc34..179509b 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -4,21 +4,21 @@ list(APPEND CMAKE_MESSAGE_CONTEXT Example) -if (FORTUNO_BUILD_SERIAL_INTERFACE) +if (FORTUNO_WITH_SERIAL) add_subdirectory(serial) if (FYPP) add_subdirectory(serial-fypp) endif () endif () -if (FORTUNO_BUILD_MPI_INTERFACE) +if (FORTUNO_WITH_MPI) add_subdirectory(mpi) if (FYPP) add_subdirectory(mpi-fypp) endif () endif () -if (FORTUNO_BUILD_COARRAY_INTERFACE) +if (FORTUNO_WITH_COARRAY) add_subdirectory(coarray) # if (FYPP) # add_subdirectory(mpi-fypp) diff --git a/example/coarray/meson.build b/example/coarray/meson.build index b48d92c..3f33724 100644 --- a/example/coarray/meson.build +++ b/example/coarray/meson.build @@ -6,8 +6,8 @@ example_mylib_lib = library( 'mylib', sources: ['mylib.f90'], install: false, - fortran_args: coarray_compile_flags, - link_args: coarray_link_flags, + fortran_args: fflags_coarray, + link_args: ldflags_coarray, ) example_mylib_dep = declare_dependency( link_with: example_mylib_lib, @@ -21,6 +21,6 @@ example_testapp_exe = executable( ], dependencies: [example_mylib_dep, fortuno_coarray_dep], install: false, - fortran_args: coarray_compile_flags, - link_args: coarray_link_flags, + fortran_args: fflags_coarray, + link_args: ldflags_coarray, ) diff --git a/example/meson.build b/example/meson.build index 0e799c0..9dd5722 100644 --- a/example/meson.build +++ b/example/meson.build @@ -2,14 +2,14 @@ # Licensed under the BSD-2-Clause Plus Patent license. # SPDX-License-Identifier: BSD-2-Clause-Patent -if build_serial_interface +if with_serial subdir('serial') endif -if build_mpi_interface +if with_mpi subdir('mpi') endif -if build_coarray_interface +if with_coarray subdir('coarray') endif diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index d6c207e..e77e965 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -17,14 +17,14 @@ if (FORTUNO_INSTALL) TARGETS fortuno_include_dir EXPORT FortunoTargets ) - if (FORTUNO_BUILD_SERIAL_INTERFACE) + if (FORTUNO_WITH_SERIAL) install( FILES fortuno_serial.fypp DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" COMPONENT Fortuno_development ) endif () - if (FORTUNO_BUILD_MPI_INTERFACE) + if (FORTUNO_WITH_MPI) install( FILES fortuno_mpi.fypp DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" diff --git a/meson.build b/meson.build index 797a85f..ac3e131 100644 --- a/meson.build +++ b/meson.build @@ -8,10 +8,10 @@ project( version: '0.1.0', ) -build_serial_interface = get_option('build_serial_interface') -build_mpi_interface = get_option('build_mpi_interface') -build_coarray_interface = get_option('build_coarray_interface') -build_examples = get_option('build_examples') +with_serial = get_option('with_serial') +with_mpi = get_option('with_mpi') +with_coarray = get_option('with_coarray') +with_examples = get_option('with_examples') fortuno_sources = [] fortuno_serial_sources = [] @@ -19,24 +19,24 @@ fortuno_mpi_sources = [] fortuno_coarray_sources = [] subdir('src') -thread_safe_compile_flags = get_option('thread_safe_compile_flags') -thread_safe_link_flags = get_option('thread_safe_link_flags') -coarray_compile_flags = get_option('coarray_compile_flags') -coarray_link_flags = get_option('coarray_link_flags') +fflags_threadsafe = get_option('fflags_threadsafe') +ldflags_threadsafe = get_option('ldflags_threadsafe') +fflags_coarray = get_option('fflags_coarray') +ldflags_coarray = get_option('ldflags_coarray') fortuno_lib = library( 'fortuno', version: meson.project_version(), sources: fortuno_sources, - fortran_args: thread_safe_compile_flags, - link_args: thread_safe_link_flags, + fortran_args: fflags_threadsafe, + link_args: ldflags_threadsafe, ) fortuno_dep = declare_dependency( link_with: fortuno_lib, ) -if build_serial_interface +if with_serial fortuno_serial_deps = [fortuno_dep] @@ -54,7 +54,7 @@ if build_serial_interface endif -if build_mpi_interface +if with_mpi fortuno_mpi_deps = [fortuno_dep] @@ -75,11 +75,11 @@ if build_mpi_interface endif -if build_coarray_interface +if with_coarray fortuno_coarray_deps = [fortuno_dep] # Disabling coarray detection as it seems to be fragile. Make sure to pass the right coarray - # compiler and linker arguments via the "coarray_compile_flags" and "coarray_link_flags" build variables. + # compiler and linker arguments via the "fflags_coarray" and "ldflags_coarray" build variables. # coarray_dep = dependency('coarray') # fortuno_coarray_deps += coarray_dep @@ -88,8 +88,8 @@ if build_coarray_interface version: meson.project_version(), sources: fortuno_coarray_sources, dependencies: fortuno_coarray_deps, - fortran_args: coarray_compile_flags, - link_args: coarray_link_flags, + fortran_args: fflags_coarray, + link_args: ldflags_coarray, ) fortuno_coarray_dep = declare_dependency( @@ -99,6 +99,6 @@ if build_coarray_interface endif -if build_examples +if with_examples subdir('example') endif diff --git a/meson.options b/meson.options index 6aae2d5..fed7502 100644 --- a/meson.options +++ b/meson.options @@ -2,30 +2,30 @@ # Licensed under the BSD-2-Clause Plus Patent license. # SPDX-License-Identifier: BSD-2-Clause-Patent -option('build_serial_interface', type: 'boolean', value: true, description: 'Build serial interface') +option('with_serial', type: 'boolean', value: true, description: 'Build serial interface') -option('build_mpi_interface', type: 'boolean', value: false, description: 'Build MPI interface') +option('with_mpi', type: 'boolean', value: false, description: 'Build MPI interface') -option('build_coarray_interface', type: 'boolean', value: false, description: 'Build coarray interface') +option('with_coarray', type: 'boolean', value: false, description: 'Build coarray interface') -option('build_examples', type: 'boolean', value: false, description: 'Build examples') +option('with_examples', type: 'boolean', value: false, description: 'Build examples') option( - 'thread_safe_compile_flags', type: 'array', value: [], + 'fflags_threadsafe', type: 'array', value: [], description: 'Fortran compiler arguments to use when compiling thread-safe sources' ) option( - 'thread_safe_link_flags', type: 'array', value: [], + 'ldflags_threadsafe', type: 'array', value: [], description: 'Linker arguments to use when linking thread-safe sources' ) option( - 'coarray_compile_flags', type: 'array', value: [], + 'fflags_coarray', type: 'array', value: [], description: 'Fortran compiler arguments to use when compiling coarray sources' ) option( - 'coarray_link_flags', type: 'array', value: [], + 'ldflags_coarray', type: 'array', value: [], description: 'Fortran linker arguments to use when linking coarray object files' ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f344bec..4e15670 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -30,7 +30,7 @@ add_subdirectory(fortuno) add_library(Fortuno::fortuno ALIAS fortuno) list(APPEND _installed_targets "fortuno") -if (FORTUNO_BUILD_SERIAL_INTERFACE) +if (FORTUNO_WITH_SERIAL) add_library(fortuno_serial) set_target_properties( @@ -58,7 +58,7 @@ if (FORTUNO_BUILD_SERIAL_INTERFACE) endif () -if (FORTUNO_BUILD_MPI_INTERFACE) +if (FORTUNO_WITH_MPI) add_library(fortuno_mpi) set_target_properties( @@ -86,7 +86,7 @@ if (FORTUNO_BUILD_MPI_INTERFACE) endif () -if (FORTUNO_BUILD_COARRAY_INTERFACE) +if (FORTUNO_WITH_COARRAY) add_library(fortuno_coarray) set_target_properties( diff --git a/test/export/coarray/meson.build b/test/export/coarray/meson.build index 39fee55..86961d3 100644 --- a/test/export/coarray/meson.build +++ b/test/export/coarray/meson.build @@ -12,15 +12,15 @@ project( ### Getting dependencies ### -coarray_compile_flags = get_option('coarray_compile_flags') -coarray_link_flags = get_option('coarray_link_flags') +fflags_coarray = get_option('fflags_coarray') +ldflags_coarray = get_option('ldflags_coarray') testapp_deps = [] fortuno_coarray_dep = dependency( 'fortuno-coarray', fallback: ['fortuno', 'fortuno_coarray_dep'], - default_options: {'coarray_compile_flags': coarray_compile_flags, 'coarray_link_flags': coarray_link_flags}, + default_options: {'fflags_coarray': fflags_coarray, 'ldflags_coarray': ldflags_coarray}, ) testapp_deps += fortuno_coarray_dep @@ -33,6 +33,6 @@ testapp_exe = executable( 'testapp', sources: testapp_srcs, dependencies: testapp_deps, - fortran_args: coarray_compile_flags, - link_args: coarray_link_flags, + fortran_args: fflags_coarray, + link_args: ldflags_coarray, ) diff --git a/test/export/coarray/meson.options b/test/export/coarray/meson.options index c2df3b5..446e57f 100644 --- a/test/export/coarray/meson.options +++ b/test/export/coarray/meson.options @@ -3,11 +3,11 @@ # SPDX-License-Identifier: BSD-2-Clause-Patent option( - 'coarray_compile_flags', type: 'array', value: [], + 'fflags_coarray', type: 'array', value: [], description: 'Fortran compiler arguments to use when compiling coarray sources' ) option( - 'coarray_link_flags', type: 'array', value: [], + 'ldflags_coarray', type: 'array', value: [], description: 'Fortran linker arguments to use when linking coarray sources' )