Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

build c++ in debug mode with biicode cmake

Tags:

c++

cmake

biicode

As I am unable to change from release to debug build type, I wonder what am I doing wrong. I am working with Unix Makefiles.

In docs.biicode.com/c++/building.html says how adding SET() in the CMakeLists.txt adds variables to cmake.

I am new to cmake and biicode, and I tried all of:

ADD_DEFINITIONS(-DCMAKE_BUILD_TYPE=Debug)
ADD_DEFINITIONS(-DCMAKE_BUILD_TYPE:STRING=Debug)
SET(CMAKE_BUILD_TYPE Debug)
target_compile_options(my_program PUBLIC $<$<CONFIG:Debug>:-Werror>)

but gdb says that "no debugging symbols found".

Another way, as states bii --help cpp, is passing to cpp:build parameters that will be passed to cmake, but calling

bii cpp:build -DCMAKE_BUILD_TYPE=Debug

yields

Building: cmake --build . -DCMAKE_BUILD_TYPE=Debug
Unknown argument -DCMAKE_BUILD_TYPE=Debug

but calling directly

cmake -DCMAKE_BUILD_TYPE=Debug --build .

works ok, and I don't know how to change the order in the bii cpp:build command.

Is all this a misconception, a sintax error, or there must be something else wrong? what is the best place to change between Debug and Release?

like image 742
jmmut Avatar asked Nov 18 '14 00:11

jmmut


1 Answers

From the biicode docs, it looks like you need to use the bii cpp:configure command to pass arguments to CMake, not bii cpp:build.

As @ruslo commented, it's not good practice to set the CMAKE_BUILD_TYPE inside the actual CMakeLists.txt (see his answer for more details), so you probably want to do:

bii cpp:configure -DCMAKE_BUILD_TYPE=Debug
bii cpp:build

I realise you said you are working with Unix makefiles, but if you were using a multi-configuration generator (like Visual Studio), the build type doesn't get set at configure time. Rather it gets set at build time. In that case, I'd expect the biicode commands to be more like:

bii cpp:configure -G "Visual Studio 12 Win64"
bii cpp:build --config Debug
like image 75
Fraser Avatar answered Oct 10 '22 11:10

Fraser