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/lib/CMakeLists.txt | 4 ++-- host/lib/cal/CMakeLists.txt | 2 +- host/lib/transport/nirio/lvbitx/CMakeLists.txt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'host/lib') diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt index 910fe3c70..fd316221c 100644 --- a/host/lib/CMakeLists.txt +++ b/host/lib/CMakeLists.txt @@ -152,7 +152,7 @@ if(MSVC) if(IS_ABSOLUTE "${CUSTOM_RC_FILE}") set(UHD_RC_IN "${CUSTOM_RC_FILE}") else() - set(UHD_RC_IN "${CMAKE_BINARY_DIR}/${CUSTOM_RC_FILE}") + set(UHD_RC_IN "${UHD_BINARY_DIR}/${CUSTOM_RC_FILE}") endif(IS_ABSOLUTE "${CUSTOM_RC_FILE}") message(STATUS "") message(STATUS "Using custom RC template: ${UHD_RC_IN}") @@ -193,7 +193,7 @@ if(ENABLE_SIM) # Get python include dirs include_directories(${PYTHON_INCLUDE_DIRS}) set(PYBIND11_INCLUDE_DIR - "${CMAKE_SOURCE_DIR}/lib/deps/pybind11/include" + "${UHD_SOURCE_DIR}/lib/deps/pybind11/include" CACHE STRING "Location of PyBind11 includes" diff --git a/host/lib/cal/CMakeLists.txt b/host/lib/cal/CMakeLists.txt index da6bdf1a2..a39aac06c 100644 --- a/host/lib/cal/CMakeLists.txt +++ b/host/lib/cal/CMakeLists.txt @@ -7,7 +7,7 @@ ######################################################################## # This file included, use CMake directory variables ######################################################################## -include_directories(${CMAKE_SOURCE_DIR}/lib/deps/flatbuffers/include) +include_directories(${UHD_SOURCE_DIR}/lib/deps/flatbuffers/include) LIBUHD_APPEND_SOURCES( ${CMAKE_CURRENT_SOURCE_DIR}/database.cpp ${CMAKE_CURRENT_SOURCE_DIR}/iq_cal.cpp diff --git a/host/lib/transport/nirio/lvbitx/CMakeLists.txt b/host/lib/transport/nirio/lvbitx/CMakeLists.txt index a68bef6fe..ea55409c9 100644 --- a/host/lib/transport/nirio/lvbitx/CMakeLists.txt +++ b/host/lib/transport/nirio/lvbitx/CMakeLists.txt @@ -12,7 +12,7 @@ macro(LIBUHD_LVBITX_GEN_SOURCE_AND_BITSTREAM lvbitx binfile) set( GEN_OPTIONS ) message( STATUS " Using ${lvbitx} for codegen" ) else( ${binfile} STREQUAL "OFF" ) - set( GEN_OPTIONS --merge-bin=${CMAKE_SOURCE_DIR}/../binaries/${binfile} --output-lvbitx-path=${CMAKE_SOURCE_DIR}/../binaries ) + set( GEN_OPTIONS --merge-bin=${UHD_SOURCE_DIR}/../binaries/${binfile} --output-lvbitx-path=${UHD_SOURCE_DIR}/../binaries ) message( STATUS " Merging ${lvbitx} with ${binfile} for codegen" ) endif( ${binfile} STREQUAL "OFF" ) -- cgit v1.2.3