cmakelists.txt fot C++ IDE
Hi all, I want to work with simple gnuradio objects in a C++ IDE (e.g. Qtcreator) using CMake build system. I am running ubuntu 22.04 and gnuradio 3.10.11.0. How can I write its cmakelists.txt? For example, to just test these PMT lines: #include // [...] pmt::pmt_t P = pmt::from_long(23); std::cout << P << std::endl; pmt::pmt_t P2 = pmt::from_complex(0,1); std::cout << P2 << std::endl; std::cout << pmt::is_complex(P2) << std::endl; I add the following lines to its cmakelists.tx # Find GNU Radio package, specifying required components find_package(Gnuradio "3.10" REQUIRED COMPONENTS pmt) # Adjust the version and components as needed # Check if GNU Radio is found if(Gnuradio_FOUND) message(STATUS "GNU Radio found.") message(STATUS "GNU Radio include dirs: ${Gnuradio_INCLUDE_DIRS}") message(STATUS "GNU Radio libraries: ${Gnuradio_LIBRARIES}") else() message(FATAL_ERROR "GNU Radio not found!") endif() # Include directories for your project include_directories( ${Gnuradio_INCLUDE_DIRS} # GNU Radio include directories ${CMAKE_SOURCE_DIR}/include # Your custom include directories ) # Define the executable add_executable(myproject ${SOURCES}) # Link the executable with GNU Radio libraries target_link_libraries(myproject ${GNURADIO_LIBRARIES}) but it doesn't work. I'd be grateful if someone help me write working cmakelists.txt. Thanks!
Re: cmakelists.txt fot C++ IDE
"Ali G. Dezfuli" writes: > Hi all, > I want to work with simple gnuradio objects in a C++ IDE (e.g. Qtcreator) > using CMake build system. > I am running ubuntu 22.04 and gnuradio 3.10.11.0. > How can I write its cmakelists.txt? The components are now available as CMake gnuradio::gnuradio-COMPONENT targets. > # Link the executable with GNU Radio libraries > target_link_libraries(myproject ${GNURADIO_LIBRARIES}) instead: target_link_libraries(myproject gnuradio::gnuradio-pmt) should do the trick. 73 de aa4hs, -Maitland
Re: cmakelists.txt fot C++ IDE
Hi Ali, since CMake is the default build system we use both for our OOT templates (as used by gr_modtool) and by the C++ code generated throug GRC, I'd say: just use the existing work as template. What you're doing here is mixing modern CMake, i.e. a config/target-based method of defining the compiler and linker properties of your compilation units, with manual "include_directories" things. Probably not a great idea! If you compare that with what `gr_modtool` generates in its lib/CMakeLists.txt, you'll find how we'd, as a project, would recommend you do it. Best, Marcus On 01.08.24 11:17, Ali G. Dezfuli wrote: Hi all, I want to work with simple gnuradio objects in a C++ IDE (e.g. Qtcreator) using CMake build system. I am running ubuntu 22.04 and gnuradio 3.10.11.0. How can I write its cmakelists.txt? For example, to just test these PMT lines: #include// [...] pmt::pmt_tP=pmt::from_long(23);std::cout< I add the following lines to its cmakelists.tx # Find GNU Radio package, specifying required components find_package(Gnuradio "3.10" REQUIRED COMPONENTS pmt) # Adjust the version and components as needed # Check if GNU Radio is found if(Gnuradio_FOUND) message(STATUS "GNU Radio found.") message(STATUS "GNU Radio include dirs: ${Gnuradio_INCLUDE_DIRS}") message(STATUS "GNU Radio libraries: ${Gnuradio_LIBRARIES}") else() message(FATAL_ERROR "GNU Radio not found!") endif() # Include directories for your project include_directories( ${Gnuradio_INCLUDE_DIRS} # GNU Radio include directories ${CMAKE_SOURCE_DIR}/include # Your custom include directories ) # Define the executable add_executable(myproject${SOURCES}) # Link the executable with GNU Radio libraries target_link_libraries(myproject ${GNURADIO_LIBRARIES}) but it doesn't work. I'd be grateful if someone help me write working cmakelists.txt. Thanks!
hier block location in 3.10.11
This isn't a serious issue but I'm curious. According to https://wiki.gnuradio.org/index.php/Hier_Blocks_and_Parameters, "For GNU Radio v3.10, the files will be created in the directory where the /.grc/ file is saved. Please create the /.grc_gnuradio/ directory and copy the /.py/ and /.yml/ files there:" However the associated hier block *.py and *.yml files appear in ~/.local/state/gnuradio. I copy them over to ~/.grc_gnuradio and all appears well. Is this the intended behaviour? Rick
Re: cmakelists.txt fot C++ IDE
Done! Big Thanks! I just connected a "Signal Source" to a "Null Sink" in GRC, changed the Option's "Output Language" to C++, pushed "Generate" (F5), took a look at the generated CMakeLists.txt, and found the answer. Thanks! On Thu, Aug 1, 2024 at 10:15 PM Marcus Müller wrote: > Hi Ali, > > since CMake is the default build system we use both for our OOT templates > (as used by > gr_modtool) and by the C++ code generated throug GRC, I'd say: > > just use the existing work as template. > > What you're doing here is mixing modern CMake, i.e. a config/target-based > method of > defining the compiler and linker properties of your compilation units, > with manual > "include_directories" things. Probably not a great idea! If you compare > that with what > `gr_modtool` generates in its lib/CMakeLists.txt, you'll find how we'd, as > a project, > would recommend you do it. > > Best, > Marcus > > On 01.08.24 11:17, Ali G. Dezfuli wrote: > > Hi all, > > I want to work with simple gnuradio objects in a C++ IDE (e.g. > Qtcreator) using CMake > > build system. > > I am running ubuntu 22.04 and gnuradio 3.10.11.0. > > How can I write its cmakelists.txt? > > > > For example, to just test these PMT lines: > > > > #include// [...] > > > pmt::pmt_tP=pmt::from_long(23);std::cout< > > > I add the following lines to its cmakelists.tx > > > > # Find GNU Radio package, specifying required components > > find_package(Gnuradio "3.10" REQUIRED COMPONENTS pmt) # Adjust the > version and components > > as needed > > > > # Check if GNU Radio is found > > if(Gnuradio_FOUND) > > message(STATUS "GNU Radio found.") > > message(STATUS "GNU Radio include dirs: ${Gnuradio_INCLUDE_DIRS}") > > message(STATUS "GNU Radio libraries: ${Gnuradio_LIBRARIES}") > > else() > > message(FATAL_ERROR "GNU Radio not found!") > > endif() > > > > # Include directories for your project > > include_directories( > > ${Gnuradio_INCLUDE_DIRS} # GNU Radio include directories > > ${CMAKE_SOURCE_DIR}/include # Your custom include directories > > ) > > > > # Define the executable > > add_executable(myproject${SOURCES}) > > > > # Link the executable with GNU Radio libraries > > target_link_libraries(myproject ${GNURADIO_LIBRARIES}) > > > > but it doesn't work. > > > > I'd be grateful if someone help me write working cmakelists.txt. > > > > Thanks! > > > >