Skip to content

Commit

Permalink
EXAMPLE: Provide example CMakeLists.txt for users of exodus library […
Browse files Browse the repository at this point in the history
…ci skip]
  • Loading branch information
gsjaardema committed May 16, 2023
1 parent c15f996 commit dd43041
Show file tree
Hide file tree
Showing 4 changed files with 1,356 additions and 0 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,24 @@ mingw-w64-x86_64-cmake mingw-w64-x86_64-fmt
There is also a Visual Studio build performed at each commit to the
SEACAS git repository. See the file `.appveyor.yml` for more details.

## Example For External Build
The `cmake-use-example` directory contains a sample `CMakeLists.txt`
file which provides an example of how to build and link a C or Fortran
program with the Exodus library installed as part of a build of this
package.

To use this, copy the contents of the directory to your own filespace
and modify the contents as needed. The example provides a C
executable and a Fortran Executable which both are linked to the
Exodus library.

To configure and build, you would do something like:
```
mkdir build; cd build
CMAKE_PREFIX_PATH={path_to_root_of_seacas_install} cmake ..
make
```

## License

SEACAS is licensed under the Modified BSD License. See the [LICENSE](LICENSE) file for details.
Expand Down
32 changes: 32 additions & 0 deletions cmake-use-example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Almost all CMake files should start with this
# You should always specify a range with the newest
# and oldest tested versions of CMake. This will ensure
# you pick up the best policies.
cmake_minimum_required(VERSION 3.1...3.26)
project(ExodusCMakeExample VERSION 1.0 LANGUAGES C Fortran)

###
### Generate Makefile with:
# * mkdir build; cd build
# * CMAKE_PREFIX_PATH={path_to_root_of_seacas_install} ccmake ..

#### C ####
find_package(SEACASExodus CONFIG)
add_executable(ExodusWriteC ExodusWrite.c)
target_link_libraries(ExodusWriteC PRIVATE SEACASExodus::all_libs)


#### FORTRAN #####
IF ("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU")
SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fcray-pointer -fdefault-real-8 -fdefault-integer-8 -fno-range-check")
ELSEIF ("${CMAKE_Fortran_COMPILER_ID}" MATCHES "XL")
SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qintsize=8 -qrealsize=8")
ELSEIF ("${CMAKE_Fortran_COMPILER_ID}" MATCHES "Cray")
SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -sdefault64")
ELSE()
SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -r8 -i8")
ENDIF()

find_package(SEACASExodus_for CONFIG)
add_executable(ExodusReadFor ExodusRead.f)
target_link_libraries(ExodusReadFor PRIVATE SEACASExodus_for::all_libs)
Loading

0 comments on commit dd43041

Please sign in to comment.