From e05179e549b9bb7ea26edd4d6827695a863e098d Mon Sep 17 00:00:00 2001 From: Niklas Date: Tue, 9 Dec 2025 14:11:49 +0100 Subject: [PATCH 1/9] Added several options for the CMake configuration such that building the Fortran API is optional and the compilation flags for warnings can be set conditionally --- CMakeLists.txt | 97 +++++++++++++++++++++++++++++------------ examples/CMakeLists.txt | 23 +++++++--- 2 files changed, 86 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5376e94d..d8ee4fd3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,8 @@ # Specify the minimum version # 3.9 required for regex submatches # 3.12 required for policy CMP0074 (using *_ROOT variables) -cmake_minimum_required ( VERSION 3.12 ) +# 3.13 required for policy CMP0076 (target_sources() command converts relative paths to absolute) +cmake_minimum_required ( VERSION 3.13 ) # Reconfigure if Project.toml has changed set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/LibTrixi.jl/Project.toml") @@ -23,13 +24,23 @@ file(WRITE "${CMAKE_BINARY_DIR}/LIBTRIXI_VERSION" "${LIBTRIXI_VERSION}\n") project ( trixi VERSION ${LIBTRIXI_VERSION_MAJOR}.${LIBTRIXI_VERSION_MINOR}.${LIBTRIXI_VERSION_PATCH} DESCRIPTION "Interface library for using Trixi.jl from C/C++/Fortran" ) -# Enable C and Fortran -enable_language(C Fortran) +# Additional configuration options +option( LIBTRIXI_BUILD_FORTRAN_API "Enable the build of the Fortran interface" ON ) +option( LIBTRIXI_WITH_T8CODE "Link against an available t8code installation" OFF ) +option( LIBTRIXI_ENABLE_ALL_WARNINGS "Use compilation flags -Wall -Wextra -Wpedantic" [OFF] ) +option( LIBTRIXI_ENABLE_WERROR "Use compilation flag -Werror" [OFF] ) +option( LIBTRIXI_ENABLE_TESTING "Build tests using Google Test (C) and test-drive (Fortran)" [OFF] ) -# Enabling setting rpath for installation -SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) +# Enable C by default and Fortran +enable_language( C ) +# Optionally enable Fortran +if( LIBTRIXI_BUILD_FORTRAN_API ) + enable_language( Fortran ) +endif() +# Enabling setting rpath for installation +SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # Additional cmake modules list ( APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/" ) @@ -38,17 +49,22 @@ list ( APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/" ) find_package( Julia REQUIRED ) # Find t8code -find_package( T8CODE CONFIG ) -if ( NOT T8CODE_FOUND ) - message( NOTICE "t8code not found: t8code examples will NOT be built") +if( LIBTRIXI_WITH_T8CODE ) + find_package( T8CODE CONFIG ) + if ( NOT T8CODE_FOUND ) + message( NOTICE "t8code not found: t8code examples will NOT be built" ) + else() + message(STATUS "Found t8code installation: ${T8CODE_DIR}" ) + endif() +else() + set(T8CODE_FOUND OFF) endif() # Find MPI find_package( MPI REQUIRED ) # Find Google Test and test-drive on demand -option( ENABLE_TESTING "Build tests using Google Test (C) and test-drive (Fortran)" ) -if( ENABLE_TESTING ) +if( LIBTRIXI_ENABLE_TESTING ) if ( NOT DEFINED JULIA_PROJECT_PATH ) message( FATAL_ERROR "JULIA_PROJECT_PATH not set, tests will not work.") endif() @@ -57,22 +73,26 @@ if( ENABLE_TESTING ) find_package( GTest REQUIRED ) - set ( TEST_DRIVE_FIND_METHOD fetch ) - # Option TEST_DRIVE_BUILD_TESTING is hard-coded to ON, could be spared - find_package( test-drive REQUIRED ) + if( LIBTRIXI_BUILD_FORTRAN_API ) + set ( TEST_DRIVE_FIND_METHOD fetch ) + # Option TEST_DRIVE_BUILD_TESTING is hard-coded to ON, could be spared + find_package( test-drive REQUIRED ) + endif() endif() # Optionally use PackageCompiler.jl to build standalone libtrixi.so option( USE_PACKAGE_COMPILER "Build standalone libtrixi.so using PackageCompiler.jl" ) -# Fortran mod file location -set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}) +if( LIBTRIXI_BUILD_FORTRAN_API ) + # Fortran mod file location + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}) +endif() if( USE_PACKAGE_COMPILER ) if ( NOT DEFINED JULIA_PROJECT_PATH ) message( FATAL_ERROR "JULIA_PROJECT_PATH needs to be set for PackageCompiler.jl.") endif() - if ( ENABLE_TESTING ) + if ( LIBTRIXI_ENABLE_TESTING ) message( NOTICE "Testing is not supported when PackageCompiler is used.") endif() @@ -89,10 +109,12 @@ if( USE_PACKAGE_COMPILER ) COMMAND ${CMAKE_COMMAND} -E copy ${PC_INIT_SOURCE} ${PC_INIT_BUILD} DEPENDS ${PC_INIT_SOURCE} ) - # Add a library target (libtrixi), only for Fortran module - add_library( ${PROJECT_NAME} OBJECT - src/api.f90 - ) + if( LIBTRIXI_BUILD_FORTRAN_API ) + # Add a library target (libtrixi), only for Fortran module + add_library( ${PROJECT_NAME} OBJECT + src/api.f90 + ) + endif() # Custom command to run PackageCompiler.jl to produce libtrixi.so add_custom_command( OUTPUT ${PC_LIBTRIXI_SO} @@ -123,12 +145,18 @@ else() # Library target add_library ( ${PROJECT_NAME} SHARED src/api.c - src/api.f90 src/auxiliary.h src/auxiliary.c src/trixi.h ) + # Build Fortran library target on demand + if( LIBTRIXI_BUILD_FORTRAN_API ) + target_sources (${PROJECT_NAME} PRIVATE + src/api.f90 + ) + endif() + # Include directories, private target_include_directories ( ${PROJECT_NAME} PRIVATE src ) @@ -148,14 +176,22 @@ else() # Set appropriate compile flags target_compile_options( ${PROJECT_NAME} PUBLIC "-fPIC" ) - target_compile_options( ${PROJECT_NAME} PRIVATE -Wall -Wextra -Werror) + + # Potentially, enable all warnings + if( LIBTRIXI_ENABLE_ALL_WARNINGS ) + target_compile_options( ${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic) + endif() + + # Potentially, enable to interpret warnings as errors + if( LIBTRIXI_ENABLE_WERROR ) + target_compile_options( ${PROJECT_NAME} PRIVATE -Werror) + endif() + # Require C11 standard with GNU extensions for C files target_compile_options( ${PROJECT_NAME} PRIVATE $<$:-std=gnu11>) # Require Fortran 2018 standard for Fortran files target_compile_options( ${PROJECT_NAME} PRIVATE $<$:-std=f2018>) - - # Add auxiliary *object* library to support fast thread-local storage (TLS) add_library ( ${PROJECT_NAME}_tls OBJECT src/tls.c @@ -163,10 +199,13 @@ else() target_include_directories( ${PROJECT_NAME}_tls PRIVATE ${JULIA_INCLUDE_DIRS} ) # Add test on demand - if( ENABLE_TESTING ) + if( LIBTRIXI_ENABLE_TESTING ) enable_testing() add_subdirectory( test/c ) - add_subdirectory( test/fortran ) + + if( LIBTRIXI_BUILD_FORTRAN_API ) + add_subdirectory( test/fortran ) + endif() endif() @@ -175,15 +214,15 @@ else() install( FILES "${CMAKE_BINARY_DIR}/LIBTRIXI_VERSION" DESTINATION share/julia ) endif() - - # Public header for libtrixi set_target_properties ( ${PROJECT_NAME} PROPERTIES PUBLIC_HEADER src/trixi.h ) # Common install configuration install( TARGETS ${PROJECT_NAME} ) install( DIRECTORY LibTrixi.jl DESTINATION share/libtrixi PATTERN "lib" EXCLUDE ) -install( FILES ${CMAKE_Fortran_MODULE_DIRECTORY}/libtrixi.mod TYPE INCLUDE) +if( LIBTRIXI_BUILD_FORTRAN_API ) + install( FILES ${CMAKE_Fortran_MODULE_DIRECTORY}/libtrixi.mod TYPE INCLUDE) +endif() install( PROGRAMS utils/libtrixi-init-julia TYPE BIN ) # Add examples diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 508fb4bf..084579fd 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -17,6 +17,11 @@ if ( NOT T8CODE_FOUND ) list( FILTER EXAMPLES EXCLUDE REGEX "trixi_controller_baroclinic.*" ) endif() +if (NOT LIBTRIXI_BUILD_FORTRAN_API) + # Remove Fortran files if the the Fortran API is not build + list( FILTER EXAMPLES EXCLUDE REGEX ".*\.f90" ) +endif() + foreach ( EXAMPLE ${EXAMPLES} ) get_filename_component ( EXAMPLE_EXT ${EXAMPLE} EXT ) @@ -45,7 +50,7 @@ foreach ( EXAMPLE ${EXAMPLES} ) target_link_libraries( ${TARGET_NAME} PRIVATE ${PROJECT_NAME}_tls ) endif() if ( T8CODE_FOUND ) - target_link_libraries( ${TARGET_NAME} PRIVATE T8CODE::T8 ) + target_link_libraries( ${TARGET_NAME} PUBLIC T8CODE::T8 ) endif() # set include directories @@ -53,8 +58,10 @@ foreach ( EXAMPLE ${EXAMPLES} ) ${TARGET_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src ) - if ( T8CODE_FOUND ) - target_include_directories( ${TARGET_NAME} PRIVATE ${T8CODE_ROOT}/include/t8_fortran_interface/ ) + + if ( LIBTRIXI_BUILD_FORTRAN_API AND T8CODE_FOUND ) + # Add the t8code include directory of the Fortran module file for the Fortran compiler to find the module files + target_include_directories( ${TARGET_NAME} PUBLIC ${T8CODE_DIR}/../include/t8_fortran_interface/ ) endif() # set runtime path for installed binaries @@ -66,8 +73,14 @@ foreach ( EXAMPLE ${EXAMPLES} ) # position independent code target_compile_options( ${TARGET_NAME} PRIVATE "-fPIC" ) - # enable warnings - target_compile_options( ${TARGET_NAME} PRIVATE -Wall -Wextra -Werror ) + # Potentially, enable all warnings + if( LIBTRIXI_ENABLE_ALL_WARNINGS ) + target_compile_options( ${TARGET_NAME} PRIVATE -Wall -Wextra -Wpedantic) + endif() + # Potentially, enable to interpret warnings as errors + if( LIBTRIXI_ENABLE_WERROR ) + target_compile_options( ${TARGET_NAME} PRIVATE -Werror) + endif() # add to installation install( TARGETS ${TARGET_NAME} ) From 1b5411a1471d4e54c5e18cbad0ca88fcb332ace8 Mon Sep 17 00:00:00 2001 From: Niklas997 <72195148+Niklas997@users.noreply.github.com> Date: Thu, 18 Jun 2026 09:51:13 +0200 Subject: [PATCH 2/9] Applied minor corrections in CMakeLists.txt --- CMakeLists.txt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d8ee4fd3..6de21807 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,9 +27,9 @@ project ( trixi VERSION ${LIBTRIXI_VERSION_MAJOR}.${LIBTRIXI_VERSION_MINOR}.${LI # Additional configuration options option( LIBTRIXI_BUILD_FORTRAN_API "Enable the build of the Fortran interface" ON ) option( LIBTRIXI_WITH_T8CODE "Link against an available t8code installation" OFF ) -option( LIBTRIXI_ENABLE_ALL_WARNINGS "Use compilation flags -Wall -Wextra -Wpedantic" [OFF] ) -option( LIBTRIXI_ENABLE_WERROR "Use compilation flag -Werror" [OFF] ) -option( LIBTRIXI_ENABLE_TESTING "Build tests using Google Test (C) and test-drive (Fortran)" [OFF] ) +option( LIBTRIXI_ENABLE_ALL_WARNINGS "Use compilation flags -Wall -Wextra -Wpedantic" OFF ) +option( LIBTRIXI_ENABLE_WERROR "Use compilation flag -Werror" OFF ) +option( LIBTRIXI_ENABLE_TESTING "Build tests using Google Test (C) and test-drive (Fortran)" OFF ) # Enable C by default and Fortran enable_language( C ) @@ -166,8 +166,6 @@ else() # Version info for the shared object set_target_properties ( ${PROJECT_NAME} PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR} ) - - # Include directories target_include_directories( ${PROJECT_NAME} PRIVATE src ${JULIA_INCLUDE_DIRS} ) @@ -208,7 +206,6 @@ else() endif() endif() - # Install configuration install( FILES $ TYPE LIB RENAME lib${PROJECT_NAME}_tls.o ) install( FILES "${CMAKE_BINARY_DIR}/LIBTRIXI_VERSION" DESTINATION share/julia ) From 7db05ef105cffa350bae2ff94820a14130f8cf57 Mon Sep 17 00:00:00 2001 From: Niklas Date: Thu, 18 Jun 2026 11:38:19 +0200 Subject: [PATCH 3/9] Updated configure options --- CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6de21807..e620ad83 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,11 +27,11 @@ project ( trixi VERSION ${LIBTRIXI_VERSION_MAJOR}.${LIBTRIXI_VERSION_MINOR}.${LI # Additional configuration options option( LIBTRIXI_BUILD_FORTRAN_API "Enable the build of the Fortran interface" ON ) option( LIBTRIXI_WITH_T8CODE "Link against an available t8code installation" OFF ) -option( LIBTRIXI_ENABLE_ALL_WARNINGS "Use compilation flags -Wall -Wextra -Wpedantic" OFF ) +option( LIBTRIXI_ENABLE_WARNINGS "Use compilation flags -Wall -Wextra" OFF ) option( LIBTRIXI_ENABLE_WERROR "Use compilation flag -Werror" OFF ) option( LIBTRIXI_ENABLE_TESTING "Build tests using Google Test (C) and test-drive (Fortran)" OFF ) -# Enable C by default and Fortran +# Enable C always enable_language( C ) # Optionally enable Fortran @@ -175,9 +175,9 @@ else() # Set appropriate compile flags target_compile_options( ${PROJECT_NAME} PUBLIC "-fPIC" ) - # Potentially, enable all warnings - if( LIBTRIXI_ENABLE_ALL_WARNINGS ) - target_compile_options( ${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic) + # Potentially, enable warnings + if( LIBTRIXI_ENABLE_WARNINGS ) + target_compile_options( ${PROJECT_NAME} PRIVATE -Wall -Wextra) endif() # Potentially, enable to interpret warnings as errors From e5411307879acd29c8afbc700184968213d325f4 Mon Sep 17 00:00:00 2001 From: Niklas Date: Thu, 18 Jun 2026 11:42:27 +0200 Subject: [PATCH 4/9] Updated the CI with new cmake options --- .github/workflows/ci.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 96694d49..e38b657f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -118,9 +118,10 @@ jobs: mkdir build cd build cmake .. -DCMAKE_INSTALL_PREFIX=../install \ - -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_BUILD_TYPE=Release -DLIBTRIXI_WITH_T8CODE=ON \ -DT8CODE_ROOT=$PWD/../t8code-local/prefix \ - -DENABLE_TESTING=ON -DJULIA_PROJECT_PATH=../libtrixi-julia + -DLIBTRIXI_ENABLE_WARNINGS=ON -DLIBTRIXI_ENABLE_WERROR=ON \ + -DLIBTRIXI_ENABLE_TESTING=ON -DJULIA_PROJECT_PATH=../libtrixi-julia - name: Configure (test_type == 'coverage') if: ${{ matrix.test_type == 'coverage' }} @@ -128,13 +129,14 @@ jobs: mkdir build cd build cmake .. -DCMAKE_INSTALL_PREFIX=../install \ - -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_BUILD_TYPE=Debug -DLIBTRIXI_WITH_T8CODE=ON \ -DT8CODE_ROOT=$PWD/../t8code-local/prefix \ -DCMAKE_C_FLAGS="-cpp --coverage -O0" \ -DCMAKE_Fortran_FLAGS="-cpp --coverage -O0" \ -DCMAKE_EXE_LINKER_FLAGS="--coverage" \ -DCMAKE_SHARED_LINKER_FLAGS="--coverage" \ - -DENABLE_TESTING=ON -DJULIA_PROJECT_PATH=../libtrixi-julia + -DLIBTRIXI_ENABLE_WARNINGS=ON -DLIBTRIXI_ENABLE_WERROR=ON \ + -DLIBTRIXI_ENABLE_TESTING=ON -DJULIA_PROJECT_PATH=../libtrixi-julia - name: Build if: ${{ matrix.test_type == 'regular' || matrix.test_type == 'coverage' }} From bfa24a610bae6b6434e6e262aabaa478d518c3c4 Mon Sep 17 00:00:00 2001 From: Niklas Date: Thu, 18 Jun 2026 12:01:27 +0200 Subject: [PATCH 5/9] Added explanation of new cmake options in the build instructions --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 771d1ae0..ec3b5ea4 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,11 @@ For building, `cmake` and its typical workflow is used. - Specifying the directory `install_directory` for later installation is optional. - Optional specification of build type sets some default compiler options for optimized or debug code. - - Building with t8code support is optional. It requires to pass + - By default the Fortran-Interface is built; it may be excluded with `DLIBTRIXI_BUILD_FORTRAN_API=OFF`. + - Optional compiler options `-Wall -Wextra` are specified with `-DLIBTRIXI_ENABLE_WARNINGS=ON`. + - Optional compiler option `-Werror` is specified with `-DLIBTRIXI_ENABLE_WERROR=ON`. + - Building of the test is enabled with `LIBTRIXI_ENABLE_TESTING=ON`. + - Building with t8code support is optional. It requires to pass `-DLIBTRIXI_WITH_T8CODE=ON` and `-DT8CODE_ROOT=`. 3. Call make From bf66eb7503c842e55b1fa1f7669072efb3158f05 Mon Sep 17 00:00:00 2001 From: Niklas Date: Mon, 22 Jun 2026 10:44:04 +0200 Subject: [PATCH 6/9] Applied compile option warnings if enabled --- CMakeLists.txt | 8 ++++++-- examples/CMakeLists.txt | 4 ++-- test/c/CMakeLists.txt | 11 +++++++++-- test/fortran/CMakeLists.txt | 12 +++++++++++- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e620ad83..613578b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,6 +31,10 @@ option( LIBTRIXI_ENABLE_WARNINGS "Use compilation flags -Wall -Wextra" OFF ) option( LIBTRIXI_ENABLE_WERROR "Use compilation flag -Werror" OFF ) option( LIBTRIXI_ENABLE_TESTING "Build tests using Google Test (C) and test-drive (Fortran)" OFF ) +# Define the warnings to use if enabled +set (LIBTRIXI_WARNING_OPTIONS -Wall -Wextra) +set (LIBTRIXI_WERROR_OPTION -Werror) + # Enable C always enable_language( C ) @@ -177,12 +181,12 @@ else() # Potentially, enable warnings if( LIBTRIXI_ENABLE_WARNINGS ) - target_compile_options( ${PROJECT_NAME} PRIVATE -Wall -Wextra) + target_compile_options( ${PROJECT_NAME} PRIVATE ${LIBTRIXI_WARNING_OPTIONS}) endif() # Potentially, enable to interpret warnings as errors if( LIBTRIXI_ENABLE_WERROR ) - target_compile_options( ${PROJECT_NAME} PRIVATE -Werror) + target_compile_options( ${PROJECT_NAME} PRIVATE ${LIBTRIXI_WERROR_OPTION}) endif() # Require C11 standard with GNU extensions for C files diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 084579fd..0f27350f 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -75,11 +75,11 @@ foreach ( EXAMPLE ${EXAMPLES} ) # Potentially, enable all warnings if( LIBTRIXI_ENABLE_ALL_WARNINGS ) - target_compile_options( ${TARGET_NAME} PRIVATE -Wall -Wextra -Wpedantic) + target_compile_options( ${TARGET_NAME} PRIVATE ${LIBTRIXI_WARNING_OPTIONS}) endif() # Potentially, enable to interpret warnings as errors if( LIBTRIXI_ENABLE_WERROR ) - target_compile_options( ${TARGET_NAME} PRIVATE -Werror) + target_compile_options( ${TARGET_NAME} PRIVATE ${LIBTRIXI_WERROR_OPTION}) endif() # add to installation diff --git a/test/c/CMakeLists.txt b/test/c/CMakeLists.txt index b532d823..52e8d4ec 100644 --- a/test/c/CMakeLists.txt +++ b/test/c/CMakeLists.txt @@ -32,8 +32,15 @@ foreach ( TEST ${TESTS} ) PRIVATE ${CMAKE_SOURCE_DIR}/src ) - # enable warnings - target_compile_options( ${TARGET_NAME} PRIVATE -Wall -Wextra -Werror ) + # Potentially, enable warnings + if( LIBTRIXI_ENABLE_WARNINGS ) + target_compile_options( ${TARGET_NAME} PRIVATE ${LIBTRIXI_WARNING_OPTIONS}) + endif() + + # Potentially, enable to interpret warnings as errors + if( LIBTRIXI_ENABLE_WERROR ) + target_compile_options( ${TARGET_NAME} PRIVATE ${LIBTRIXI_WERROR_OPTION}) + endif() # pass julia project path target_compile_definitions( ${TARGET_NAME} PRIVATE diff --git a/test/fortran/CMakeLists.txt b/test/fortran/CMakeLists.txt index 5b6ee0b3..1fecb305 100644 --- a/test/fortran/CMakeLists.txt +++ b/test/fortran/CMakeLists.txt @@ -38,7 +38,17 @@ if ( T8CODE_FOUND ) endif() # enable warnings -target_compile_options( ${TARGET_NAME} PRIVATE -cpp -Wall -Wextra -Werror -Wno-uninitialized ) +target_compile_options( ${TARGET_NAME} PRIVATE -cpp -Wno-uninitialized ) + +# Potentially, enable warnings +if( LIBTRIXI_ENABLE_WARNINGS ) + target_compile_options( ${TARGET_NAME} PRIVATE ${LIBTRIXI_WARNING_OPTIONS}) +endif() + +# Potentially, enable to interpret warnings as errors +if( LIBTRIXI_ENABLE_WERROR ) + target_compile_options( ${TARGET_NAME} PRIVATE ${LIBTRIXI_WERROR_OPTION}) +endif() # pass julia project path target_compile_definitions( ${TARGET_NAME} PRIVATE From e60d611791edfa605f4513b459577c3cba224394 Mon Sep 17 00:00:00 2001 From: Niklas Date: Tue, 23 Jun 2026 10:23:23 +0200 Subject: [PATCH 7/9] Revert scope of t8code linkage and include directory --- examples/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 0f27350f..2c4edcb2 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -50,7 +50,7 @@ foreach ( EXAMPLE ${EXAMPLES} ) target_link_libraries( ${TARGET_NAME} PRIVATE ${PROJECT_NAME}_tls ) endif() if ( T8CODE_FOUND ) - target_link_libraries( ${TARGET_NAME} PUBLIC T8CODE::T8 ) + target_link_libraries( ${TARGET_NAME} PRIVATE T8CODE::T8 ) endif() # set include directories @@ -61,7 +61,7 @@ foreach ( EXAMPLE ${EXAMPLES} ) if ( LIBTRIXI_BUILD_FORTRAN_API AND T8CODE_FOUND ) # Add the t8code include directory of the Fortran module file for the Fortran compiler to find the module files - target_include_directories( ${TARGET_NAME} PUBLIC ${T8CODE_DIR}/../include/t8_fortran_interface/ ) + target_include_directories( ${TARGET_NAME} PRIVATE ${T8CODE_ROOT}/include/t8_fortran_interface/ ) endif() # set runtime path for installed binaries From ca7e64f2d283ee7be87744cb91527d4f852c66c8 Mon Sep 17 00:00:00 2001 From: Niklas Date: Tue, 23 Jun 2026 10:24:41 +0200 Subject: [PATCH 8/9] Corrected cmake option in instructions --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ec3b5ea4..aac64ca8 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ For building, `cmake` and its typical workflow is used. - By default the Fortran-Interface is built; it may be excluded with `DLIBTRIXI_BUILD_FORTRAN_API=OFF`. - Optional compiler options `-Wall -Wextra` are specified with `-DLIBTRIXI_ENABLE_WARNINGS=ON`. - Optional compiler option `-Werror` is specified with `-DLIBTRIXI_ENABLE_WERROR=ON`. - - Building of the test is enabled with `LIBTRIXI_ENABLE_TESTING=ON`. + - Building of the test is enabled with `-DLIBTRIXI_ENABLE_TESTING=ON`. - Building with t8code support is optional. It requires to pass `-DLIBTRIXI_WITH_T8CODE=ON` and `-DT8CODE_ROOT=`. From f15865dddb9a2a6ae4dfbafadcb1c23e75f93a07 Mon Sep 17 00:00:00 2001 From: Niklas Date: Tue, 23 Jun 2026 13:01:26 +0200 Subject: [PATCH 9/9] Removed additionally introduced t8code cmake option --- .github/workflows/ci.yml | 4 ++-- CMakeLists.txt | 13 +++---------- README.md | 2 +- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e38b657f..3a00a52d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -118,7 +118,7 @@ jobs: mkdir build cd build cmake .. -DCMAKE_INSTALL_PREFIX=../install \ - -DCMAKE_BUILD_TYPE=Release -DLIBTRIXI_WITH_T8CODE=ON \ + -DCMAKE_BUILD_TYPE=Release \ -DT8CODE_ROOT=$PWD/../t8code-local/prefix \ -DLIBTRIXI_ENABLE_WARNINGS=ON -DLIBTRIXI_ENABLE_WERROR=ON \ -DLIBTRIXI_ENABLE_TESTING=ON -DJULIA_PROJECT_PATH=../libtrixi-julia @@ -129,7 +129,7 @@ jobs: mkdir build cd build cmake .. -DCMAKE_INSTALL_PREFIX=../install \ - -DCMAKE_BUILD_TYPE=Debug -DLIBTRIXI_WITH_T8CODE=ON \ + -DCMAKE_BUILD_TYPE=Debug \ -DT8CODE_ROOT=$PWD/../t8code-local/prefix \ -DCMAKE_C_FLAGS="-cpp --coverage -O0" \ -DCMAKE_Fortran_FLAGS="-cpp --coverage -O0" \ diff --git a/CMakeLists.txt b/CMakeLists.txt index 613578b7..ee7a56eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,6 @@ project ( trixi VERSION ${LIBTRIXI_VERSION_MAJOR}.${LIBTRIXI_VERSION_MINOR}.${LI # Additional configuration options option( LIBTRIXI_BUILD_FORTRAN_API "Enable the build of the Fortran interface" ON ) -option( LIBTRIXI_WITH_T8CODE "Link against an available t8code installation" OFF ) option( LIBTRIXI_ENABLE_WARNINGS "Use compilation flags -Wall -Wextra" OFF ) option( LIBTRIXI_ENABLE_WERROR "Use compilation flag -Werror" OFF ) option( LIBTRIXI_ENABLE_TESTING "Build tests using Google Test (C) and test-drive (Fortran)" OFF ) @@ -53,15 +52,9 @@ list ( APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/" ) find_package( Julia REQUIRED ) # Find t8code -if( LIBTRIXI_WITH_T8CODE ) - find_package( T8CODE CONFIG ) - if ( NOT T8CODE_FOUND ) - message( NOTICE "t8code not found: t8code examples will NOT be built" ) - else() - message(STATUS "Found t8code installation: ${T8CODE_DIR}" ) - endif() -else() - set(T8CODE_FOUND OFF) +find_package( T8CODE CONFIG ) +if ( NOT T8CODE_FOUND ) + message( NOTICE "t8code not found: t8code examples will NOT be built") endif() # Find MPI diff --git a/README.md b/README.md index aac64ca8..850eba3b 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ For building, `cmake` and its typical workflow is used. - Optional compiler options `-Wall -Wextra` are specified with `-DLIBTRIXI_ENABLE_WARNINGS=ON`. - Optional compiler option `-Werror` is specified with `-DLIBTRIXI_ENABLE_WERROR=ON`. - Building of the test is enabled with `-DLIBTRIXI_ENABLE_TESTING=ON`. - - Building with t8code support is optional. It requires to pass `-DLIBTRIXI_WITH_T8CODE=ON` and + - Building with t8code support is optional. It requires to pass `-DT8CODE_ROOT=`. 3. Call make