What is the best way to compile a standalone tool?

Having trouble installing or compiling FreeCAD? Get help here.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
hrhassan
Posts: 75
Joined: Mon May 25, 2020 3:25 am

What is the best way to compile a standalone tool?

Post by hrhassan »

I am following this tutorial: https://www.youtube.com/watch?v=s4pHvlD ... e=youtu.be to compile a FreeCAD build. I am successful till the end, however, my main goal is to make a standalone tool using the FreeCAD source code. I want to extract the Sketcher module and make it into an independent, stand-alone program. What is the best away to approach this goal from where I am currently? Thank you for your time.
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: What is the best way to compile a standalone tool?

Post by vocx »

hrhassan wrote: Mon May 25, 2020 5:04 am ... I want to extract the Sketcher module and make it into an independent, stand-alone program...
But what do you want to do with it exactly?

The core of FreeCAD is composed of the code in the src/App and src/Base directories. Essentially everything else is optional. The main interface is in src/Gui. Then each of the workbenches, like the Sketcher, is in one of the src/Mod/ directories. If you only want to have the Sketcher, then you could compile the base of FreeCAD, and deactivate every module except for the Sketcher and Part.

The Part Module is necessary because it is the one that connects to the OpenCASCADE Technology (OCCT) libraries and produces all the geometrical shapes that you see on screen. All the lines in the Sketcher are created from calls to Part.

The Base system handles core stuff like Units and Vectors, the App portion describes the basic properties of the objects, and how they will be saved to disk, and the Gui system defines the graphical interface, and things like visual properties of the objects in the 3D view, the selection mechanism, and how to build graphical commands.

So, depending on what you want to do, you could essentially have a stripped down FreeCAD contained within your bigger program. You wouldn't just have the Sketcher, because it would still require pieces of Part, and the Base, App, Gui parts. Of if you just want the solver of the Sketcher, that is somewhere in the src/Mod/Sketcher directory, but it wouldn't work without the rest of the system.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
hrhassan
Posts: 75
Joined: Mon May 25, 2020 3:25 am

Re: What is the best way to compile a standalone tool?

Post by hrhassan »

Thank you for your reply. I am tasked to compile a stand alone application from an open source project as part of a college class assignment, so I chose FreeCAD and would like to extract the Sketcher Tool into it's own application, where as soon as you were to open the app, it would go into Sketcher mode. I do need those dependencies including App, Base, Gui, and Part of course.

You mentioned "If you only want to have the Sketcher, then you could compile the base of FreeCAD, and deactivate every module except for the Sketcher and Part."

How should I deactivate within Visual Studio when compiling? Would I also need the Start Gui, StartPage, and StartScripts modules or is there a better way to go directly to the Sketcher Function? Thank you for your time.
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: What is the best way to compile a standalone tool?

Post by vocx »

hrhassan wrote: Mon May 25, 2020 4:16 pm ...
How should I deactivate within Visual Studio when compiling?
The build system that FreeCAD uses is CMake, which contains a toplevel CMakeLists.txt file. When this is imported, it should show you a list of variables that you can set to control the parts of FreeCAD that are compiled. See the information in Compiling, and Compile on Windows.

I don't know exactly the minimum number of modules that you need; I've only compiled the full program.

But if you just want to automatically start the Sketcher, this is possible with the full program as well. You just need to set the correct property in the Preferences Editor, in the General section.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
hrhassan
Posts: 75
Joined: Mon May 25, 2020 3:25 am

Re: What is the best way to compile a standalone tool?

Post by hrhassan »

Thank you for your reply. So how would this process go if I were to want to disable certain features such as the Macro Recorder and Command Menu Drop downs? Where can I access those features? Thank you
Post Reply