diff options
Diffstat (limited to 'host/cmake')
-rw-r--r-- | host/cmake/Modules/FindUSB1.cmake | 15 | ||||
-rw-r--r-- | host/cmake/Modules/UHDPackage.cmake | 9 | ||||
-rw-r--r-- | host/cmake/Modules/UHDUnitTest.cmake | 110 | ||||
-rwxr-xr-x | host/cmake/debian/postinst.in | 4 | ||||
-rwxr-xr-x | host/cmake/redhat/post_install.in | 4 |
5 files changed, 131 insertions, 11 deletions
diff --git a/host/cmake/Modules/FindUSB1.cmake b/host/cmake/Modules/FindUSB1.cmake index 8bfc2f975..626d06cc1 100644 --- a/host/cmake/Modules/FindUSB1.cmake +++ b/host/cmake/Modules/FindUSB1.cmake @@ -32,7 +32,20 @@ FIND_LIBRARY(LIBUSB_LIBRARIES PATHS /usr/local/lib /usr/lib /opt/local/lib ) +enable_language(C) #needs C support for check below +include(CheckFunctionExists) +if(LIBUSB_INCLUDE_DIRS) + set(CMAKE_REQUIRED_INCLUDES ${LIBUSB_INCLUDE_DIRS}) +endif() +if(LIBUSB_LIBRARIES) + set(CMAKE_REQUIRED_LIBRARIES ${LIBUSB_LIBRARIES}) +endif() +CHECK_FUNCTION_EXISTS("libusb_handle_events_timeout_completed" HAVE_LIBUSB_HANDLE_EVENTS_TIMEOUT_COMPLETED) + +if(HAVE_LIBUSB_HANDLE_EVENTS_TIMEOUT_COMPLETED) + list(APPEND LIBUSB_DEFINITIONS "HAVE_LIBUSB_HANDLE_EVENTS_TIMEOUT_COMPLETED=1") +endif(HAVE_LIBUSB_HANDLE_EVENTS_TIMEOUT_COMPLETED) + include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBUSB DEFAULT_MSG LIBUSB_LIBRARIES LIBUSB_INCLUDE_DIRS) MARK_AS_ADVANCED(LIBUSB_INCLUDE_DIRS LIBUSB_LIBRARIES) - diff --git a/host/cmake/Modules/UHDPackage.cmake b/host/cmake/Modules/UHDPackage.cmake index a535241a7..ae11c5042 100644 --- a/host/cmake/Modules/UHDPackage.cmake +++ b/host/cmake/Modules/UHDPackage.cmake @@ -109,7 +109,6 @@ SET(CPACK_COMPONENT_LIBRARIES_GROUP "Development") SET(CPACK_COMPONENT_HEADERS_GROUP "Development") SET(CPACK_COMPONENT_UTILITIES_GROUP "Runtime") SET(CPACK_COMPONENT_EXAMPLES_GROUP "Runtime") -SET(CPACK_COMPONENT_TESTS_GROUP "Runtime") SET(CPACK_COMPONENT_MANUAL_GROUP "Documentation") SET(CPACK_COMPONENT_DOXYGEN_GROUP "Documentation") SET(CPACK_COMPONENT_README_GROUP "Documentation") @@ -118,7 +117,6 @@ SET(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries") SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ Headers") SET(CPACK_COMPONENT_UTILITIES_DISPLAY_NAME "Utilities") SET(CPACK_COMPONENT_EXAMPLES_DISPLAY_NAME "Examples") -SET(CPACK_COMPONENT_TESTS_DISPLAY_NAME "Unit Tests") SET(CPACK_COMPONENT_MANUAL_DISPLAY_NAME "Manual") SET(CPACK_COMPONENT_DOXYGEN_DISPLAY_NAME "Doxygen") SET(CPACK_COMPONENT_README_DISPLAY_NAME "Readme") @@ -128,7 +126,6 @@ SET(CPACK_COMPONENT_LIBRARIES_DESCRIPTION "Dynamic link library") SET(CPACK_COMPONENT_HEADERS_DESCRIPTION "C++ development headers") SET(CPACK_COMPONENT_UTILITIES_DESCRIPTION "Utility executables and python scripts") SET(CPACK_COMPONENT_EXAMPLES_DESCRIPTION "Example executables") -SET(CPACK_COMPONENT_TESTS_DESCRIPTION "Unit test executables") SET(CPACK_COMPONENT_MANUAL_DESCRIPTION "Manual/application notes (rst and html)") SET(CPACK_COMPONENT_DOXYGEN_DESCRIPTION "API documentation (html)") SET(CPACK_COMPONENT_README_DESCRIPTION "Readme files (txt)") @@ -140,7 +137,7 @@ SET(CPACK_COMPONENT_UTILITIES_DEPENDS libraries) SET(CPACK_COMPONENT_EXAMPLES_DEPENDS libraries) SET(CPACK_COMPONENT_TESTS_DEPENDS libraries) -SET(CPACK_COMPONENTS_ALL libraries headers utilities examples tests manual doxygen readme images) +SET(CPACK_COMPONENTS_ALL libraries headers utilities examples manual doxygen readme images) ######################################################################## # Setup CPack Debian @@ -179,11 +176,11 @@ SET(CPACK_NSIS_MODIFY_PATH ON) SET(HLKM_ENV "\\\"SYSTEM\\\\CurrentControlSet\\\\Control\\\\Session Manager\\\\Environment\\\"") SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS " - WriteRegStr HKLM ${HLKM_ENV} \\\"UHD_PKG_DATA_PATH\\\" \\\"$INSTDIR\\\\share\\\\uhd\\\" + WriteRegStr HKLM ${HLKM_ENV} \\\"UHD_PKG_PATH\\\" \\\"$INSTDIR\\\" ") SET(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS " - DeleteRegValue HKLM ${HLKM_ENV} \\\"UHD_PKG_DATA_PATH\\\" + DeleteRegValue HKLM ${HLKM_ENV} \\\"UHD_PKG_PATH\\\" ") ######################################################################## diff --git a/host/cmake/Modules/UHDUnitTest.cmake b/host/cmake/Modules/UHDUnitTest.cmake new file mode 100644 index 000000000..47cddc521 --- /dev/null +++ b/host/cmake/Modules/UHDUnitTest.cmake @@ -0,0 +1,110 @@ +# +# Copyright 2010-2012 Ettus Research LLC +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +######################################################################## +# Add a unit test and setup the environment for a unit test. +# Takes the same arguments as the ADD_TEST function. +# +# Before calling set the following variables: +# UHD_TEST_TARGET_DEPS - built targets for the library path +# UHD_TEST_LIBRARY_DIRS - directories for the library path +######################################################################## +function(UHD_ADD_TEST test_name) + + #Ensure that the build exe also appears in the PATH. + list(APPEND UHD_TEST_TARGET_DEPS ${ARGN}) + + #In the land of windows, all libraries must be in the PATH. + #Since the dependent libraries are not yet installed, + #we must manually set them in the PATH to run tests. + #The following appends the path of a target dependency. + foreach(target ${UHD_TEST_TARGET_DEPS}) + get_target_property(location ${target} LOCATION) + if(location) + get_filename_component(path ${location} PATH) + string(REGEX REPLACE "\\$\\(.*\\)" ${CMAKE_BUILD_TYPE} path ${path}) + list(APPEND UHD_TEST_LIBRARY_DIRS ${path}) + endif(location) + endforeach(target) + + file(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR} srcdir) + file(TO_NATIVE_PATH "${UHD_TEST_LIBRARY_DIRS}" libpath) #ok to use on dir list? + + #http://www.cmake.org/pipermail/cmake/2009-May/029464.html + #Replaced this add test + set environs code with the shell script generation. + #Its nicer to be able to manually run the shell script to diagnose problems. + #ADD_TEST(${ARGV}) + #SET_TESTS_PROPERTIES(${test_name} PROPERTIES ENVIRONMENT "${environs}") + + if(UNIX) + set(LD_PATH_VAR "LD_LIBRARY_PATH") + if(APPLE) + set(LD_PATH_VAR "DYLD_LIBRARY_PATH") + endif() + + set(binpath "${CMAKE_CURRENT_BINARY_DIR}:$PATH") + list(APPEND libpath "$${LD_PATH_VAR}") + + #replace list separator with the path separator + string(REPLACE ";" ":" libpath "${libpath}") + list(APPEND environs "PATH=${binpath}" "${LD_PATH_VAR}=${libpath}") + + #generate a bat file that sets the environment and runs the test + find_program(SHELL sh) + set(sh_file ${CMAKE_CURRENT_BINARY_DIR}/${test_name}_test.sh) + file(WRITE ${sh_file} "#!${SHELL}\n") + #each line sets an environment variable + foreach(environ ${environs}) + file(APPEND ${sh_file} "export ${environ}\n") + endforeach(environ) + #load the command to run with its arguments + foreach(arg ${ARGN}) + file(APPEND ${sh_file} "${arg} ") + endforeach(arg) + file(APPEND ${sh_file} "\n") + + #make the shell file executable + execute_process(COMMAND chmod +x ${sh_file}) + + add_test(${test_name} ${SHELL} ${sh_file}) + + endif(UNIX) + + if(WIN32) + list(APPEND libpath ${DLL_PATHS} "%PATH%") + + #replace list separator with the path separator (escaped) + string(REPLACE ";" "\\;" libpath "${libpath}") + list(APPEND environs "PATH=${libpath}") + + #generate a bat file that sets the environment and runs the test + set(bat_file ${CMAKE_CURRENT_BINARY_DIR}/${test_name}_test.bat) + file(WRITE ${bat_file} "@echo off\n") + #each line sets an environment variable + foreach(environ ${environs}) + file(APPEND ${bat_file} "SET ${environ}\n") + endforeach(environ) + #load the command to run with its arguments + foreach(arg ${ARGN}) + file(APPEND ${bat_file} "${arg} ") + endforeach(arg) + file(APPEND ${bat_file} "\n") + + add_test(${test_name} ${bat_file}) + endif(WIN32) + +endfunction(UHD_ADD_TEST) diff --git a/host/cmake/debian/postinst.in b/host/cmake/debian/postinst.in index eaca15394..bc27c46f0 100755 --- a/host/cmake/debian/postinst.in +++ b/host/cmake/debian/postinst.in @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright 2011 Ettus Research LLC +# Copyright 2011,2013 Ettus Research LLC # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -17,7 +17,7 @@ # if [ "$1" = "configure" ]; then - cp @CMAKE_INSTALL_PREFIX@/share/uhd/utils/uhd-usrp.rules /etc/udev/rules.d/uhd-usrp.rules + cp @CMAKE_INSTALL_PREFIX@/lib/uhd/utils/uhd-usrp.rules /etc/udev/rules.d/uhd-usrp.rules udevadm control --reload-rules ldconfig fi diff --git a/host/cmake/redhat/post_install.in b/host/cmake/redhat/post_install.in index 01fd3338f..25864e0ec 100755 --- a/host/cmake/redhat/post_install.in +++ b/host/cmake/redhat/post_install.in @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright 2011 Ettus Research LLC +# Copyright 2011,2013 Ettus Research LLC # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,6 +16,6 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # -cp @CMAKE_INSTALL_PREFIX@/share/uhd/utils/uhd-usrp.rules /etc/udev/rules.d/uhd-usrp.rules +cp @CMAKE_INSTALL_PREFIX@/lib/uhd/utils/uhd-usrp.rules /etc/udev/rules.d/uhd-usrp.rules udevadm control --reload-rules ldconfig |