diff options
author | Josh Blum <josh@joshknows.com> | 2010-12-27 14:10:27 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-12-27 14:10:27 -0800 |
commit | 8dffb7d5a6f3ff0390ca01dcd15200689b874b30 (patch) | |
tree | d01db9ff7c0bc4d87aea4af6d6b424db48a1a212 /host/Modules | |
parent | 3017907fd83d32e89e91f43a5d2b94d4155beddd (diff) | |
download | uhd-8dffb7d5a6f3ff0390ca01dcd15200689b874b30.tar.gz uhd-8dffb7d5a6f3ff0390ca01dcd15200689b874b30.tar.bz2 uhd-8dffb7d5a6f3ff0390ca01dcd15200689b874b30.zip |
cmake: moved module files into modules directory, set modules path
Diffstat (limited to 'host/Modules')
-rw-r--r-- | host/Modules/FindUSB1.cmake | 38 | ||||
-rw-r--r-- | host/Modules/UHDComponent.cmake | 86 | ||||
-rw-r--r-- | host/Modules/UHDPackage.cmake | 44 | ||||
-rw-r--r-- | host/Modules/UHDPython.cmake | 69 | ||||
-rw-r--r-- | host/Modules/UHDVersion.cmake | 68 |
5 files changed, 305 insertions, 0 deletions
diff --git a/host/Modules/FindUSB1.cmake b/host/Modules/FindUSB1.cmake new file mode 100644 index 000000000..ebcac99eb --- /dev/null +++ b/host/Modules/FindUSB1.cmake @@ -0,0 +1,38 @@ +# - Try to find the freetype library +# Once done this defines +# +# LIBUSB_FOUND - system has libusb +# LIBUSB_INCLUDE_DIR - the libusb include directory +# LIBUSB_LIBRARIES - Link these to use libusb + +# Copyright (c) 2006, 2008 Laurent Montel, <montel@kde.org> +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + + +if (LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES) + + # in cache already + set(LIBUSB_FOUND TRUE) + +else (LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES) + IF (NOT WIN32) + # use pkg-config to get the directories and then use these values + # in the FIND_PATH() and FIND_LIBRARY() calls + find_package(PkgConfig) + pkg_check_modules(PC_LIBUSB libusb-1.0) + ENDIF(NOT WIN32) + + FIND_PATH(LIBUSB_INCLUDE_DIR libusb.h + PATHS ${PC_LIBUSB_INCLUDEDIR} ${PC_LIBUSB_INCLUDE_DIRS}) + + FIND_LIBRARY(LIBUSB_LIBRARIES NAMES usb-1.0 + PATHS ${PC_LIBUSB_LIBDIR} ${PC_LIBUSB_LIBRARY_DIRS}) + + include(FindPackageHandleStandardArgs) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBUSB DEFAULT_MSG LIBUSB_LIBRARIES LIBUSB_INCLUDE_DIR) + + MARK_AS_ADVANCED(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARIES) + +endif (LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES) diff --git a/host/Modules/UHDComponent.cmake b/host/Modules/UHDComponent.cmake new file mode 100644 index 000000000..0263b071f --- /dev/null +++ b/host/Modules/UHDComponent.cmake @@ -0,0 +1,86 @@ +# +# Copyright 2010 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/>. +# + +######################################################################## +SET(_uhd_enabled_components "" CACHE INTERNAL "" FORCE) +SET(_uhd_disabled_components "" CACHE INTERNAL "" FORCE) + +######################################################################## +# Register a component into the system +# - name the component string name +# - var the global enable variable +# - enb the default enable setting +# - deps a list of dependencies +# - dis the default disable setting +######################################################################## +FUNCTION(LIBUHD_REGISTER_COMPONENT name var enb deps dis) + INCLUDE(CMakeDependentOption) + MESSAGE(STATUS "") + MESSAGE(STATUS "Configuring ${name} support...") + IF(DEFINED ${var}) + MESSAGE(STATUS "${name} support configured ${var}=${${var}}") + ELSE(DEFINED ${var}) #not defined: automatic enabling of component + MESSAGE(STATUS "${name} support configured automatically") + ENDIF(DEFINED ${var}) + + #setup the dependent option for this component + CMAKE_DEPENDENT_OPTION(${var} "enable ${name} support" ${enb} "${deps}" ${dis}) + + #remove previous occurrence of component in either list + IF(DEFINED _uhd_enabled_components) + LIST(REMOVE_ITEM _uhd_enabled_components ${name}) + ENDIF(DEFINED _uhd_enabled_components) + IF(DEFINED _uhd_disabled_components) + LIST(REMOVE_ITEM _uhd_disabled_components ${name}) + ENDIF(DEFINED _uhd_disabled_components) + + #append the component into one of the lists + IF(${var}) + MESSAGE(STATUS " Enabling ${name} support.") + LIST(APPEND _uhd_enabled_components ${name}) + ELSE(${var}) + MESSAGE(STATUS " Disabling ${name} support.") + LIST(APPEND _uhd_disabled_components ${name}) + ENDIF(${var}) + + #make components lists into global variables + SET(_uhd_enabled_components ${_uhd_enabled_components} CACHE INTERNAL "" FORCE) + SET(_uhd_disabled_components ${_uhd_disabled_components} CACHE INTERNAL "" FORCE) +ENDFUNCTION(LIBUHD_REGISTER_COMPONENT) + +######################################################################## +# Print the registered component summary +######################################################################## +FUNCTION(UHD_PRINT_COMPONENT_SUMMARY) + MESSAGE(STATUS "") + MESSAGE(STATUS "######################################################") + MESSAGE(STATUS "# LibUHD enabled components ") + MESSAGE(STATUS "######################################################") + FOREACH(comp ${_uhd_enabled_components}) + MESSAGE(STATUS " * ${comp}") + ENDFOREACH(comp) + + MESSAGE(STATUS "") + MESSAGE(STATUS "######################################################") + MESSAGE(STATUS "# LibUHD disabled components ") + MESSAGE(STATUS "######################################################") + FOREACH(comp ${_uhd_disabled_components}) + MESSAGE(STATUS " * ${comp}") + ENDFOREACH(comp) + + MESSAGE(STATUS "") +ENDFUNCTION(UHD_PRINT_COMPONENT_SUMMARY) diff --git a/host/Modules/UHDPackage.cmake b/host/Modules/UHDPackage.cmake new file mode 100644 index 000000000..2a11d407b --- /dev/null +++ b/host/Modules/UHDPackage.cmake @@ -0,0 +1,44 @@ +# +# Copyright 2010 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/>. +# + +######################################################################## +INCLUDE(UHDVersion) #sets version information + +######################################################################## +# Setup CPack +######################################################################## +SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Ettus Research - Universal Hardware Driver") +SET(CPACK_PACKAGE_VENDOR "Ettus Research LLC") +SET(CPACK_PACKAGE_CONTACT "support@ettus.com") +SET(CPACK_PACKAGE_VERSION_MAJOR ${UHD_VERSION_MAJOR}) +SET(CPACK_PACKAGE_VERSION_MINOR ${UHD_VERSION_MINOR}) +SET(CPACK_PACKAGE_VERSION_PATCH ${UHD_VERSION_PATCH}) +SET(CPACK_RESOURCE_FILE_README ${CMAKE_SOURCE_DIR}/README) +SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE) +SET(BOOST_MIN_VERSION 1.36) #used in setup for boost +STRING(REPLACE "," ", " CPACK_DEBIAN_PACKAGE_DEPENDS + "libboost-date-time-dev (>= ${BOOST_MIN_VERSION})," + "libboost-filesystem-dev (>= ${BOOST_MIN_VERSION})," + "libboost-program-options-dev (>= ${BOOST_MIN_VERSION})," + "libboost-regex-dev (>= ${BOOST_MIN_VERSION})," + "libboost-system-dev (>= ${BOOST_MIN_VERSION})," + "libboost-test-dev (>= ${BOOST_MIN_VERSION})," + "libboost-thread-dev (>= ${BOOST_MIN_VERSION})" +) +SET(CPACK_DEBIAN_PACKAGE_RECOMMENDS "python, python-tk") +SET(CPACK_RPM_PACKAGE_REQUIRES "boost-devel >= ${BOOST_MIN_VERSION}") +INCLUDE(CPack) #include after setting vars diff --git a/host/Modules/UHDPython.cmake b/host/Modules/UHDPython.cmake new file mode 100644 index 000000000..49f74ae88 --- /dev/null +++ b/host/Modules/UHDPython.cmake @@ -0,0 +1,69 @@ +# +# Copyright 2010 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/>. +# + +######################################################################## +# Setup Python +######################################################################## +#this allows the user to override PYTHON_EXECUTABLE +IF(PYTHON_EXECUTABLE) + + SET(PYTHONINTERP_FOUND TRUE) + +#otherwise if not set, try to automatically find it +ELSE(PYTHON_EXECUTABLE) + + #use the built-in find script + FIND_PACKAGE(PythonInterp) + + #and if that fails use the find program routine + IF(NOT PYTHONINTERP_FOUND) + FIND_PROGRAM(PYTHON_EXECUTABLE python) + IF(PYTHON_EXECUTABLE) + SET(PYTHONINTERP_FOUND TRUE) + ENDIF(PYTHON_EXECUTABLE) + ENDIF(NOT PYTHONINTERP_FOUND) + +ENDIF(PYTHON_EXECUTABLE) + +#make the path to the executable appear in the cmake gui +SET(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE PYTHON_EXECUTABLE "python interpreter") + +IF(NOT PYTHONINTERP_FOUND) + MESSAGE(FATAL_ERROR "Error: Python interpretor required by the build system.") +ENDIF(NOT PYTHONINTERP_FOUND) + +MACRO(PYTHON_CHECK_MODULE desc mod cmd have) + MESSAGE(STATUS "") + MESSAGE(STATUS "Python checking for ${desc}") + EXECUTE_PROCESS( + COMMAND ${PYTHON_EXECUTABLE} -c " +######################################### +try: import ${mod} +except: exit(-1) +try: assert ${cmd} +except: exit(-1) +#########################################" + RESULT_VARIABLE ${have} + ) + IF(${have} EQUAL 0) + MESSAGE(STATUS "Python checking for ${desc} - found") + SET(${have} TRUE) + ELSE(${have} EQUAL 0) + MESSAGE(STATUS "Python checking for ${desc} - not found") + SET(${have} FALSE) + ENDIF(${have} EQUAL 0) +ENDMACRO(PYTHON_CHECK_MODULE) diff --git a/host/Modules/UHDVersion.cmake b/host/Modules/UHDVersion.cmake new file mode 100644 index 000000000..fc2e2bbbd --- /dev/null +++ b/host/Modules/UHDVersion.cmake @@ -0,0 +1,68 @@ +# +# Copyright 2010 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/>. +# + +######################################################################## +INCLUDE(UHDPython) #requires python for parsing + +######################################################################## +# Setup Version Numbers +######################################################################## +SET(UHD_VERSION_MAJOR 0001) #API compatibility number +SET(UHD_VERSION_MINOR 0) #Timestamp of git commit +SET(UHD_VERSION_PATCH 0) #Short hash of git commit + +######################################################################## +# Find GIT to get repo information +######################################################################## +MESSAGE(STATUS "") +MESSAGE(STATUS "Checking for git") +FIND_PROGRAM(GIT git) +IF(GIT) + MESSAGE(STATUS "Checking for git - found") + + #grab the git log entry for the current head + EXECUTE_PROCESS( + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMAND ${GIT} log HEAD~..HEAD --date=raw + OUTPUT_VARIABLE _git_log OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + #extract the timestamp from the git log entry + EXECUTE_PROCESS( + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMAND ${PYTHON_EXECUTABLE} -c "import re; print re.match('^.*Date:\\s*(\\d*).*$', ''' ${_git_log} ''', re.MULTILINE | re.DOTALL).groups()[0]" + OUTPUT_VARIABLE _git_timestamp OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + #format the timestamp into YYYY-MM-DD-HH-MM-SS + EXECUTE_PROCESS( + COMMAND ${PYTHON_EXECUTABLE} -c "import time; print time.strftime('%Y%m%d%H%M%S', time.gmtime(${_git_timestamp}))" + OUTPUT_VARIABLE _git_date OUTPUT_STRIP_TRAILING_WHITESPACE + ) + SET(UHD_VERSION_MINOR ${_git_date}) + + #grab the git ref id for the current head + EXECUTE_PROCESS( + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMAND ${GIT} rev-parse --short HEAD + OUTPUT_VARIABLE _git_rev OUTPUT_STRIP_TRAILING_WHITESPACE + ) + SET(UHD_VERSION_PATCH ${_git_rev}) + +ELSE(GIT) + MESSAGE(STATUS "Checking for git - not found") +ENDIF(GIT) |