|
From: | Marcus Müller |
Subject: | Re: [Discuss-gnuradio] GNURadio CMake question |
Date: | Thu, 29 Oct 2015 10:58:29 +0100 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 |
Hi Damindra, I'm assuming you're looking at an out-of-tree (OOT) module that was generated with gr_modtool (i.e. that follows the usual CMake architecture). So, there's a CMakeLists.txt in your main folder and in lib/. When you look at the main CMakeLists.txt (I'm linking to an example here, [1]), you'll find lines like find_package(PackageName)which is a way of telling CMake to look into a few directories, looking for a file called "FindPackageName.cmake". Let's illustrate this with: find_package(CppUnit)This makes CMake look into your OOT's cmake/Modules/, and execute what's in FindCppUnit.cmake[2]. What that does is very similar to the magic autotools does: It first asks pkg-config about cppunit [3] and then verifies that the files are actually are there, or tries to guess their location. Chances are your library also has a pkg-config entry[4]. So, what you'd do is
Notice that this clearly isn't the fastest way to just link
against a library; you could of course also just "hardcode" the
library name and include paths in 5. and 6., but 1. -- 4. gives
you a portable (to some extent, even to Windows) and reusable
solution, even on systems (like mine) where self-built libraries
might be in totally unusual locations. I personally find writing
build scripts a bit boring, but its a job worth doing right from
the start, because fixing the problems you get when you try to run
the same build procedure on a slightly different machine just
isn't worth it. Not to mention the frustration you save other
people when they happen to try your code on their machine. Best regards, and happy hacking, [1] https://github.com/marcusmueller/gr-debugme/blob/master/CMakeLists.txt#L104 [2] https://github.com/marcusmueller/gr-debugme/blob/master/cmake/Modules/FindCppUnit.cmake [3] https://github.com/marcusmueller/gr-debugme/blob/master/cmake/Modules/FindCppUnit.cmake#L13 [4] check by running "pkg-config --list-all|grep -i NAMEOFYOURLIBRARY" [5] https://github.com/marcusmueller/gr-debugme/blob/master/lib/CMakeLists.txt#L25 [6] https://github.com/marcusmueller/gr-debugme/blob/master/lib/CMakeLists.txt#L39 On 29.10.2015 04:28, Damindra Bandara
wrote:
|
[Prev in Thread] | Current Thread | [Next in Thread] |