Skip to content

Commit

Permalink
Simplify config variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
aradi committed Sep 27, 2024
1 parent 8b0da77 commit e184ad0
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 92 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
46 changes: 14 additions & 32 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand All @@ -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"
)

Expand All @@ -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")
Expand All @@ -115,7 +97,7 @@ endif ()

add_subdirectory(include)
add_subdirectory(src)
if (FORTUNO_BUILD_EXAMPLES)
if (FORTUNO_WITH_EXAMPLES)
add_subdirectory(example)
endif ()

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions cmake/FortunoHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand Down Expand Up @@ -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 ()

Expand Down
6 changes: 3 additions & 3 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions example/coarray/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
)
6 changes: 3 additions & 3 deletions example/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
34 changes: 17 additions & 17 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,35 @@ 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 = []
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]

Expand All @@ -54,7 +54,7 @@ if build_serial_interface

endif

if build_mpi_interface
if with_mpi

fortuno_mpi_deps = [fortuno_dep]

Expand All @@ -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

Expand All @@ -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(
Expand All @@ -99,6 +99,6 @@ if build_coarray_interface

endif

if build_examples
if with_examples
subdir('example')
endif
16 changes: 8 additions & 8 deletions meson.options
Original file line number Diff line number Diff line change
Expand Up @@ -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'
)
Loading

0 comments on commit e184ad0

Please sign in to comment.