diff options
Diffstat (limited to 'gr-howto-write-a-block')
-rw-r--r-- | gr-howto-write-a-block/CMakeLists.txt | 6 | ||||
-rw-r--r-- | gr-howto-write-a-block/cmake/Modules/FindLog4cxx.cmake | 28 | ||||
-rw-r--r-- | gr-howto-write-a-block/cmake/Modules/GrMiscUtils.cmake | 32 | ||||
-rw-r--r-- | gr-howto-write-a-block/lib/CMakeLists.txt | 6 |
4 files changed, 71 insertions, 1 deletions
diff --git a/gr-howto-write-a-block/CMakeLists.txt b/gr-howto-write-a-block/CMakeLists.txt index 02b13c6b69..d5d04e24d0 100644 --- a/gr-howto-write-a-block/CMakeLists.txt +++ b/gr-howto-write-a-block/CMakeLists.txt @@ -94,6 +94,10 @@ if(NOT GNURADIO_CORE_FOUND) message(FATAL_ERROR "GnuRadio Core required to compile howto") endif() +# Handle gr_log enable/disable +include(GrMiscUtils) #define LIB_SUFFIX +GR_LOGGING() + ######################################################################## # Setup the include and linker paths ######################################################################## @@ -101,12 +105,14 @@ include_directories( ${CMAKE_SOURCE_DIR}/include ${GNURADIO_CORE_INCLUDE_DIRS} ${GRUEL_INCLUDE_DIRS} + ${LOG4CXX_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ) link_directories( ${GNURADIO_CORE_LIBRARY_DIRS} ${GRUEL_LIBRARY_DIRS} + ${LOG4CXX_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS} ) diff --git a/gr-howto-write-a-block/cmake/Modules/FindLog4cxx.cmake b/gr-howto-write-a-block/cmake/Modules/FindLog4cxx.cmake new file mode 100644 index 0000000000..b1e4f6f1f7 --- /dev/null +++ b/gr-howto-write-a-block/cmake/Modules/FindLog4cxx.cmake @@ -0,0 +1,28 @@ +# CMake module to find LOG4CXX library + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PC_LOG4CXX liblog4cxx) + +FIND_PATH( + LOG4CXX_INCLUDE_DIRS + NAMES log4cxx/log4cxx.h + HINTS $ENV{LOG4CXX_DIR}/include + ${PC_LOG4CXX_INCLUDE_DIRS} + PATHS /usr/local/include + /usr/include +) + +FIND_LIBRARY( + LOG4CXX_LIBRARIES + NAMES log4cxx + HINTS $ENV{LOG4CXX_DIR}/lib + ${PC_LOG4CXX_LIBRARIES} + PATHS /usr/local/lib + /usr/local/lib64 + /usr/lib + /usr/lib64 +) + +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(LOG4CXX DEFAULT_MSG LOG4CXX_LIBRARIES LOG4CXX_INCLUDE_DIRS) +MARK_AS_ADVANCED(LOG4CXX_LIBRARIES LOG4CXX_INCLUDE_DIRS) diff --git a/gr-howto-write-a-block/cmake/Modules/GrMiscUtils.cmake b/gr-howto-write-a-block/cmake/Modules/GrMiscUtils.cmake index 9331d5debc..cffe2f6540 100644 --- a/gr-howto-write-a-block/cmake/Modules/GrMiscUtils.cmake +++ b/gr-howto-write-a-block/cmake/Modules/GrMiscUtils.cmake @@ -208,3 +208,35 @@ function(GR_GEN_TARGET_DEPS name var) set(${var} "DEPENDS;${name};COMMAND;${name}" PARENT_SCOPE) endif() endfunction(GR_GEN_TARGET_DEPS) + + +######################################################################## +# Control use of gr_log +# Usage: +# GR_LOGGING() +# +# Will set ENABLE_GR_LOG to 1 by default. +# Can manually set with -DENABLE_GR_LOG=0|1 +######################################################################## +function(GR_LOGGING) + find_package(Log4cxx) + + OPTION(ENABLE_GR_LOG "Use gr_log" ON) + + if(NOT LOG4CXX_FOUND) + SET(ENABLE_GR_LOG OFF) + endif(NOT LOG4CXX_FOUND) + + message(STATUS "ENABLE_GR_LOG set to ${ENABLE_GR_LOG}.") + + if(ENABLE_GR_LOG) + add_definitions( -DENABLE_GR_LOG ) + else(ENABLE_GR_LOG) + # If not enabled or available, set these variable to + # blank so we can use them later without having to + # check ENABLE_GR_LOG each time. + SET(LOG4CXX_INCLUDE_DIRS "" CACHE INTERNAL "" FORCE) + SET(LOG4CXX_LIBRARY_DIRS "" CACHE INTERNAL "" FORCE) + SET(LOG4CXX_LIBRARIES "" CACHE INTERNAL "" FORCE) + endif(ENABLE_GR_LOG) +endfunction(GR_LOGGING) diff --git a/gr-howto-write-a-block/lib/CMakeLists.txt b/gr-howto-write-a-block/lib/CMakeLists.txt index 835ae02d60..a55bb1fa4a 100644 --- a/gr-howto-write-a-block/lib/CMakeLists.txt +++ b/gr-howto-write-a-block/lib/CMakeLists.txt @@ -23,7 +23,11 @@ include(GrPlatform) #define LIB_SUFFIX add_library(gnuradio-howto SHARED howto_square_ff.cc howto_square2_ff.cc) -target_link_libraries(gnuradio-howto ${Boost_LIBRARIES} ${GRUEL_LIBRARIES} ${GNURADIO_CORE_LIBRARIES}) +target_link_libraries(gnuradio-howto + ${Boost_LIBRARIES} + ${GRUEL_LIBRARIES} + ${GNURADIO_CORE_LIBRARIES} + ${LOG4CXX_LIBRARIES}) set_target_properties(gnuradio-howto PROPERTIES DEFINE_SYMBOL "gnuradio_howto_EXPORTS") ######################################################################## |