Skip to content

Some modernizations #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0 # Use the latest stable tag
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files
36 changes: 30 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,38 @@
cmake_minimum_required(VERSION 3.14)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we switch to CMake presets, we need to increase this to >3.25.


# Project name
# try to prevent modification of source directory
# note: some files may still be written before CMake can abort and need to be removed manually
if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
message(
FATAL_ERROR
"In-source build not allowed. "
"Please create a new directory, preferably next to the source directory, and run CMake from there. "
"You may want to remove CMakeCache.txt and CMakeFiles/ which were created in the source directory."
)
endif()

project(mirco VERSION 0.1.0)

# Check for out-of-source build
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "\nIn-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there.\n\nTo clean-up, you may need to remove CMakeCache.txt and CMakeFiles from your source directory.")
endif()
# Print CMake version to screen
message(STATUS "Using CMake ${CMAKE_VERSION}")

# Enforce the C++ standard we are using and turn off compiler-specific extensions
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# We do not use C++ modules (yet). Turn off scanning to avoid issues with clang-tidy.
# If you want to add module support, this problem needs to be revisited. Our hope
# is that CMake and/or clang-tidy will be updated to handle modules better.
set(CMAKE_CXX_SCAN_FOR_MODULES OFF)

# Ensure cmake setup the correct runtime path when installing
# see here for more information: https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
include(GNUInstallDirs)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

# Add libraries
if(GTEST_IN_MIRCO)
Expand Down Expand Up @@ -145,7 +169,7 @@ configure_package_config_file(cmake/mirco_libConfig.cmake.in

install(FILES
${CMAKE_CURRENT_BINARY_DIR}/mirco_libConfig.cmake
DESTINATION lib/cmake/mirco
DESTINATION lib/cmake/mirco
)

install(DIRECTORY ${PROJECT_SOURCE_DIR}/src/ DESTINATION include/mirco FILES_MATCHING PATTERN "*.h")
Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,62 +22,83 @@ cd <someBaseDir>
mkdir <sourceDir>
git clone --recursive https://github.com/imcs-compsim/MIRCO.git <sourceDir>
```

where `<someBaseDir>` is some directory in your machine and `<sourceDir>` will contain the `MIRCO` source code.

If you have already cloned the repository using:

```bash
git clone https://github.com/imcs-compsim/MIRCO.git <sourceDir>
```

you can pull the submodules using:

```bash
cd <sourceDir>
git submodule update --init --recursive
```

To update the submodules, you can use the following command from your source directory:

```bash
git submodule update --recursive --remote
```

### Configure and build the code

To create an out-of-source build, first create a build directory using:

```bash
cd <someBaseDir>
mkdir <buildDir>
```

where `<buildDir>` is the build directory.

> Note: The exact location of `<buildDir>` is arbitrary, as long as it is _not_ a subdirectory of `<sourceDir>`.

Now, you have to navigate to the build directory and call the `do-configure` script in order to invoke `cmake`:

```bash
cd <buildDir>
<sourceDir>/do-configure
```

Alternatively, you can use CMake presets:

```bash
cd <buildDir>
cmake --preset=<name_of_your_preset> <sourceDir>
```

> **IMPORTANT** Make sure to set `Trilinos_DIR` to point to you Trilinos installation.

Build the `mirco` executable in the build directory using:

```bash
cd <buildDir>
make -j <numProc>
```

with `<numProc>` specifying the number of processes used for compilation.
The `mirco` executable will be created in the build directory.

### Run all tests

You can run the tests from the build directory using:

```bash
ctest
```

### Run the code

To run the code with an input file, use the following command in your build directory:

```bash
./mirco <sourceDir>/Input/<someInputFile.xml>
```

where `<someInputFile.xml>` is any input file in the prescribed format.

## How to cite MIRCO?
Expand Down
16 changes: 15 additions & 1 deletion create-mirco-python-venv
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
#!/bin/bash

# Exit the script at the first failure
set -e

if [ ! -f "./create-mirco-python-venv" ]; then
echo "Please run this script from the root directory of the repository."
exit 1
fi

# Path to the python virtual environment.
PYTHON_VENV="`dirname "$0"`/utilities/mirco-python-venv"

# If the virtual environment already exists, delete it.
if [ -d "$PYTHON_VENV" ]; then rm -Rf $PYTHON_VENV; fi

# Path to python
PYTHON_PATH=${1:-python3}

# Setup the virtual environment and source it.
python3 -m venv "${PYTHON_VENV}"
$PYTHON_PATH -m venv "${PYTHON_VENV}"
source "${PYTHON_VENV}"/bin/activate

# Install all the modules defined in requirements.txt.
pip install --upgrade pip
pip install wheel
pip install -r requirements.txt

# Install the pre-commit hooks.
pre-commit install
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Python modules that will be installed into the MIRCO python virtual environment
clang-format==14.0.0
clang-format==14.0.0
pre-commit==3.5.0