
CLion guide
CLion guide.
Covers how to set up a build environment for contributing to FreeCAD
Working on FreeCAD is similar to working on may other open-source projects. This guide provides a short overview of the process. Much more information can be found at https://wiki.freecad.org .
To work on FreeCAD you will need CMake, git, a code editor, a C++ compiler, and a Python interpreter. Many different combinations work:
Other combinations may work as well, these are just the ones that you will be able to get help with most readily on the FreeCAD Forum .
See also Dependencies
FreeCAD depends on many other open source projects to provide the basic foundations of the program. There are many ways of installing these dependencies: for details and the complete list, see the following Wiki pages:
One of the easiest ways of creating a standalone FreeCAD build environment with its dependencies in a way that does not affect the rest of your system is to use Pixi .
pixi
using the following command:iwr -useb https://pixi.sh/install.ps1 | iex
curl -fsSL https://pixi.sh/install.sh | bash
Configure FreeCAD for your platform. There are additional steps necessary on Windows outlined in the next subsection.
pixi run configure
Build FreeCAD
pixi run build
If your computer has less ram than is necessary to run a compiler per processor core, then you can reduce the number of parallel compiler jobs. For example, if you wish to limit to 4 parallel compiler processes use the following command:
pixi run build -j 4
Run FreeCAD
pixi run freecad
In general, there will be no need to re-run the configure command as it will be automatically run by pixi run build
if needed. However, there may be times in which a git submodule is added or updated. To integrate these changes, the command pixi run initialize
will run the commands necessary.
Pixi uses the conda-forge
packages, including the compilers
metapackage to bring in the platform-specific compiler support. On Windows, it is expected that Microsoft Visual C++ has been installed and matches the version used by the conda-forge
team, which is Visual Studio Community 2019
.
The Visual Studio Installer may be used to install Visual Studio Community 2019 alongside newer versions of Visual Studio. Ensure all of the necessary components are installed:
Open the Visual Studio Installer
Click modify
for Visual Studio 2019.
Make sure to select Desktop development with C++
under the Desktop & Mobile
section. Ensure that the necessary optional items are selected on the right.
Fork https://github.com/FreeCAD/FreeCAD on GitHub
Clone your fork: for example, on the command line you can use git clone --recurse-submodules https://github.com/YourUsername/FreeCAD FreeCAD-src
Set up pre-commit
(our automatic code-formatter and checker):
pre-commit
(either using your system package manager or pip):apt install pre-commit
dnf install pre-commit
(Fedora)pacman -S pre-commit
pip install pre-commit
python -m pip install pre-commit
cd FreeCAD-src
pre-commit install
(or python -m pre-commit install
, depending on your PATH)We strongly recommend doing an out-of-source build, that is, build FreeCAD and put all generated files in a separate directory. Otherwise, the build files will be spread all over the source code and it will be much harder to sort out one from the other. A build directory can be created outside the FreeCAD source folder or inside:
mkdir build
cd build
Run CMake, either in via the CMake GUI or on the command line see the wiki compilation page for your operating system for a detailed list of options.
CMake will generate project files that can be read by your IDE of choice. See your IDE’s documentation for details. In general:
cmake --build /path/to/FreeCAD-src
run from your build directory ( or cmake --build ..
if your build directory is inside FreeCAD-src).cmake --build /path/to/FreeCAD-src
from your build directory, or if using CLion be sure to “Build All” the first time you run.If you plan on submitting a PR, create a branch:
git branch fixTheThing
git checkout fixTheThing
(or both commands in one go: git checkout -b fixTheThing
)The basic process is:
git add file1.cpp file2.cpp
git commit -m "Sketcher: Fixed bug in constraints" -m "Added foo to bar. Fixes #1234."
git commit
our pre-commit hooks will run to check your code. If the scripts had to make changes, you will have to git add
the changed files and run git commit
again.git push
to send your changes to GitHubMaintainers review PRs on a rolling basis throughout the week, and also in a more concentrated review meeting on Mondays (see the FreeCAD Events Calendar for the exact date and time in your timezone). When reviewing, Maintainers strive to uphold the tenets of the CONTRIBUTING document. These meetings are open to the public and all developers are welcome to attend: particularly if you have a PR under review, you may be able to accelerate that process by being present to address and questions or concerns that arise. You can also participate in the process by reviewing PRs yourself. Although only Maintainers may merge PRs, anyone is welcome to test and provide feedback, and Maintainers take that feedback into consideration when evaluating PRs. Any time you can contribute to the project is appreciated!
To expedite the PR review process, consider the following guidelines:
CLion guide.
Dependencies.
VSCode.