From 09d94529e5dbfa992cb6012cc0dc38d6f3e7d57d Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Thu, 2 Sep 2021 11:38:05 +0200 Subject: cmake: Replace CMAKE_{SOURCE,BINARY}_DIR with UHD_*_DIR See the CMake 3.8 documentation on these two variables: https://cmake.org/cmake/help/v3.8/variable/PROJECT-NAME_SOURCE_DIR.html https://cmake.org/cmake/help/v3.8/variable/CMAKE_SOURCE_DIR.html Under normal circumstances, these two are identical. For sub-projects (i.e., when building UHD as part of something else that is also a CMake project), only the former is useful. There is no discernible downside of using UHD_SOURCE_DIR over CMAKE_SOURCE_DIR. This was changed using sed: $ sed -i "s/CMAKE_SOURCE_DIR/UHD_SOURCE_DIR/g" \ `ag -l CMAKE_SOURCE_DIR **/{CMakeLists.txt,*.cmake}` $ sed -i "s/CMAKE_BINARY_DIR/UHD_BINARY_DIR/g" \ `ag -l CMAKE_BINARY_DIR **/{CMakeLists.txt,*.cmake}` At the same time, we also replace the CMake variable UHD_HOST_ROOT (used in MPM) with UHD_SOURCE_DIR. There's no reason to have two variables with the same meaning and different names, but more importantly, this means that UHD_SOURCE_DIR is defined even in those cases where MPM calls into CMake files from UHD without any additional patches. Shoutout to GitHub user marcobergamin for bringing this up. --- host/cmake/Modules/CodeCoverage.cmake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'host/cmake/Modules/CodeCoverage.cmake') diff --git a/host/cmake/Modules/CodeCoverage.cmake b/host/cmake/Modules/CodeCoverage.cmake index e19c6399d..449b317af 100644 --- a/host/cmake/Modules/CodeCoverage.cmake +++ b/host/cmake/Modules/CodeCoverage.cmake @@ -71,7 +71,7 @@ find_program( GCOV_PATH gcov ) find_program( LCOV_PATH lcov ) find_program( GENHTML_PATH genhtml ) -find_program( GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/tests) +find_program( GCOVR_PATH gcovr PATHS ${UHD_SOURCE_DIR}/tests) if(NOT GCOV_PATH) message(FATAL_ERROR "gcov not found! Aborting...") @@ -130,7 +130,7 @@ function(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname) message(FATAL_ERROR "genhtml not found! Aborting...") endif() # NOT GENHTML_PATH - set(coverage_info "${CMAKE_BINARY_DIR}/${_outputname}.info") + set(coverage_info "${UHD_BINARY_DIR}/${_outputname}.info") set(coverage_cleaned "${coverage_info}.cleaned") separate_arguments(test_command UNIX_COMMAND "${_testrunner}") @@ -150,7 +150,7 @@ function(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname) COMMAND ${GENHTML_PATH} -o ${_outputname} ${coverage_cleaned} COMMAND ${CMAKE_COMMAND} -E remove ${coverage_info} ${coverage_cleaned} - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + WORKING_DIRECTORY ${UHD_BINARY_DIR} COMMENT "Resetting code coverage counters to zero.\nProcessing code coverage counters and generating report." ) @@ -183,8 +183,8 @@ function(SETUP_TARGET_FOR_COVERAGE_COBERTURA _targetname _testrunner _outputname ${_testrunner} ${ARGV3} # Running gcovr - COMMAND ${GCOVR_PATH} -x -r ${CMAKE_SOURCE_DIR} -e '${CMAKE_SOURCE_DIR}/tests/' -o ${_outputname}.xml - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + COMMAND ${GCOVR_PATH} -x -r ${UHD_SOURCE_DIR} -e '${UHD_SOURCE_DIR}/tests/' -o ${_outputname}.xml + WORKING_DIRECTORY ${UHD_BINARY_DIR} COMMENT "Running gcovr to produce Cobertura code coverage report." ) -- cgit v1.2.3