Cmake problem


I want to ask these questions about how to write cmake lists when we
gr-xxx projects (modules) with gr_modtool:

1- How could I add dependencies of my project! For example I’m using a
library in one of my gr block, so how could I tell cmake to check the
dependency? I read GNURadio tutorial :
But it’s confusing! (I’m using GNURadio 3.7.3)

2- How could I merge all of my gr-xxx modules to a single project with
which I could cmake all the modules and making them? This is like
GNURadio source file which one has to cmake, make, install all the gr
modules together.

I know I must use:
*add_subdirectory(gr-xxx) *
in cmake lists but what are the other changes?


Hi Mostafa,

first things first: If you’re trying to use things from the GNU Radio
main tree, refer to [1].

If you want to use external libraries, you will need to modify the
CMakeLists.txt in your module directory and in your lib/ directory.
In the main CMakeLists.txt you will find a paragraph starting with “#
Find *** build dependencies”; after that you’ll see lines like
“find_package(some_library)”; some_library matches a script
Findsome_library.cmake in the cmake/Modules subdirectory.
You might need to write your own, but most probably someone else has
already done that for you, and you can use his code.
This script will set some variables pointing to the header files and to
the linkable library; you will have to add these to the
include_directories(…) variable and link_directories(…), respectively.
In the lib/CMakeLists.txt, you will need to extend the variables of the
same names, and set the target_link_libraries accordingly (for both the
main library and the test).

To see a modern implementation of this with some interesting external
dependencies, maybe take a look at (CMakeLists.txt,
lib/CMakeLists.txt, cmake/Modules/) .



Hi Mostafa,

you’ve forgot to add the mailing list in your reply question; please
always remember to do that :slight_smile:

My library is a package. I think I can find it with package config tool, so
I don’t need Findsome_library.cmake. Am I right?

Ok, this is getting too far away from GNU Radio. I’m referring you to
especially the introduction and the pkg-config related stuff on that

Hope that helps,

Thank you,

Yeah when I sent it, I remembered that I didn’t send it to the mailing
list, excuse me.

OK, I’ll find it.