← Back to team overview

elementary-dev-community team mailing list archive

Issues finding declarations when using multiple CMakeLists.txt files

 

Dear elementary-dev community,

I'm trying to spend some of my spare time to the development of a new
elementaryOS targeted application. I'm tying to include unit tests, but
I'm stuck on the cmake configuration for this (to be clear: I do not
want to start another pro-contra unit test discussion, I'd just like to
know why cmake/ make fails to find some files)

Current code is available in launchpad:
https://code.launchpad.net/~kurt.smolderen/notebox/trunk.

As you can see, I have a separate src and tests directory. Both contains
a CMakeLists.txt file. As long as my tests do not contain a reference to
a class declared in the src folder, everything compiles. But from the
moment I include a reference to a class declared in this project, the
compiler claims stating "
~Documents/projecten/notebox/build$ make
[  5%] Generating config.c, NoteBox.c, MainWindow.c, data/Note.c,
data/TagList.c, notebox.vapi, notebox.h, notebox_internal.h
/home/ksmolder/Documents/projecten/notebox/src/MainWindow.vala:34.5-34.46:
warning: field `NoteBox.MainWindow.sidebar' never used
    private Granite.Widgets.SourceList sidebar;
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/ksmolder/Documents/projecten/notebox/src/MainWindow.vala:35.5-35.53:
warning: field `NoteBox.MainWindow.main_split_view' never used
    private Granite.Widgets.ThinPaned main_split_view;
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Compilation succeeded - 2 warning(s)
Scanning dependencies of target notebox
[ 11%] Building C object src/CMakeFiles/notebox.dir/config.c.o
[ 17%] Building C object src/CMakeFiles/notebox.dir/NoteBox.c.o
[ 23%] Building C object src/CMakeFiles/notebox.dir/MainWindow.c.o
[ 29%] Building C object src/CMakeFiles/notebox.dir/data/Note.c.o
[ 35%] Building C object src/CMakeFiles/notebox.dir/data/TagList.c.o
Linking C executable notebox
[ 35%] Built target notebox
Scanning dependencies of target notebox-clib
[ 41%] Building C object src/CMakeFiles/notebox-clib.dir/config.c.o
[ 47%] Building C object src/CMakeFiles/notebox-clib.dir/NoteBox.c.o
[ 52%] Building C object src/CMakeFiles/notebox-clib.dir/MainWindow.c.o
[ 58%] Building C object src/CMakeFiles/notebox-clib.dir/data/Note.c.o
[ 64%] Building C object src/CMakeFiles/notebox-clib.dir/data/TagList.c.o
Linking C static library libnotebox-clib.a
[ 70%] Built target notebox-clib
[ 76%] Generating geetestcase.c, test-main.c, data/TestNote.c
/home/ksmolder/Documents/projecten/notebox/tests/data/TestNote.vala:21.9-21.20:
error: The type name `NoteBox.Note' could not be found
        NoteBox.Note note = new NoteBox.Note();
        ^^^^^^^^^^^^
Compilation failed: 1 error(s), 0 warning(s)
make[2]: *** [tests/geetestcase.c] Error 1
make[1]: *** [tests/CMakeFiles/unittests.dir/all] Error 2
make: *** [all] Error 2

So the question is: what do I have to change to make the files from the
src directory visible to the files in the tests directory during
compilation time of the latter? I am probably still missing something in
the tests/CMakeLists.txt file, but I can't figure out what exactly that
would be...

For reference:
http://blog.remysaissy.com/2012/11/setting-up-unit-tests-in-vala-project.html
was used as reference...

Thanks a lot for your help!!

Kind regards
Kurt