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/examples/rfnoc-example/CMakeLists.txt | 12 ++++++------ host/examples/rfnoc-example/apps/CMakeLists.txt | 2 +- host/examples/rfnoc-example/lib/CMakeLists.txt | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'host/examples') diff --git a/host/examples/rfnoc-example/CMakeLists.txt b/host/examples/rfnoc-example/CMakeLists.txt index 738b5ae8e..4bd9db678 100644 --- a/host/examples/rfnoc-example/CMakeLists.txt +++ b/host/examples/rfnoc-example/CMakeLists.txt @@ -8,7 +8,7 @@ cmake_minimum_required(VERSION 3.8) project(rfnoc-example CXX C) #make sure our local CMake Modules path comes first -#list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake/Modules) +#list(INSERT CMAKE_MODULE_PATH 0 ${UHD_SOURCE_DIR}/cmake/Modules) #install to PyBOMBS target prefix if defined #if(DEFINED ENV{PYBOMBS_PREFIX}) @@ -37,8 +37,8 @@ find_package(UnixCommands) if(BASH) message(STATUS "Found bash interpreter: ${BASH}") configure_file( - ${CMAKE_SOURCE_DIR}/cmake/Modules/run_testbench.sh.in - ${CMAKE_BINARY_DIR}/cmake/Modules/run_testbench.sh + ${UHD_SOURCE_DIR}/cmake/Modules/run_testbench.sh.in + ${UHD_BINARY_DIR}/cmake/Modules/run_testbench.sh @ONLY ) else() @@ -98,7 +98,7 @@ macro(RFNOC_ADD_TB_DIR) set(_target_name "${_tb_dir}_tb") message(STATUS "Adding testbench target: ${_target_name}") add_custom_target(${_target_name} - COMMAND ${CMAKE_BINARY_DIR}/cmake/Modules/run_testbench.sh ${UHD_FPGA_DIR} ${UHD_FPGA_DEFAULT_DEVICE} ${CMAKE_CURRENT_SOURCE_DIR} xsim + COMMAND ${UHD_BINARY_DIR}/cmake/Modules/run_testbench.sh ${UHD_FPGA_DIR} ${UHD_FPGA_DEFAULT_DEVICE} ${CMAKE_CURRENT_SOURCE_DIR} xsim ) add_dependencies(testbenches ${_target_name}) endif() @@ -138,7 +138,7 @@ macro(RFNOC_REGISTER_IMAGE_CORE) if (_rfnoc_image_builder_exe) message(STATUS "Adding image core target: ${_target_name}") add_custom_target(${_target_name} - COMMAND ${_rfnoc_image_builder_exe} -F ${UHD_FPGA_DIR} -y ${CMAKE_CURRENT_SOURCE_DIR}/${_rfnoc_image_core_SRC} -I ${CMAKE_SOURCE_DIR} + COMMAND ${_rfnoc_image_builder_exe} -F ${UHD_FPGA_DIR} -y ${CMAKE_CURRENT_SOURCE_DIR}/${_rfnoc_image_core_SRC} -I ${UHD_SOURCE_DIR} ) endif() endmacro() @@ -147,7 +147,7 @@ endmacro() # Create uninstall target ######################################################################## configure_file( - ${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in + ${UHD_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake @ONLY) add_custom_target(uninstall diff --git a/host/examples/rfnoc-example/apps/CMakeLists.txt b/host/examples/rfnoc-example/apps/CMakeLists.txt index bca9336ce..ea9dafd71 100644 --- a/host/examples/rfnoc-example/apps/CMakeLists.txt +++ b/host/examples/rfnoc-example/apps/CMakeLists.txt @@ -20,7 +20,7 @@ endif(MSVC) find_package(Boost 1.65 REQUIRED ${BOOST_REQUIRED_COMPONENTS}) include_directories( - ${CMAKE_SOURCE_DIR}/include + ${UHD_SOURCE_DIR}/include ) add_executable(init_gain_block diff --git a/host/examples/rfnoc-example/lib/CMakeLists.txt b/host/examples/rfnoc-example/lib/CMakeLists.txt index 45b5c9b03..8b447723d 100644 --- a/host/examples/rfnoc-example/lib/CMakeLists.txt +++ b/host/examples/rfnoc-example/lib/CMakeLists.txt @@ -23,10 +23,10 @@ endif() # Setup the include and linker paths ######################################################################## include_directories( - ${CMAKE_SOURCE_DIR}/lib - ${CMAKE_SOURCE_DIR}/include - ${CMAKE_BINARY_DIR}/lib - ${CMAKE_BINARY_DIR}/include + ${UHD_SOURCE_DIR}/lib + ${UHD_SOURCE_DIR}/include + ${UHD_BINARY_DIR}/lib + ${UHD_BINARY_DIR}/include ${UHD_INCLUDE_DIRS} ${Boost_INCLUDE_DIR} ) -- cgit v1.2.3