Developing KiCad: Configure an IDE

First of all it should be split into three, one for each platform (Win, Lin, Mac). After that it would be much easier to follow. I would even go as far as having separate documents for different Linux distros, even if it creates duplicated text.

EDIT: part of the documentation for Debian is here: https://kicad.org/download/debian/. But I don’t know if it’s up to date; and I have proposed a better alternative for installing the dependencies easily without knowing what they are.

Hey Russ,
yes that is possible and was done in my writeup.
As already mentioned the -DCMAKE_INSTALL_PREFIX does define where the binaries are stored after comiling.
So no official builds are overwritten or modified.

As for my attempt, the total sizes if I compile KiCad in Release and in Debug Mode, together with the sourcecode and objectcode (so everything I need to compile run and debug everything) I get around 8GiB diskspace and I cannot see any (major) difference in RAM usage for a live debugging.

1 Like

Yeah I thought so too, unfortunately I am too blind to see and to stupid to correctly search for a solution.
ATM it is just an inconvenience but I hope someone who reads this has an idea :slight_smile:

That is one way, but if you are using one of the supported KiCad linux versions (currently only Ubuntu and Fedora, I haven’t done Debian yet), you can try the scripts that I have been putting together to build out CI docker containers to build and test KiCad in the code repository. They are available here: https://gitlab.com/kicad/kicad-ci/source_containers/tree/master/scripts. This has several options for different packages to install (such as different Python versions, OCE, OCC, with/without ngspice, etc.), and also includes tooling for compiling, debugging, and doing the formatting checks. (note: ngspice on Ubuntu 18.04 is somewhat problematic, and requires some after-processing that is done in its dockerfile not in the install script). Or, if you are feeling adventurous and have used containers before, you can even try to use the actual containers from that repository. I know that KiCad can successfully configure on each container, and builds fine on Fedora (I haven’t run the build on the Ubuntu container yet).

If you want to have different versions (e.g. both 5.1 and master) installed side-by-side, I would suggest that you also use the CMake variable -DKICAD_CONFIG_DIR=<wherever> to separate the configuration files for the two.

All of the KiCad dependencies can take upwards of 700-800MB of space on an install. (The Ubuntu containers increased from 25MB to 646MB with everything installed, and Fedora increased from 63MB to 733MB with everything installed). The actual compiled code can be upwards of 6-8GB for the debug builds, and probably around half to 3/4 of that for release builds.

Edit:

Splitting by platform would work, but I would suggest we avoid splitting by the Linux distros. We could just provide the dependency list, and then link to the CI install scripts for the dependency installation for each OS. I would like to avoid hard-coding the package names into the docs if at all possible. After dependency installation, all linux builds will basically be the same.

At least in debian and fedore package systems (.deb and .rpm) based distros) there is a way to install build dependencies - and not only libraries, but build systems etc. - as long as prepackaged nightly builds are available for the platform. I would document that. It’s been explained in some forum threads.

Hmm, I didn’t know that DNF provided a way to install all the dependent packages.

BTW, if you didn’t notice a relevant thread about dependencies is going on:

Current directory is ~/Kicad
$ cmake -DCMAKE_INSTALL_PREFIX=build/debug/bin/ -DCMAKE_BUILD_TYPE=Debug
CMake Warning:
No source or binary directory provided. Both will be assumed to be the
same as the current working directory, but note that this warning will
become a fatal error in future CMake releases.

– Configuring done
– Generating done
– Build files have been written to: /home/user/Kicad
$ ls build/debug/bin
$ ls
build cmake_install.cmake hello_world Makefile my_2020_cmake_log.txt.bk1
CMakeCache.txt CMakeLists.txt helloworld.cpp Makefile.bk1 my_kcb_log.txt
CMakeFiles cmake_URLs.txt kicad my_2020_cmake_log.txt qtcreator
$ ls build/
debug release
$ ls build/debug/
bin
$ ls build/debug/bin/

-- Configuring done
-- Generating done
-- Build files have been written to: /home/user/Kicad

$ ls build/debug/bin
$ ls build/
debug release
$ ls build/debug/
bin
$ ls build/debug/bin/

Well, it said the build files were written, but obviously they were not.
Where did I go wrong?

Thank you, herostat. You just defined me. Before writing this post, I installed cmake version 3.13.4, watched a youtube video on how to use cmake, and then successfully ran cmake with the {hello world} code given in the video.

