# Cmake problem

**URL:** <https://www.ruby-forum.com/t/cmake-problem/229969>\
**Category:** GNU Radio\
**Created:** [May 24, 2014, 5:26pm UTC](https://www.ruby-forum.com/t/cmake-problem/229969 "2014-05-24T17:26:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jason\_sam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7993a0/32.png) [@jason\_sam](https://www.ruby-forum.com/u/jason_sam)\
**Post date:** [May 24, 2014, 5:26pm UTC](https://www.ruby-forum.com/t/cmake-problem/229969/1 "2014-05-24T17:26:15Z")

</div>

Hi,

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

1- How could I add dependencies of my project! For example I’m using a  
c++  
library in one of my gr block, so how could I tell cmake to check the  
dependency? I read GNURadio tutorial :  
[http://gnuradio.org/redmine/projects/gnuradio/wiki/OutOfTreeModulesConfig](http://gnuradio.org/redmine/projects/gnuradio/wiki/OutOfTreeModulesConfig)  
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  
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?

best,  
mostafa

---

<div class="post-metadata">

**Author:** ![mostafa\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/5e9695/32.png) [@mostafa\_a](https://www.ruby-forum.com/u/mostafa_a)\
**Post date:** [May 24, 2014, 10:09pm UTC](https://www.ruby-forum.com/t/cmake-problem/229969/2 "2014-05-24T22:09:41Z")

</div>

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  
[http://git.osmocom.org/gr-fosphor/tree/](http://git.osmocom.org/gr-fosphor/tree/) (CMakeLists.txt,  
lib/CMakeLists.txt, cmake/Modules/) .

Greetings,  
Marcus

[1]  
[http://gnuradio.org/redmine/projects/gnuradio/wiki/OutOfTreeModulesConfig](http://gnuradio.org/redmine/projects/gnuradio/wiki/OutOfTreeModulesConfig)

---

<div class="post-metadata">

**Author:** ![mostafa\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/5e9695/32.png) [@mostafa\_a](https://www.ruby-forum.com/u/mostafa_a)\
**Post date:** [May 26, 2014, 2:09am UTC](https://www.ruby-forum.com/t/cmake-problem/229969/3 "2014-05-26T02:09:11Z")

</div>

Hi Mostafa,

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

> 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

> **[CMake Wiki has moved](https://cmake.org/rdrctcm.php?old_link=CMake:How_To_Find_Libraries)**

especially the introduction and the pkg-config related stuff on that  
page.

Hope that helps,  
Greetings,  
Marcus

---

<div class="post-metadata">

**Author:** ![mostafa\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/5e9695/32.png) [@mostafa\_a](https://www.ruby-forum.com/u/mostafa_a)\
**Post date:** [May 26, 2014, 2:12am UTC](https://www.ruby-forum.com/t/cmake-problem/229969/4 "2014-05-26T02:12:52Z")

</div>

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.
