From 54473809f79336f35f34abdcc623ab97f0371c8f Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 7 Feb 2019 20:31:40 +0100 Subject: [PATCH 1/3] Imported target for GPerftools --- cmake/Modules/FindGPERFTOOLS.cmake | 49 ++++++++++++++++++++++++++++-- src/main/CMakeLists.txt | 12 +++----- src/tests/CMakeLists.txt | 37 +++++++++++----------- 3 files changed, 70 insertions(+), 28 deletions(-) diff --git a/cmake/Modules/FindGPERFTOOLS.cmake b/cmake/Modules/FindGPERFTOOLS.cmake index 67dfff8af..1c778574f 100644 --- a/cmake/Modules/FindGPERFTOOLS.cmake +++ b/cmake/Modules/FindGPERFTOOLS.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2011-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -33,6 +33,12 @@ # GPERFTOOLS_FOUND System has Gperftools libs/headers # GPERFTOOLS_LIBRARIES The Gperftools libraries (tcmalloc & profiler) # GPERFTOOLS_INCLUDE_DIR The location of Gperftools headers +# +# Provides the following imported targets: +# Gperftools::tcmalloc +# Gperftools::profiler +# Gperftools::gperftools +# find_library(GPERFTOOLS_TCMALLOC NAMES tcmalloc @@ -41,6 +47,8 @@ find_library(GPERFTOOLS_TCMALLOC $ENV{GPERFTOOLS_ROOT}/lib ${GPERFTOOLS_ROOT}/lib64 $ENV{GPERFTOOLS_ROOT}/lib64 + /usr/lib + /usr/lib64 ) find_library(GPERFTOOLS_PROFILER @@ -50,6 +58,8 @@ find_library(GPERFTOOLS_PROFILER $ENV{GPERFTOOLS_ROOT}/lib ${GPERFTOOLS_ROOT}/lib64 $ENV{GPERFTOOLS_ROOT}/lib64 + /usr/lib + /usr/lib64 ) find_library(GPERFTOOLS_TCMALLOC_AND_PROFILER @@ -59,6 +69,8 @@ find_library(GPERFTOOLS_TCMALLOC_AND_PROFILER $ENV{GPERFTOOLS_ROOT}/lib ${GPERFTOOLS_ROOT}/lib64 $ENV{GPERFTOOLS_ROOT}/lib64 + /usr/lib + /usr/lib64 ) find_path(GPERFTOOLS_INCLUDE_DIR @@ -66,6 +78,7 @@ find_path(GPERFTOOLS_INCLUDE_DIR HINTS ${Gperftools_ROOT_DIR}/include ${GPERFTOOLS_ROOT}/include $ENV{GPERFTOOLS_ROOT}/include + /usr/include ) set(GPERFTOOLS_LIBRARIES ${GPERFTOOLS_TCMALLOC_AND_PROFILER}) @@ -76,10 +89,42 @@ find_package_handle_standard_args( DEFAULT_MSG GPERFTOOLS_LIBRARIES GPERFTOOLS_INCLUDE_DIR + GPERFTOOLS_TCMALLOC + GPERFTOOLS_PROFILER + ) +if(GPERFTOOLS_FOUND AND NOT TARGET Gperftools::tcmalloc) + add_library(Gperftools::tcmalloc SHARED IMPORTED) + set_target_properties(Gperftools::tcmalloc PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${GPERFTOOLS_TCMALLOC}" + INTERFACE_INCLUDE_DIRECTORIES "${GPERFTOOLS_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "${GPERFTOOLS_TCMALLOC}" + ) +endif() + +if(GPERFTOOLS_FOUND AND NOT TARGET Gperftools::profiler) + add_library(Gperftools::profiler SHARED IMPORTED) + set_target_properties(Gperftools::profiler PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${GPERFTOOLS_PROFILER}" + INTERFACE_INCLUDE_DIRECTORIES "${GPERFTOOLS_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "${GPERFTOOLS_PROFILER}" + ) +endif() + +if(GPERFTOOLS_FOUND AND NOT TARGET Gperftools::gperftools) + add_library(Gperftools::gperftools SHARED IMPORTED) + set_target_properties(Gperftools::gperftools PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${GPERFTOOLS_TCMALLOC_AND_PROFILER}" + INTERFACE_INCLUDE_DIRECTORIES "${GPERFTOOLS_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "${GPERFTOOLS_TCMALLOC_AND_PROFILER}" + ) +endif() + mark_as_advanced( - Gperftools_ROOT_DIR GPERFTOOLS_TCMALLOC GPERFTOOLS_PROFILER GPERFTOOLS_TCMALLOC_AND_PROFILER diff --git a/src/main/CMakeLists.txt b/src/main/CMakeLists.txt index 0008ae648..b5d9f35bb 100644 --- a/src/main/CMakeLists.txt +++ b/src/main/CMakeLists.txt @@ -30,13 +30,13 @@ target_link_libraries(gnss-sdr gnss_sdr_flags ) +target_compile_definitions(gnss-sdr PRIVATE -DGNSS_SDR_VERSION="${VERSION}") + # Disable internal logging if(NOT ENABLE_LOG) target_compile_definitions(gnss-sdr PRIVATE -DGOOGLE_STRIP_LOG=1) endif() -target_compile_definitions(gnss-sdr PRIVATE -DGNSS_SDR_VERSION="${VERSION}") - if(ENABLE_CUDA) target_link_libraries(gnss-sdr PUBLIC @@ -53,12 +53,8 @@ if(ENABLE_GPERFTOOLS) if(GPERFTOOLS_FOUND) target_link_libraries(gnss-sdr PUBLIC - ${GPERFTOOLS_PROFILER} - ${GPERFTOOLS_TCMALLOC} - ) - target_include_directories(gnss-sdr - PRIVATE - ${GPERFTOOLS_INCLUDE_DIR} + Gperftools::profiler + Gperftools::tcmalloc ) endif() endif() diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 0202a4ec0..bc8419cbb 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -151,23 +151,8 @@ endif() ################################################################################ -# Optional libraries +# Definitions ################################################################################ -set(GNSS_SDR_TEST_OPTIONAL_LIBS "") -set(GNSS_SDR_TEST_OPTIONAL_HEADERS "") - -if(ENABLE_CUDA) - set(GNSS_SDR_TEST_OPTIONAL_HEADERS ${GNSS_SDR_TEST_OPTIONAL_HEADERS} ${CUDA_INCLUDE_DIRS}) - set(GNSS_SDR_TEST_OPTIONAL_LIBS ${GNSS_SDR_TEST_OPTIONAL_LIBS} ${CUDA_LIBRARIES}) -endif() - -if(ENABLE_GPERFTOOLS) - if(GPERFTOOLS_FOUND) - set(GNSS_SDR_TEST_OPTIONAL_LIBS "${GNSS_SDR_TEST_OPTIONAL_LIBS};${GPERFTOOLS_LIBRARIES}") - set(GNSS_SDR_TEST_OPTIONAL_HEADERS "${GNSS_SDR_TEST_OPTIONAL_HEADERS};${GPERFTOOLS_INCLUDE_DIR}") - endif() -endif() - if(${PC_GNURADIO_RUNTIME_VERSION} VERSION_GREATER "3.7.13.4") add_definitions(-DGR_GREATER_38=1) @@ -348,7 +333,6 @@ endif() set(LIST_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/src/tests/common-files - ${GNSS_SDR_TEST_OPTIONAL_HEADERS} ) include_directories(${LIST_INCLUDE_DIRS}) @@ -395,7 +379,6 @@ if(ENABLE_UNIT_TESTING) pvt_adapters signal_processing_testing_lib system_testing_lib - ${GNSS_SDR_TEST_OPTIONAL_LIBS} ) if(ENABLE_UNIT_TESTING_EXTRA) target_link_libraries(run_tests PUBLIC Gpstk::gpstk) @@ -410,6 +393,24 @@ if(ENABLE_UNIT_TESTING) COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_SOURCE_DIR}/install/$) endif() + if(ENABLE_GPERFTOOLS) + if(GPERFTOOLS_FOUND) + target_link_libraries(run_tests + PUBLIC + Gperftools::gperftools + ) + endif() + endif() + if(ENABLE_CUDA) + target_link_libraries(run_tests + PUBLIC + ${CUDA_LIBRARIES} + ) + target_include_directories(run_tests + PUBLIC + ${CUDA_INCLUDE_DIRS} + ) + endif() endif() if(ENABLE_FPGA) From 5d9dea953775ab94468d2557cc9343be77acb1d9 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 7 Feb 2019 20:51:50 +0100 Subject: [PATCH 2/3] Clean CMake scripts --- .../tracking/adapters/CMakeLists.txt | 18 +++++++------ .../tracking/gnuradio_blocks/CMakeLists.txt | 27 +++++++++---------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/algorithms/tracking/adapters/CMakeLists.txt b/src/algorithms/tracking/adapters/CMakeLists.txt index a7211b02d..b9380c539 100644 --- a/src/algorithms/tracking/adapters/CMakeLists.txt +++ b/src/algorithms/tracking/adapters/CMakeLists.txt @@ -26,10 +26,6 @@ if(ENABLE_CUDA) ${OPT_TRACKING_ADAPTERS_HEADERS} gps_l1_ca_dll_pll_tracking_gpu.h ) - set(OPT_TRACKING_INCLUDE_DIRS - ${OPT_TRACKING_INCLUDE_DIRS} - ${CUDA_INCLUDE_DIRS} - ) endif() if(ENABLE_FPGA) @@ -104,10 +100,16 @@ target_link_libraries(tracking_adapters gnss_sdr_flags ) -target_include_directories(tracking_adapters - PUBLIC - ${OPT_TRACKING_INCLUDE_DIRS} -) +if(ENABLE_CUDA) + target_link_libraries(tracking_adapters + PUBLIC + ${CUDA_LIBRARIES} + ) + target_include_directories(tracking_adapters + PUBLIC + ${CUDA_INCLUDE_DIRS} + ) +endif() set_property(TARGET tracking_adapters APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES diff --git a/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt b/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt index 5451846e2..bf342a553 100644 --- a/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt @@ -25,14 +25,6 @@ if(ENABLE_CUDA) ${OPT_TRACKING_BLOCKS_HEADERS} gps_l1_ca_dll_pll_tracking_gpu_cc.h ) - set(OPT_TRACKING_INCLUDES - ${OPT_TRACKING_INCLUDES} - ${CUDA_INCLUDE_DIRS} - ) - set(OPT_TRACKING_LIBRARIES - ${OPT_TRACKING_LIBRARIES} - ${CUDA_LIBRARIES} - ) endif() if(ENABLE_FPGA) @@ -91,20 +83,25 @@ add_library(tracking_gr_blocks target_link_libraries(tracking_gr_blocks PUBLIC Boost::boost - tracking_lib Gnuradio::blocks + Matio::matio Volkgnsssdr::volkgnsssdr gnss_sdr_flags gnss_sp_libs gnss_rx - Matio::matio - ${OPT_TRACKING_LIBRARIES} + tracking_lib ) -target_include_directories(tracking_gr_blocks - PUBLIC - ${OPT_TRACKING_INCLUDES} -) +if(ENABLE_CUDA) + target_link_libraries(tracking_gr_blocks + PUBLIC + ${CUDA_LIBRARIES} + ) + target_include_directories(tracking_gr_blocks + PUBLIC + ${CUDA_INCLUDE_DIRS} + ) +endif() set_property(TARGET tracking_gr_blocks APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES From 8fc749cf726f0a992319ad3b06cb9583914ea4f2 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 7 Feb 2019 20:52:24 +0100 Subject: [PATCH 3/3] Workaround of a CMake bug in Debian 8.11 --- CMakeLists.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d2735b50..2b1040daa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -442,7 +442,15 @@ if(CMAKE_VERSION VERSION_LESS 3.1) set_property(TARGET Threads::Threads PROPERTY INTERFACE_LINK_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}") set_property(TARGET Threads::Threads PROPERTY IMPORTED_LINK_INTERFACE_LANGUAGES "CXX") include(GNUInstallDirs) - set_property(TARGET Threads::Threads PROPERTY IMPORTED_LOCATION /usr/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}pthread${CMAKE_SHARED_LIBRARY_SUFFIX}) + # Fix bug in Debian 8.11 + if(${LINUX_DISTRIBUTION} MATCHES "Debian") + if(${LINUX_VER} VERSION_LESS 8.12) + if(ARCH_64BITS) + set(FIX_PTHREADS_LOCATION "x86_64-linux-gnu/") + endif() + endif() + endif() + set_property(TARGET Threads::Threads PROPERTY IMPORTED_LOCATION /usr/${CMAKE_INSTALL_LIBDIR}/${FIX_PTHREADS_LOCATION}${CMAKE_FIND_LIBRARY_PREFIXES}pthread${CMAKE_SHARED_LIBRARY_SUFFIX}) else() set(CMAKE_THREAD_PREFER_PTHREAD TRUE) if(CMAKE_CROSSCOMPILING)