Run cmake from build directory otherwise you will contaminate source tree and run into problems.
By build directory I mean Kicad/build/release or Kicad/build/debug or wherever you want your build to actually happen.

[code]user@solydk1:~/Kicad/build/debug$ cmake -DCMAKE_INSTALL_PREFIX=build/debug/bin/ -DCMAKE_BUILD_TYPE=Debug
CMake Warning:
No source or binary directory provided. Both will be assumed to be the
same as the current working directory, but note that this warning will
become a fatal error in future CMake releases.

CMake Error: The source directory “/home/user/Kicad/build/debug” does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
user@solydk1:~/Kicad/build/debug$ cmake -DCMAKE_INSTALL_PREFIX=…/ -DCMAKE_BUILD_TYPE=Debug
CMake Warning:
No source or binary directory provided. Both will be assumed to be the
same as the current working directory, but note that this warning will
become a fatal error in future CMake releases.

CMake Error: The source directory “/home/user/Kicad/build/debug” does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
user@solydk1:~/Kicad/build/debug$ cmake -DCMAKE_INSTALL_PREFIX=/home/user/Kicad/build/debug/bin/ -DCMAKE_BUILD_TYPE=Debug
CMake Warning:
No source or binary directory provided. Both will be assumed to be the
same as the current working directory, but note that this warning will
become a fatal error in future CMake releases.

CMake Error: The source directory “/home/user/Kicad/build/debug” does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
user@solydk1:~/Kicad/build/debug$ cmake -DCMAKE_INSTALL_PREFIX=./ -DCMAKE_BUILD_TYPE=DebugCMake Warning:
No source or binary directory provided. Both will be assumed to be the
same as the current working directory, but note that this warning will
become a fatal error in future CMake releases.

CMake Error: The source directory “/home/user/Kicad/build/debug” does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.[/code]
I must be doing something stupid, but I don’t see what it is.

From /home/user/Kicad,

user@solydk1:~/Kicad$ find ./ -name "CMakelists.txt" 

From where I expect the build to be created, ~/Kicad/build/debug,

user@solydk1:~/Kicad/build/debug$ pwd
/home/user/Kicad/build/debug
user@solydk1:~/Kicad/build/debug$ cmake -DCMAKE_INSTALL_PREFIX=../../ -DCMAKE_BUILD_TYPE=Debug
CMake Warning:
  No source or binary directory provided.  Both will be assumed to be the
  same as the current working directory, but note that this warning will
  become a fatal error in future CMake releases.


CMake Error: The source directory "/home/user/Kicad/build/debug" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.

I thought -DCMAKE_INSTALL_PREFIX specified a relative path to CMakelists.txt. Am I wrong?

That specifies where make install should put the program after it’s compiled. To point cmake to root source dir just pass ../../ as last parameter.
cmake -Dsomething -Dsomeotherthing ../../

vim+ctags or equivalent setups running in pure terminal can be quite powerful when configured with all kinds of plugins and shortcuts but they have very steep learning curve. Even today it’s a very viable way to work on code and many do just that.
However even when you master these tools they are still bound by limitations of pure text interface and simply cannot provide the level of comfort and ergonomics of a well designed GUI app. What I like about VSCode is that everything there is configurable and you can add your own actions running arbitrary parametrized shell commands, making that the best of both GUI/terminal worlds imho.

Well, I tried what you said from inside /home/user/Kicad and this is what happened:

user@solydk1:~/Kicad$ cmake -DCMAKE_INSTALL_PREFIX=../../ -DCMAKE_BUILD_TYPE=Debug ./build/release/bin/ 
CMake Error: The source directory "/home/user/Kicad/build/release/bin" does not appear to contain CMakeLists.txt.

I don’t know enough about cmake to know what I’m doing wrong.

I think I wasn’t clear enough.
From /home/user/Kicad/build/debug do this:

cmake -DCMAKE_BUILD_TYPE=Debug ../../

The working directory of where you run cmake from is where cmake will generate build files. Last parameter in the command above is the relative path to where cmake will look for CMakeLists.txt. So when you are in Kicad/build/debug this ../../ will point to Kicad. Makes sense?
After you’ve run cmake like this (assuming it didn’t throw a bunch of errors at you) you will run make to actually build kicad using the build files that cmake generated. To speed up build you can run it with multiple threads like make -j16. Put the number of cores/threads of your CPU instead of 16 there.

Awesome! this is a very good and helpful step by step tutorial.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.