# Cmake rule to compile GRC files with GRCC

**URL:** <https://www.ruby-forum.com/t/cmake-rule-to-compile-grc-files-with-grcc/233354>\
**Category:** GNU Radio\
**Created:** [December 7, 2014, 8:58am UTC](https://www.ruby-forum.com/t/cmake-rule-to-compile-grc-files-with-grcc/233354 "2014-12-07T08:58:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [December 7, 2014, 8:58am UTC](https://www.ruby-forum.com/t/cmake-rule-to-compile-grc-files-with-grcc/233354/1 "2014-12-07T08:58:59Z")

</div>

Hi all,

In my third party gnuradio project - gr-gsm  
([GitHub - ptrkrysik/gr-gsm: Gnuradio blocks and tools for receiving GSM transmissions](https://github.com/ptrkrysik/gr-gsm)) - I’m using gnuradio companion to  
create apps. Different versions of gnuradio companion generate python  
files that may be incompatible between different GNU Radio versions.  
Therefore if the user decides to compile gr-gsm it would be best to  
compile python files on his machine, for whatever version of GNU Radio  
he has.

I’m is looking for someone who know how to do this with use of cmake.  
There is a file taken from GNU Radio which is in  
[https://github.com/ptrkrysik/gr-gsm/blob/master/cmake/Modules/GrMiscUtils.cmake](https://github.com/ptrkrysik/gr-gsm/blob/master/cmake/Modules/GrMiscUtils.cmake).  
It had GRCC function which was suited for GNU Radio (although it was not  
really used in GNU Radio). I’ve tried to adapt it to gr-gsm case but it  
caused more problems than it solved. If you know how to write a CMAKE  
rule compiling GRC files with grcc - please help.

Best Regards,  
Piotr K.

---

<div class="post-metadata">

**Author:** ![hibernaculus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/6de8d8/32.png) [@hibernaculus](https://www.ruby-forum.com/u/hibernaculus)\
**Post date:** [December 7, 2014, 6:10pm UTC](https://www.ruby-forum.com/t/cmake-rule-to-compile-grc-files-with-grcc/233354/2 "2014-12-07T18:10:49Z")

</div>

On 12/07/2014 08:57 AM, Piotr K. wrote:

> I’m is looking for someone who know how to do this with use of cmake.  
> There is a file taken from GNU Radio which is in  
> [https://github.com/ptrkrysik/gr-gsm/blob/master/cmake/Modules/GrMiscUtils.cmake](https://github.com/ptrkrysik/gr-gsm/blob/master/cmake/Modules/GrMiscUtils.cmake).  
> It had GRCC function which was suited for GNU Radio (although it was not  
> really used in GNU Radio). I’ve tried to adapt it to gr-gsm case but it  
> caused more problems than it solved. If you know how to write a CMAKE  
> rule compiling GRC files with grcc - please help.

I’ve used this in the past (grc/CMakeLists.txt):

message(“Compiling GRC hier blocks…”)  
foreach(grc\_file ${grc\_hier\_blocks})  
message("Compiling " ${grc\_file})  
execute\_process(  
COMMAND grcc ${grc\_file}  
WORKING\_DIRECTORY ${CMAKE\_CURRENT\_SOURCE\_DIR}  
)  
endforeach(grc\_file ${grc\_hier\_blocks})

…but it’s not ideal as it runs during cmake, not make.

M

---

<div class="post-metadata">

**Author:** ![hibernaculus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/6de8d8/32.png) [@hibernaculus](https://www.ruby-forum.com/u/hibernaculus)\
**Post date:** [December 8, 2014, 8:48am UTC](https://www.ruby-forum.com/t/cmake-rule-to-compile-grc-files-with-grcc/233354/3 "2014-12-08T08:48:22Z")

</div>

W dniu 07.12.2014 o 18:09, Martin B. pisze:

> …but it’s not ideal as it runs during cmake, not make.
> 
> M

Many thanks Martin for the answer. I will give a try your method.

–  
Piotr
