@@ -72,6 +72,29 @@ Additionally, Visual Studio is required to compile in *Windows*.
7272
7373 http://www.boost.org/users/download/.
7474
75+ - # ### macOS installation
76+
77+ ** Homebrew is the recommended method** for installing dependencies on macOS (Intel and Apple Silicon).
78+
79+ First, [install Homebrew](https://brew.sh/) if not already installed:
80+ ` ` ` Shell
81+ /bin/bash -c " $( curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh) "
82+ ` ` `
83+
84+ Then install the required dependencies:
85+ ` ` ` Shell
86+ brew install cmake llvm boost python@3.14
87+ ` ` `
88+
89+ ** Important:** macOS' s system clang compiler lacks OpenMP support. The `llvm` installation from Homebrew provides `libomp` which is required. When building Kratos, you must explicitly use the Homebrew LLVM compiler (see configuration examples in the [MacOS build section](#macos) below).
90+
91+ Optional but recommended for faster builds:
92+ ```Shell
93+ brew install ninja ccache
94+ ```
95+
96+ If you need a specific Python version, Homebrew also provides `python@3.13`, `python@3.12`, etc.
97+
7598- #### Windows installation
7699
77100 - Visual Studio
@@ -595,54 +618,174 @@ else
595618 echo " Python DLL not found at ${PYTHON_DLL} "
596619 exit 1
597620fi
598- ```
621+ ` `
599622
600623# ## MacOS
601624
602- ```console
603- # Function to add apps
604- add_app () {
605- export KRATOS_APPLICATIONS="${KRATOS_APPLICATIONS}$1;"
606- }
625+ # ### System Requirements
607626
608- # Set compiler
609- export CC=/usr/local/opt/llvm/bin/clang
610- export CXX=/usr/local/opt/llvm/bin/clang++
627+ ** Supported Versions:** macOS 11.0+ (Intel and Apple Silicon M1/M2/M3+)
611628
612- # Set variables
613- export KRATOS_SOURCE="${KRATOS_SOURCE:-"$( cd "$(dirname "$0")" ; pwd -P )"/..}"
614- export KRATOS_BUILD="${KRATOS_SOURCE}/build"
615- export KRATOS_APP_DIR="${KRATOS_SOURCE}/applications"
616- export KRATOS_INSTALL_PYTHON_USING_LINKS=ON
629+ ** Recommended:** Use Homebrew for dependency management. The following dependencies must be installed:
617630
618- # Set basic configuration
619- export KRATOS_BUILD_TYPE="Release"
620- export BOOST_ROOT="/path/to/boost"
621- export PYTHON_EXECUTABLE="/Library/Frameworks/Python.framework/Versions/3.8/bin/python3"
631+ ` ` ` bash
632+ # Install Homebrew (if not already installed)
633+ /bin/bash -c " $( curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh) "
622634
623- # Set applications to compile
624- export KRATOS_APPLICATIONS=
625- add_app ${KRATOS_APP_DIR}/LinearSolversApplication
626- add_app ${KRATOS_APP_DIR}/StructuralMechanicsApplication
627- add_app ${KRATOS_APP_DIR}/FluidDynamicsApplication
635+ # Install required dependencies
636+ brew install cmake llvm boost python@3.14
628637
629- # Clean
630- clear
631- rm -rf "${KRATOS_BUILD}/${KRATOS_BUILD_TYPE}/cmake_install.cmake"
632- rm -rf "${KRATOS_BUILD}/${KRATOS_BUILD_TYPE}/CMakeCache.txt"
633- rm -rf "${KRATOS_BUILD}/${KRATOS_BUILD_TYPE}/CMakeFiles"
638+ # Optional but recommended for faster builds
639+ brew install ninja ccache
640+ ` ` `
634641
635- # Configure
636- /Applications/CMake.app/Contents/bin/cmake -H"${KRATOS_SOURCE}" -B"${KRATOS_BUILD}/${KRATOS_BUILD_TYPE}" \
637- -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -msse3 -std=c++11 -L/usr/local/opt/llvm/lib" \
638- -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -msse3 -L/usr/local/opt/llvm/lib" \
639- -DUSE_EIGEN_MKL=OFF
642+ ** Critical:** macOS system clang lacks OpenMP support. You ** must** use Homebrew' s LLVM installation, which provides `libomp`.
640643
641- # Build
642- /Applications/CMake.app/Contents/bin/cmake --build "${KRATOS_BUILD}/${KRATOS_BUILD_TYPE}" --target install -- -j3
644+ #### Recommended: Using the Build Script
645+
646+ Kratos provides a dedicated build script for Apple Silicon that handles all macOS-specific configuration:
643647
648+ ```bash
649+ cd /path/to/Kratos
650+ ./scripts/mac_build -j4
644651```
645652
653+ This script will:
654+ - Automatically find Homebrew-installed LLVM and Boost
655+ - Detect your Python installation
656+ - Install Kratos to your Python site-packages directory
657+ - Use the Ninja build system if installed (faster than Unix Makefiles)
658+
659+ **Options:**
660+ - `-j <N>`: Number of parallel build jobs (default: auto-detected)
661+ - `-i <path>`: Custom installation directory (default: Python site-packages)
662+ - `-o "<option>"`: Pass additional CMake options
663+ - `-C`: Clean build and install directories
664+
665+ **Example with custom Python:**
666+ ```bash
667+ ./scripts/mac_build -o "-DPYTHON_EXECUTABLE=$(which python3)" -j8
668+ ```
669+
670+ #### Manual Configuration (Advanced)
671+
672+ If you prefer to configure manually, follow these steps:
673+
674+ **Step 1: Create a Python Virtual Environment (Recommended)**
675+
676+ ```bash
677+ python3 -m venv ~/kratos_env
678+ source ~/kratos_env/bin/activate
679+ pip install --upgrade pip
680+ ```
681+
682+ **Step 2: Configure with CMake**
683+
684+ ```bash
685+ # Set paths
686+ export KRATOS_SOURCE=/path/to/Kratos
687+ export KRATOS_BUILD=$KRATOS_SOURCE/build
688+ export KRATOS_INSTALL=$(python3 -c "import sysconfig; print(sysconfig.get_paths()[' purelib' ])")
689+
690+ # Create build directory
691+ mkdir -p $KRATOS_BUILD
692+ cd $KRATOS_BUILD
693+
694+ # Configure (adjust -j to your CPU core count)
695+ cmake $KRATOS_SOURCE \
696+ -DCMAKE_INSTALL_PREFIX=$KRATOS_INSTALL \
697+ -DCMAKE_C_COMPILER=/opt/homebrew/opt/llvm/bin/clang \
698+ -DCMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm/bin/clang++ \
699+ -DCMAKE_BUILD_TYPE=Release \
700+ -DPYTHON_EXECUTABLE=$(which python3) \
701+ -G Ninja
702+ ```
703+
704+ **Step 3: Build and Install**
705+
706+ ```bash
707+ cmake --build . --target install -j$(sysctl -n machdep.cpu.thread_count)
708+ ```
709+
710+ #### Testing Your Installation
711+
712+ After successful build, verify the installation:
713+
714+ ```bash
715+ python3 << ' EOF'
716+ import KratosMultiphysics
717+
718+ # Create a basic model
719+ model = KratosMultiphysics.Model()
720+ model_part = model.CreateModelPart("TestPart")
721+
722+ print("✅ Kratos successfully installed and working!")
723+ print(f"Installation path: {KratosMultiphysics.__file__}")
724+ EOF
725+ ```
726+
727+ You should see output similar to:
728+ ```
729+ | / |
730+ ' / __| _` | __| _ \ __|
731+ . \ | ( | | ( | \_ _ \
732+ _| \_\_ | \_ _,_| \_ _| \_ __/ ____/
733+ Multi-Physics X.Y.Z-hash-Release-ARM64
734+ Compiled for Mac OS and PythonX.Y with Clang-XX.X
735+ Compiled with threading support. Threading support with OpenMP.
736+ Maximum number of threads: N.
737+ ✅ Kratos successfully installed and working!
738+ Installation path: /path/to/site-packages/KratosMultiphysics/__init__.py
739+ ` ` `
740+
741+ # ### Troubleshooting
742+
743+ ** Error: " Unable to find KratosCore" or " Symbol not found in flat namespace" **
744+
745+ - ** Cause:** Python version mismatch (e.g., compiled for Python 3.12 but running Python 3.14)
746+ - ** Solution:** Explicitly specify Python when configuring:
747+ ` ` ` bash
748+ cmake ... -DPYTHON_EXECUTABLE=/opt/homebrew/opt/python@3.14/bin/python3.14
749+ ` ` `
750+
751+ ** Error: " libomp not found" **
752+
753+ - ** Cause:** LLVM from Homebrew not installed
754+ - ** Solution:**
755+ ` ` ` bash
756+ brew install llvm
757+ # Then verify LLVM paths are used in CMake configuration
758+ ` ` `
759+
760+ ** Error: " Boost not found" **
761+
762+ - ** Cause:** Homebrew Boost installed but CMake can' t find it
763+ - **Solution:** Explicitly set Boost path:
764+ ```bash
765+ cmake ... -DBOOST_ROOT=$(brew --prefix boost)
766+ ```
767+
768+ **Build is slow or using system clang**
769+
770+ - **Cause:** System clang is being used instead of Homebrew LLVM
771+ - **Solution:** Verify compiler paths:
772+ ```bash
773+ which clang # Should show /usr/bin/clang, that' s OK
774+ # But CMAKE_CXX_COMPILER should point to Homebrew LLVM:
775+ echo /opt/homebrew/opt/llvm/bin/clang++
776+ ` ` `
777+
778+ ** Permission denied on installation**
779+
780+ - ** Cause:** Writing to Python site-packages requires appropriate permissions
781+ - ** Solution:** Use a Python virtual environment (recommended) or install to custom directory:
782+ ` ` ` bash
783+ cmake ... -DCMAKE_INSTALL_PREFIX=$HOME /.local/opt/kratos
784+ export PYTHONPATH=$PYTHONPATH :$HOME /.local/opt/kratos
785+ ` ` `
786+
787+
788+
646789# # Adding Applications
647790
648791In order to add an application you can use the provided macro (` add_app [PATH]` for *GNU/Linux*, `CALL :add_app [PATH]` for Win) along with the route folder of the application that you want to compile. Several examples are provided in the configuration files.
@@ -761,6 +904,37 @@ rem Build
761904cmake --build " %KRATOS_BUILD%/%KRATOS_BUILD_TYPE%" --target install -- /property:configuration=%KRATOS_BUILD_TYPE% /p:Platform=x64 /p:CL_MPcount=2 /m:2
762905` ` `
763906
907+ # ### MacOS
908+
909+ * MacOS* has a dedicated build script that automatically configures all macOS-specific settings (compilers, OpenMP, Boost, Python):
910+
911+ ` ` ` bash
912+ cd /path/to/Kratos
913+ ./scripts/mac_build -j4
914+ ` ` `
915+
916+ ** This is the recommended approach** for most users. The script will:
917+ - Automatically detect Homebrew-installed LLVM, Boost, and Python
918+ - Configure the correct compiler flags for Apple Silicon or Intel Macs
919+ - Install Kratos to your Python site-packages directory
920+ - Use Ninja if available (faster builds)
921+
922+ ** For advanced users** needing custom configuration, see the [MacOS advanced build section](# macos) for manual CMake instructions.
923+
924+ ** Mac_build script options:**
925+ - ` -j< N> ` : Number of parallel build jobs (default: auto-detected)
926+ - ` -i < path> ` : Custom installation directory
927+ - ` -o " <option>" ` : Pass additional CMake options
928+ - ` -C` : Clean build and install directories
929+ - ` -h` : Show help
930+
931+ Example with custom Python and more cores:
932+ ` ` ` bash
933+ ./scripts/mac_build -o " -DPYTHON_EXECUTABLE=$( which python3.13) " -j8
934+ ` ` `
935+
936+ ** Note:** The older ` scripts/standard_configure_mac.sh` is deprecated. Please use ` scripts/mac_build` instead.
937+
764938Finally you can set parallelism options in the * VisualStudio IDE* .
765939
766940** Warning** : Please be careful while mixing parallel builds with unitary builds. See [below](# unitary-builds)
0 commit comments