Compilation flow for debug and development

Discussion about new features and development support

Moderator: thorsten

Post Reply
wallclimber21
Posts: 2
Joined: Thu 12 Aug 2021, 00:03

Compilation flow for debug and development

Post by wallclimber21 » Thu 12 Aug 2021, 00:21

Right now, I'm doing the following to step through the openems code (to understand it better and, later, make changes and debug):
  • Patch the ./openems/CMakeList.txt to change from 'Release' to 'Debug' on line 6
  • Run "./update_openEMS.sh `pwd`/debug_build" to compile the whole thing
  • Run gdb on "debug_build/bin/openEMS"
The whole thing is not ideal, especially because everything gets compiled in a "/tmp" directory and then gets deleted after everything passes.

I'd like to know the the detailed steps do thing the traditional way, with running cmake and make and then have incremental builds whenever you make a little change.

Unfortunately, creating a "build" directory in "openems" and then doing "cmake .." results in a whole bunch of stuff that's not being found.

I'm looking at the "update_openEMS.sh" script to figure out how to do this, but somebody else must have had the same problems and already know the answer right away?

Thanks!

wallclimber21
Posts: 2
Joined: Thu 12 Aug 2021, 00:03

Re: Compilation flow for debug and development

Post by wallclimber21 » Thu 12 Aug 2021, 01:15

Here's my current recipe:

* Patch the ./openems/CMakeList.txt and change Release to Debug on line 6
* Build everything completely:

Code: Select all

cd .../openEMS-Project/
mkdir build
cd build
cmake  -DBUILD_APPCSXCAD=0 -DCMAKE_INSTALL_PREFIX=./b -DWITH_MPI=0 ..
make -j $(nproc)
* the binaries are now in the ./build/b/bin directory

If you make a code change to an openems file, then do an incremental compile as follows:

Code: Select all

cd .../openEMS-Project/build/openEMS-prefix/src/openEMS-build
make -j $(nproc)
Much better!

thorsten
Posts: 1468
Joined: Mon 27 Jun 2011, 12:26

Re: Compilation flow for debug and development

Post by thorsten » Sun 22 Aug 2021, 09:46

Hi,

sorry I missed this question. Yes what I do for development I run every part manually. For that you can create a file called "localConfig.cmake" which gets loaded by the "normal" cmake file to make local changes that also do not git tracked.

In my localConfig.cmake for CSXCAD is the following (for example):

Code: Select all

SET(FPARSER_ROOT_DIR /home/thorsten/opt/openEMS)
SET(CMAKE_INSTALL_PREFIX /home/thorsten/opt/openEMS)
or for openEMS:

Code: Select all

SET(WITH_MPI 0)
SET(FPARSER_ROOT_DIR /home/thorsten/opt/openEMS)
SET(CSXCAD_ROOT_DIR /home/thorsten/opt/openEMS)
SET(CMAKE_INSTALL_PREFIX /home/thorsten/opt/openEMS)
I guess setting to debug can be done like this too. But to be honest I rarely use gdb and thus mostly just develop running the release state. Because I want to have/see the full speed of the code most of the time...

With having this file I do it pretty much like you do too...

regards
Thorsten

Post Reply