Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
fc8f836
add basic macos support
tristanmontoya Jun 6, 2026
2e480fb
find fortran compiler in ci
tristanmontoya Jun 6, 2026
2e32c93
avoid doc deploy from fork PRs
tristanmontoya Jun 6, 2026
555949c
revert unnecessary diff
tristanmontoya Jun 15, 2026
bc09f6b
fix mistakes
tristanmontoya Jun 15, 2026
63bb35a
revert other unnecessary diff
tristanmontoya Jun 15, 2026
59b3332
check without GFORTRAN
benegee Jul 3, 2026
6517f23
Merge branch 'main' into tm/macos-support
benegee Jul 3, 2026
ee20cb2
fix
benegee Jul 3, 2026
bfc5f41
Merge branch 'tm/macos-support' of github.com:trixi-framework/libtrix…
benegee Jul 3, 2026
9392506
Merge branch 'main' into bg/add-macos
benegee Sep 28, 2026
be539aa
try to integrate macos
benegee Sep 28, 2026
85e9568
check if mpifort works
benegee Sep 28, 2026
a887f47
add comments
benegee Sep 28, 2026
2e65e47
install gtest
benegee Sep 28, 2026
fbb0050
conditionally adapt HDF5 prefix
benegee Sep 28, 2026
453289b
add MPI path for macos
benegee Sep 28, 2026
12e3c64
use bash array instead
benegee Sep 28, 2026
d0aae80
add a Fortran example
benegee Sep 28, 2026
a93b6dc
Does PC work with t8code?
benegee Sep 28, 2026
7904222
add option disabling fortran build
benegee Sep 29, 2026
13e3ed1
add a test with Fortran disabled
benegee Sep 29, 2026
6be7ef2
temporarily switch to Julia 1.12
benegee Sep 29, 2026
448fca6
update minimum version
benegee Sep 29, 2026
fed3825
SYSTEM PRIVATE?
benegee Sep 29, 2026
3eb3d36
fix
benegee Sep 29, 2026
e809d47
fix
benegee Sep 29, 2026
501e447
Merge branch 'main' into bg/optional-fortran-build
benegee Sep 29, 2026
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
32 changes: 29 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,17 @@ jobs:
cmake .. -DCMAKE_INSTALL_PREFIX=../install \
-DCMAKE_BUILD_TYPE=Release \
-DT8CODE_ROOT=$PWD/../t8code-local/prefix \
-DENABLE_TESTING=ON -DJULIA_PROJECT_PATH=../libtrixi-julia
-DLIBTRIXI_ENABLE_TESTING=ON -DJULIA_PROJECT_PATH=../libtrixi-julia

- name: Configure without Fortran (test_type == 'regular')
if: ${{ matrix.test_type == 'regular' }}
run: |
mkdir build-nofortran
cd build-nofortran
cmake .. -DCMAKE_INSTALL_PREFIX=../install-nofortran \
-DCMAKE_BUILD_TYPE=Release \
-DT8CODE_ROOT=$PWD/../t8code-local/prefix \
-DLIBTRIXI_BUILD_FORTRAN_API=OFF

- name: Configure (test_type == 'coverage')
if: ${{ matrix.test_type == 'coverage' }}
Expand All @@ -154,14 +164,20 @@ jobs:
-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_TESTING=ON -DJULIA_PROJECT_PATH=../libtrixi-julia

- name: Build
if: ${{ matrix.test_type == 'regular' || matrix.test_type == 'coverage' || matrix.test_type == 'smoke' }}
run: |
cd build
make -j 2

- name: Build without Fortran
if: ${{ matrix.test_type == 'regular' }}
run: |
cd build-nofortran
make -j 2

- name: Install
if: ${{ matrix.test_type == 'regular' || matrix.test_type == 'coverage' || matrix.test_type == 'smoke' }}
run: |
Expand Down Expand Up @@ -227,7 +243,7 @@ jobs:
cmake .. -DCMAKE_INSTALL_PREFIX=../install \
-DCMAKE_BUILD_TYPE=Debug \
-DT8CODE_ROOT=$PWD/../t8code-local/prefix \
-DUSE_PACKAGE_COMPILER=ON \
-DLIBTRIXI_USE_PACKAGE_COMPILER=ON \
-DJULIA_PROJECT_PATH=$PWD/../libtrixi-julia

- name: Build (test_type == 'package-compiler')
Expand Down Expand Up @@ -300,6 +316,16 @@ jobs:
env:
LIBTRIXI_DEBUG: all

- name: Run C example (Fortran API disabled)
if: ${{ matrix.test_type == 'regular'}}
run: |
cd build-nofortran/examples
mpirun -n 2 trixi_controller_simple_c \
../../libtrixi-julia \
../../LibTrixi.jl/examples/libelixir_p4est2d_euler_sedov.jl
env:
LIBTRIXI_DEBUG: all

