aboutsummaryrefslogtreecommitdiffstats
path: root/host/cmake/Modules/UHDVersion.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/Modules/UHDVersion.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/Modules/UHDVersion.cmake')
-rw-r--r--host/cmake/Modules/UHDVersion.cmake10
1 files changed, 5 insertions, 5 deletions
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
)