aboutsummaryrefslogtreecommitdiffstats
path: root/host/cmake
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2021-09-02 11:38:05 +0200
committerAaron Rossetto <aaron.rossetto@ni.com>2021-09-10 15:08:10 -0500
commit09d94529e5dbfa992cb6012cc0dc38d6f3e7d57d (patch)
treef632274ec4af60e1559a361bd2b607cc65e9d5f7 /host/cmake
parente64d3e28316f642c1203722b6f5f2af710a7e281 (diff)
downloaduhd-09d94529e5dbfa992cb6012cc0dc38d6f3e7d57d.tar.gz
uhd-09d94529e5dbfa992cb6012cc0dc38d6f3e7d57d.tar.bz2
uhd-09d94529e5dbfa992cb6012cc0dc38d6f3e7d57d.zip
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.
Diffstat (limited to 'host/cmake')
-rw-r--r--host/cmake/Modules/CMakeRC.cmake2
-rw-r--r--host/cmake/Modules/CodeCoverage.cmake10
-rw-r--r--host/cmake/Modules/UHDPackage.cmake24
-rw-r--r--host/cmake/Modules/UHDUnitTest.cmake18
-rw-r--r--host/cmake/Modules/UHDVersion.cmake10
5 files changed, 32 insertions, 32 deletions
diff --git a/host/cmake/Modules/CMakeRC.cmake b/host/cmake/Modules/CMakeRC.cmake
index 81a447c8e..ce6d8fbd2 100644
--- a/host/cmake/Modules/CMakeRC.cmake
+++ b/host/cmake/Modules/CMakeRC.cmake
@@ -85,7 +85,7 @@ function(_cmrc_normalize_path var)
set("${var}" "${path}" PARENT_SCOPE)
endfunction()
-get_filename_component(_inc_dir "${CMAKE_BINARY_DIR}/_cmrc/include" ABSOLUTE)
+get_filename_component(_inc_dir "${UHD_BINARY_DIR}/_cmrc/include" ABSOLUTE)
set(CMRC_INCLUDE_DIR "${_inc_dir}" CACHE INTERNAL "Directory for CMakeRC include files")
# Let's generate the primary include file
file(MAKE_DIRECTORY "${CMRC_INCLUDE_DIR}/cmrc")
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."
)
diff --git a/host/cmake/Modules/UHDPackage.cmake b/host/cmake/Modules/UHDPackage.cmake
index 4d507493b..2ccbed6e5 100644
--- a/host/cmake/Modules/UHDPackage.cmake
+++ b/host/cmake/Modules/UHDPackage.cmake
@@ -110,8 +110,8 @@ set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Ettus Research - USRP Hardware Driver")
set(CPACK_PACKAGE_VENDOR "Ettus Research (National Instruments)")
set(CPACK_PACKAGE_CONTACT "Ettus Research <support@ettus.com>")
set(CPACK_PACKAGE_VERSION "${UHD_VERSION}")
-set(CPACK_RESOURCE_FILE_WELCOME ${CMAKE_SOURCE_DIR}/README.md)
-set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE)
+set(CPACK_RESOURCE_FILE_WELCOME ${UHD_SOURCE_DIR}/README.md)
+set(CPACK_RESOURCE_FILE_LICENSE ${UHD_SOURCE_DIR}/LICENSE)
########################################################################
# Setup CPack Source
@@ -165,16 +165,16 @@ set(CPACK_COMPONENTS_ALL libraries pythonapi headers utilities examples manual d
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libboost-all-dev, python3-requests")
set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "python3, python3-tk")
foreach(filename preinst postinst prerm postrm)
- list(APPEND CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA ${CMAKE_BINARY_DIR}/debian/${filename})
- file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/debian)
+ list(APPEND CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA ${UHD_BINARY_DIR}/debian/${filename})
+ file(MAKE_DIRECTORY ${UHD_BINARY_DIR}/debian)
configure_file(
- ${CMAKE_SOURCE_DIR}/cmake/debian/${filename}.in
- ${CMAKE_BINARY_DIR}/debian/${filename}
+ ${UHD_SOURCE_DIR}/cmake/debian/${filename}.in
+ ${UHD_BINARY_DIR}/debian/${filename}
@ONLY)
endforeach(filename)
configure_file(
- ${CMAKE_SOURCE_DIR}/cmake/debian/watch
- ${CMAKE_BINARY_DIR}/debian/watch
+ ${UHD_SOURCE_DIR}/cmake/debian/watch
+ ${UHD_BINARY_DIR}/debian/watch
@ONLY)
########################################################################
@@ -185,11 +185,11 @@ set(CPACK_RPM_PACKAGE_REQUIRES "boost-devel, python3-requests")
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/share/man;/usr/share/man/man1;/usr/lib64/pkgconfig;/usr/lib64/cmake;/usr/lib64/python2.7;/usr/lib64/python2.7/site-packages")
foreach(filename post_install post_uninstall pre_install pre_uninstall)
string(TOUPPER ${filename} filename_upper)
- list(APPEND CPACK_RPM_${filename_upper}_SCRIPT_FILE ${CMAKE_BINARY_DIR}/redhat/${filename})
- file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/redhat)
+ list(APPEND CPACK_RPM_${filename_upper}_SCRIPT_FILE ${UHD_BINARY_DIR}/redhat/${filename})
+ file(MAKE_DIRECTORY ${UHD_BINARY_DIR}/redhat)
configure_file(
- ${CMAKE_SOURCE_DIR}/cmake/redhat/${filename}.in
- ${CMAKE_BINARY_DIR}/redhat/${filename}
+ ${UHD_SOURCE_DIR}/cmake/redhat/${filename}.in
+ ${UHD_BINARY_DIR}/redhat/${filename}
@ONLY)
endforeach(filename)
diff --git a/host/cmake/Modules/UHDUnitTest.cmake b/host/cmake/Modules/UHDUnitTest.cmake
index 4e6651fd9..d8933dd0e 100644
--- a/host/cmake/Modules/UHDUnitTest.cmake
+++ b/host/cmake/Modules/UHDUnitTest.cmake
@@ -20,13 +20,13 @@ function(UHD_ADD_TEST test_name)
#directory itself.
if(WIN32)
set(UHD_TEST_LIBRARY_DIRS
- "${CMAKE_BINARY_DIR}/lib/${CMAKE_BUILD_TYPE}"
+ "${UHD_BINARY_DIR}/lib/${CMAKE_BUILD_TYPE}"
"${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}"
"${Boost_LIBRARY_DIRS}"
)
else()
set(UHD_TEST_LIBRARY_DIRS
- "${CMAKE_BINARY_DIR}/lib"
+ "${UHD_BINARY_DIR}/lib"
"${CMAKE_CURRENT_BINARY_DIR}"
)
if(NOT APPLE)
@@ -56,7 +56,7 @@ function(UHD_ADD_TEST test_name)
#replace list separator with the path separator
string(REPLACE ";" ":" libpath "${libpath}")
- list(APPEND environs "PATH=\"${binpath}\"" "${LD_PATH_VAR}=\"${libpath}\"" "UHD_RFNOC_DIR=\"${CMAKE_SOURCE_DIR}/include/uhd/rfnoc\"")
+ list(APPEND environs "PATH=\"${binpath}\"" "${LD_PATH_VAR}=\"${libpath}\"" "UHD_RFNOC_DIR=\"${UHD_SOURCE_DIR}/include/uhd/rfnoc\"")
#generate a bat file that sets the environment and runs the test
if (CMAKE_CROSSCOMPILING)
@@ -88,7 +88,7 @@ function(UHD_ADD_TEST test_name)
#replace list separator with the path separator (escaped)
string(REPLACE ";" "\\;" libpath "${libpath}")
- list(APPEND environs "PATH=${libpath}" "UHD_RFNOC_DIR=${CMAKE_SOURCE_DIR}/include/uhd/rfnoc")
+ list(APPEND environs "PATH=${libpath}" "UHD_RFNOC_DIR=${UHD_SOURCE_DIR}/include/uhd/rfnoc")
#generate a bat file that sets the environment and runs the test
set(bat_file ${CMAKE_CURRENT_BINARY_DIR}/${test_name}_test.bat)
@@ -120,25 +120,25 @@ function(UHD_ADD_PYTEST test_name)
-m unittest discover
-s ${CMAKE_CURRENT_SOURCE_DIR}
-p "${test_name}.*"
- WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/python"
+ WORKING_DIRECTORY "${UHD_BINARY_DIR}/python"
)
else()
add_test(NAME ${test_name}
COMMAND ${RUNTIME_PYTHON_EXECUTABLE} -m unittest discover
-s ${CMAKE_CURRENT_SOURCE_DIR}
-p "${test_name}.*"
- WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/python"
+ WORKING_DIRECTORY "${UHD_BINARY_DIR}/python"
)
endif(ENABLE_QEMU_UNITTESTS)
- # Include ${CMAKE_BINARY_DIR}/utils/ for testing the python utils
+ # Include ${UHD_BINARY_DIR}/utils/ for testing the python utils
if(APPLE)
set_tests_properties(${test_name} PROPERTIES
ENVIRONMENT
- "DYLD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib/;PYTHONPATH=${UHD_BINARY_DIR}/python:${CMAKE_SOURCE_DIR}/tests/common:${CMAKE_BINARY_DIR}/utils/")
+ "DYLD_LIBRARY_PATH=${UHD_BINARY_DIR}/lib/;PYTHONPATH=${UHD_BINARY_DIR}/python:${UHD_SOURCE_DIR}/tests/common:${UHD_BINARY_DIR}/utils/")
else()
set_tests_properties(${test_name} PROPERTIES
ENVIRONMENT
- "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib/;PYTHONPATH=${UHD_BINARY_DIR}/python:${CMAKE_SOURCE_DIR}/tests/common:${CMAKE_BINARY_DIR}/utils/"
+ "LD_LIBRARY_PATH=${UHD_BINARY_DIR}/lib/;PYTHONPATH=${UHD_BINARY_DIR}/python:${UHD_SOURCE_DIR}/tests/common:${UHD_BINARY_DIR}/utils/"
)
endif()
endfunction(UHD_ADD_PYTEST)
diff --git a/host/cmake/Modules/UHDVersion.cmake b/host/cmake/Modules/UHDVersion.cmake
index 3a39a40cf..eff705571 100644
--- a/host/cmake/Modules/UHDVersion.cmake
+++ b/host/cmake/Modules/UHDVersion.cmake
@@ -38,7 +38,7 @@ endif(NOT DEFINED UHD_VERSION_DEVEL)
set(UHD_GIT_BRANCH "")
if(GIT_FOUND)
execute_process(
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ WORKING_DIRECTORY ${UHD_SOURCE_DIR}
COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
OUTPUT_VARIABLE _git_branch OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE _git_branch_result
@@ -77,7 +77,7 @@ endif(DEFINED UHD_GIT_BRANCH_OVERRIDE)
#grab the git ref id for the current head
execute_process(
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ WORKING_DIRECTORY ${UHD_SOURCE_DIR}
COMMAND ${GIT_EXECUTABLE} describe --always --abbrev=8 --long
OUTPUT_VARIABLE _git_describe OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE _git_describe_result
@@ -87,7 +87,7 @@ execute_process(
if(_git_describe_result EQUAL 0)
if(NOT UHD_GIT_COUNT)
execute_process(
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ WORKING_DIRECTORY ${UHD_SOURCE_DIR}
COMMAND ${PYTHON_EXECUTABLE} -c "
try:
print('${_git_describe}'.split('-')[-2])
@@ -99,7 +99,7 @@ except IndexError:
endif()
if(NOT UHD_GIT_HASH)
execute_process(
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ WORKING_DIRECTORY ${UHD_SOURCE_DIR}
COMMAND ${PYTHON_EXECUTABLE} -c "
try:
print('${_git_describe}'.split('-')[-1])
@@ -125,7 +125,7 @@ if(UHD_RELEASE_MODE)
#Ignore UHD_GIT_COUNT in UHD_VERSION if the string 'release' is in UHD_RELEASE_MODE
execute_process(
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ WORKING_DIRECTORY ${UHD_SOURCE_DIR}
COMMAND ${PYTHON_EXECUTABLE} -c "print ('release' in '${UHD_RELEASE_MODE}') or ('rc' in '${UHD_RELEASE_MODE}')"
OUTPUT_VARIABLE TRIM_UHD_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE
)