- name: Check error handling of examples
if: ${{ matrix.test_type == 'regular' || matrix.test_type == 'coverage' }}
run: |
Expand Down
76 changes: 51 additions & 25 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -23,8 +24,18 @@ 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_ENABLE_TESTING "Build tests using Google Test (C) and test-drive (Fortran)" OFF )
option( LIBTRIXI_USE_PACKAGE_COMPILER "Build standalone libtrixi.so using PackageCompiler.jl" )

# Enable C always
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)
Expand All @@ -47,8 +58,7 @@ endif()
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()
Expand All @@ -57,22 +67,23 @@ 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( LIBTRIXI_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()

Expand All @@ -89,10 +100,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}
Expand Down Expand Up @@ -123,12 +136,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 )

Expand All @@ -141,7 +160,10 @@ else()


# Include directories
target_include_directories( ${PROJECT_NAME} PRIVATE src ${JULIA_INCLUDE_DIRS} )
# PRIVATE: Do not include internal directory in projects building against libtrixi
# SYSTEM: Disable warnings/error from upstream libraries
target_include_directories( ${PROJECT_NAME} PRIVATE src )
target_include_directories( ${PROJECT_NAME} SYSTEM PRIVATE ${JULIA_INCLUDE_DIRS} )

# Libraries to link
target_link_libraries( ${PROJECT_NAME} PRIVATE ${JULIA_LIBRARY} )
Expand All @@ -160,13 +182,15 @@ else()
add_library ( ${PROJECT_NAME}_tls OBJECT
src/tls.c
)
target_include_directories( ${PROJECT_NAME}_tls PRIVATE ${JULIA_INCLUDE_DIRS} )
target_include_directories( ${PROJECT_NAME}_tls SYSTEM 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()


Expand All @@ -183,7 +207,9 @@ 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
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ 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.
- By default the Fortran-Interface is built; it may be excluded with
`-DLIBTRIXI_BUILD_FORTRAN_API=OFF`.
- Building with t8code support is optional. It requires to pass
`-DT8CODE_ROOT=<t8code_install_directory>`.

Expand Down Expand Up @@ -302,7 +304,7 @@ To try this out, perform the following steps:
*using cmake*
- Add
```
-DUSE_PACKAGE_COMPILER=ON -DJULIA_PROJECT_PATH=<libtrixi-julia_directory>
-DLIBTRIXI_USE_PACKAGE_COMPILER=ON -DJULIA_PROJECT_PATH=<libtrixi-julia_directory>
```
to your cmake call (see above)
3. From inside the `examples` folder you should be able to run the example (in parallel)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/developers.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ For testing the C interface of libtrixi we rely on [GoogleTest](https://google.g
The tests are contained in `cpp`-files located under `test/c`. They are processed by `cmake` and made available via
`ctest`, provided the options
```
-DENABLE_TESTING=ON -DJULIA_PROJECT_PATH=<libtrixi-julia_directory>
-DLIBTRIXI_ENABLE_TESTING=ON -DJULIA_PROJECT_PATH=<libtrixi-julia_directory>
```
are passed to `cmake` during configuration.
The executables can then be found under `<build_directory>/test/c` (they will not be installed). To run them, execute
Expand Down
4 changes: 3 additions & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ 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.
- By default the Fortran-Interface is built; it may be excluded with
`-DLIBTRIXI_BUILD_FORTRAN_API=OFF`.
- Building with t8code support is optional. It requires to pass
`-DT8CODE_ROOT=<t8code_install_directory>`.

Expand Down Expand Up @@ -306,7 +308,7 @@ To try this out, perform the following steps:
*using cmake*
- Add
```
-DUSE_PACKAGE_COMPILER=ON -DJULIA_PROJECT_PATH=<libtrixi-julia_directory>
-DLIBTRIXI_USE_PACKAGE_COMPILER=ON -DJULIA_PROJECT_PATH=<libtrixi-julia_directory>
```
to your cmake call (see above)
3. From inside the `examples` folder you should be able to run the example (in parallel)
Expand Down
11 changes: 9 additions & 2 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand All @@ -41,7 +46,7 @@ foreach ( EXAMPLE ${EXAMPLES} )
${TARGET_NAME}
PRIVATE MPI::MPI_${EXAMPLE_LANG} ${PROJECT_NAME}
)
if ( NOT USE_PACKAGE_COMPILER )
if ( NOT LIBTRIXI_USE_PACKAGE_COMPILER )
target_link_libraries( ${TARGET_NAME} PRIVATE ${PROJECT_NAME}_tls )
endif()
if ( T8CODE_FOUND )
Expand All @@ -53,7 +58,9 @@ foreach ( EXAMPLE ${EXAMPLES} )
${TARGET_NAME}
PRIVATE ${CMAKE_SOURCE_DIR}/src
)
if ( T8CODE_FOUND )

if ( LIBTRIXI_BUILD_FORTRAN_API AND T8CODE_FOUND )
# Add the t8code include directory of the Fortran module file
target_include_directories( ${TARGET_NAME} PRIVATE ${T8CODE_ROOT}/include/t8_fortran_interface/ )
endif()

Expand Down
Loading