diff options
author | Martin Braun <martin.braun@ettus.com> | 2021-09-02 11:38:05 +0200 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2021-09-10 15:08:10 -0500 |
commit | 09d94529e5dbfa992cb6012cc0dc38d6f3e7d57d (patch) | |
tree | f632274ec4af60e1559a361bd2b607cc65e9d5f7 /host/cmake/Modules/UHDUnitTest.cmake | |
parent | e64d3e28316f642c1203722b6f5f2af710a7e281 (diff) | |
download | uhd-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/Modules/UHDUnitTest.cmake')
-rw-r--r-- | host/cmake/Modules/UHDUnitTest.cmake | 18 |
1 files changed, 9 insertions, 9 deletions
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) |