diff options
Diffstat (limited to 'host/cmake')
-rw-r--r-- | host/cmake/Modules/CMakeParseArgumentsCopy.cmake | 138 | ||||
-rw-r--r-- | host/cmake/Modules/UHDComponent.cmake | 56 | ||||
-rw-r--r-- | host/cmake/Modules/UHDPackage.cmake | 40 | ||||
-rw-r--r-- | host/cmake/Modules/UHDVersion.cmake | 11 |
4 files changed, 223 insertions, 22 deletions
diff --git a/host/cmake/Modules/CMakeParseArgumentsCopy.cmake b/host/cmake/Modules/CMakeParseArgumentsCopy.cmake new file mode 100644 index 000000000..7ce4c49ae --- /dev/null +++ b/host/cmake/Modules/CMakeParseArgumentsCopy.cmake @@ -0,0 +1,138 @@ +# CMAKE_PARSE_ARGUMENTS(<prefix> <options> <one_value_keywords> <multi_value_keywords> args...) +# +# CMAKE_PARSE_ARGUMENTS() is intended to be used in macros or functions for +# parsing the arguments given to that macro or function. +# It processes the arguments and defines a set of variables which hold the +# values of the respective options. +# +# The <options> argument contains all options for the respective macro, +# i.e. keywords which can be used when calling the macro without any value +# following, like e.g. the OPTIONAL keyword of the install() command. +# +# The <one_value_keywords> argument contains all keywords for this macro +# which are followed by one value, like e.g. DESTINATION keyword of the +# install() command. +# +# The <multi_value_keywords> argument contains all keywords for this macro +# which can be followed by more than one value, like e.g. the TARGETS or +# FILES keywords of the install() command. +# +# When done, CMAKE_PARSE_ARGUMENTS() will have defined for each of the +# keywords listed in <options>, <one_value_keywords> and +# <multi_value_keywords> a variable composed of the given <prefix> +# followed by "_" and the name of the respective keyword. +# These variables will then hold the respective value from the argument list. +# For the <options> keywords this will be TRUE or FALSE. +# +# All remaining arguments are collected in a variable +# <prefix>_UNPARSED_ARGUMENTS, this can be checked afterwards to see whether +# your macro was called with unrecognized parameters. +# +# As an example here a my_install() macro, which takes similar arguments as the +# real install() command: +# +# function(MY_INSTALL) +# set(options OPTIONAL FAST) +# set(oneValueArgs DESTINATION RENAME) +# set(multiValueArgs TARGETS CONFIGURATIONS) +# cmake_parse_arguments(MY_INSTALL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) +# ... +# +# Assume my_install() has been called like this: +# my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub) +# +# After the cmake_parse_arguments() call the macro will have set the following +# variables: +# MY_INSTALL_OPTIONAL = TRUE +# MY_INSTALL_FAST = FALSE (this option was not used when calling my_install() +# MY_INSTALL_DESTINATION = "bin" +# MY_INSTALL_RENAME = "" (was not used) +# MY_INSTALL_TARGETS = "foo;bar" +# MY_INSTALL_CONFIGURATIONS = "" (was not used) +# MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (no value expected after "OPTIONAL" +# +# You can the continue and process these variables. +# +# Keywords terminate lists of values, e.g. if directly after a one_value_keyword +# another recognized keyword follows, this is interpreted as the beginning of +# the new option. +# E.g. my_install(TARGETS foo DESTINATION OPTIONAL) would result in +# MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION would +# be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefor. + +#============================================================================= +# Copyright 2010 Alexander Neundorf <neundorf@kde.org> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + + +if(__CMAKE_PARSE_ARGUMENTS_INCLUDED) + return() +endif() +set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE) + + +function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames) + # first set all result variables to empty/FALSE + foreach(arg_name ${_singleArgNames} ${_multiArgNames}) + set(${prefix}_${arg_name}) + endforeach(arg_name) + + foreach(option ${_optionNames}) + set(${prefix}_${option} FALSE) + endforeach(option) + + set(${prefix}_UNPARSED_ARGUMENTS) + + set(insideValues FALSE) + set(currentArgName) + + # now iterate over all arguments and fill the result variables + foreach(currentArg ${ARGN}) + list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword + list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword + list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword + + if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1) + if(insideValues) + if("${insideValues}" STREQUAL "SINGLE") + set(${prefix}_${currentArgName} ${currentArg}) + set(insideValues FALSE) + elseif("${insideValues}" STREQUAL "MULTI") + list(APPEND ${prefix}_${currentArgName} ${currentArg}) + endif() + else(insideValues) + list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg}) + endif(insideValues) + else() + if(NOT ${optionIndex} EQUAL -1) + set(${prefix}_${currentArg} TRUE) + set(insideValues FALSE) + elseif(NOT ${singleArgIndex} EQUAL -1) + set(currentArgName ${currentArg}) + set(${prefix}_${currentArgName}) + set(insideValues "SINGLE") + elseif(NOT ${multiArgIndex} EQUAL -1) + set(currentArgName ${currentArg}) + set(${prefix}_${currentArgName}) + set(insideValues "MULTI") + endif() + endif() + + endforeach(currentArg) + + # propagate the result variables to the caller: + foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames}) + set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE) + endforeach(arg_name) + set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE) + +endfunction(CMAKE_PARSE_ARGUMENTS _options _singleArgs _multiArgs) diff --git a/host/cmake/Modules/UHDComponent.cmake b/host/cmake/Modules/UHDComponent.cmake index 52b7450d5..a041762b2 100644 --- a/host/cmake/Modules/UHDComponent.cmake +++ b/host/cmake/Modules/UHDComponent.cmake @@ -1,5 +1,5 @@ # -# Copyright 2010-2011 Ettus Research LLC +# Copyright 2010-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 @@ -54,6 +54,60 @@ MACRO(LIBUHD_REGISTER_COMPONENT name var enb deps dis) ENDMACRO(LIBUHD_REGISTER_COMPONENT) ######################################################################## +# Install only if appropriate for package and if component is enabled +######################################################################## +FUNCTION(UHD_INSTALL) + include(CMakeParseArgumentsCopy) + CMAKE_PARSE_ARGUMENTS(UHD_INSTALL "" "DESTINATION;COMPONENT" "TARGETS;FILES;PROGRAMS" ${ARGN}) + + IF(UHD_INSTALL_FILES) + SET(TO_INSTALL "${UHD_INSTALL_FILES}") + ELSEIF(UHD_INSTALL_PROGRAMS) + SET(TO_INSTALL "${UHD_INSTALL_PROGRAMS}") + ELSEIF(UHD_INSTALL_TARGETS) + SET(TO_INSTALL "${UHD_INSTALL_TARGETS}") + ENDIF(UHD_INSTALL_FILES) + + IF(UHD_INSTALL_COMPONENT STREQUAL "headers") + IF(NOT LIBUHD_PKG AND NOT UHDHOST_PKG) + INSTALL(${ARGN}) + ENDIF(NOT LIBUHD_PKG AND NOT UHDHOST_PKG) + ELSEIF(UHD_INSTALL_COMPONENT STREQUAL "examples") + IF(NOT LIBUHD_PKG AND NOT LIBUHDDEV_PKG) + INSTALL(${ARGN}) + ENDIF(NOT LIBUHD_PKG AND NOT LIBUHDDEV_PKG) + ELSEIF(UHD_INSTALL_COMPONENT STREQUAL "tests") + IF(NOT LIBUHD_PKG AND NOT LIBUHDDEV_PKG) + INSTALL(${ARGN}) + ENDIF(NOT LIBUHD_PKG AND NOT LIBUHDDEV_PKG) + ELSEIF(UHD_INSTALL_COMPONENT STREQUAL "utilities") + IF(NOT LIBUHD_PKG AND NOT LIBUHDDEV_PKG) + INSTALL(${ARGN}) + ENDIF(NOT LIBUHD_PKG AND NOT LIBUHDDEV_PKG) + ELSEIF(UHD_INSTALL_COMPONENT STREQUAL "manual") + IF(NOT LIBUHD_PKG AND NOT LIBUHDDEV_PKG) + INSTALL(${ARGN}) + ENDIF(NOT LIBUHD_PKG AND NOT LIBUHDDEV_PKG) + ELSEIF(UHD_INSTALL_COMPONENT STREQUAL "doxygen") + IF(NOT LIBUHD_PKG AND NOT UHDHOST_PKG) + INSTALL(${ARGN}) + ENDIF(NOT LIBUHD_PKG AND NOT UHDHOST_PKG) + ELSEIF(UHD_INSTALL_COMPONENT STREQUAL "manpages") + IF(NOT LIBUHD_PKG AND NOT LIBUHDDEV_PKG) + INSTALL(${ARGN}) + ENDIF(NOT LIBUHD_PKG AND NOT LIBUHDDEV_PKG) + ELSEIF(UHD_INSTALL_COMPONENT STREQUAL "images") + IF(NOT LIBUHD_PKG AND NOT LIBUHDDEV_PKG AND NOT UHDHOST_PKG) + INSTALL(${ARGN}) + ENDIF(NOT LIBUHD_PKG AND NOT LIBUHDDEV_PKG AND NOT UHDHOST_PKG) + ELSEIF(UHD_INSTALL_COMPONENT STREQUAL "readme") + IF(NOT LIBUHD_PKG AND NOT LIBUHDDEV_PKG AND NOT UHDHOST_PKG) + INSTALL(${ARGN}) + ENDIF(NOT LIBUHD_PKG AND NOT LIBUHDDEV_PKG AND NOT UHDHOST_PKG) + ENDIF(UHD_INSTALL_COMPONENT STREQUAL "headers") +ENDFUNCTION(UHD_INSTALL) + +######################################################################## # Print the registered component summary ######################################################################## FUNCTION(UHD_PRINT_COMPONENT_SUMMARY) diff --git a/host/cmake/Modules/UHDPackage.cmake b/host/cmake/Modules/UHDPackage.cmake index 1f1d266e2..0ce390699 100644 --- a/host/cmake/Modules/UHDPackage.cmake +++ b/host/cmake/Modules/UHDPackage.cmake @@ -1,5 +1,5 @@ # -# Copyright 2010-2012 Ettus Research LLC +# Copyright 2010-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 @@ -55,23 +55,31 @@ ENDIF() ######################################################################## # Setup package file name ######################################################################## -FIND_PROGRAM(LSB_RELEASE_EXECUTABLE lsb_release) -IF((DEBIAN OR REDHAT) AND LSB_RELEASE_EXECUTABLE) - - #extract system information by executing the commands - EXECUTE_PROCESS( - COMMAND ${LSB_RELEASE_EXECUTABLE} --short --id - OUTPUT_VARIABLE LSB_ID OUTPUT_STRIP_TRAILING_WHITESPACE - ) - EXECUTE_PROCESS( - COMMAND ${LSB_RELEASE_EXECUTABLE} --short --release - OUTPUT_VARIABLE LSB_RELEASE OUTPUT_STRIP_TRAILING_WHITESPACE - ) - - #set a more sensible package name for this system - SET(CPACK_PACKAGE_FILE_NAME "uhd_${UHD_VERSION}_${LSB_ID}-${LSB_RELEASE}-${CMAKE_SYSTEM_PROCESSOR}") +IF(DEBIAN AND LIBUHD_PKG) + SET(CPACK_PACKAGE_FILE_NAME "libuhd${UHD_VERSION_MAJOR}_${TRIMMED_UHD_VERSION}_${CMAKE_SYSTEM_PROCESSOR}") +ELSEIF(DEBIAN AND LIBUHDDEV_PKG) + SET(CPACK_PACKAGE_FILE_NAME "libuhd-dev_${TRIMMED_UHD_VERSION}_${CMAKE_SYSTEM_PROCESSOR}") +ELSEIF(DEBIAN AND UHDHOST_PKG) + SET(CPACK_PACKAGE_FILE_NAME "uhd-host_${TRIMMED_UHD_VERSION}_${CMAKE_SYSTEM_PROCESSOR}") +ELSE() + FIND_PROGRAM(LSB_RELEASE_EXECUTABLE lsb_release) + IF((DEBIAN OR REDHAT) AND LSB_RELEASE_EXECUTABLE) + + #extract system information by executing the commands + EXECUTE_PROCESS( + COMMAND ${LSB_RELEASE_EXECUTABLE} --short --id + OUTPUT_VARIABLE LSB_ID OUTPUT_STRIP_TRAILING_WHITESPACE + ) + EXECUTE_PROCESS( + COMMAND ${LSB_RELEASE_EXECUTABLE} --short --release + OUTPUT_VARIABLE LSB_RELEASE OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + #set a more sensible package name for this system + SET(CPACK_PACKAGE_FILE_NAME "uhd_${UHD_VERSION}_${LSB_ID}-${LSB_RELEASE}-${CMAKE_SYSTEM_PROCESSOR}") ENDIF() +ENDIF(DEBIAN AND LIBUHD_PKG) IF(${CPACK_GENERATOR} STREQUAL NSIS) diff --git a/host/cmake/Modules/UHDVersion.cmake b/host/cmake/Modules/UHDVersion.cmake index a31acac3f..c81e9510b 100644 --- a/host/cmake/Modules/UHDVersion.cmake +++ b/host/cmake/Modules/UHDVersion.cmake @@ -27,10 +27,10 @@ FIND_PACKAGE(Git QUIET) ######################################################################## SET(UHD_VERSION_MAJOR 003) SET(UHD_VERSION_MINOR 005) -SET(UHD_VERSION_PATCH 002) +SET(UHD_VERSION_PATCH 003) ######################################################################## -# Set up DLL resource version numbers +# Set up trimmed version numbers for DLL resource files and packages ######################################################################## FUNCTION(DEPAD_NUM input_num output_num) @@ -42,9 +42,10 @@ FUNCTION(DEPAD_NUM input_num output_num) SET(${output_num} ${depadded_num} PARENT_SCOPE) ENDFUNCTION(DEPAD_NUM) -DEPAD_NUM(${UHD_VERSION_MAJOR} RC_VERSION_MAJOR) -DEPAD_NUM(${UHD_VERSION_MINOR} RC_VERSION_MINOR) -DEPAD_NUM(${UHD_VERSION_PATCH} RC_VERSION_PATCH) +DEPAD_NUM(${UHD_VERSION_MAJOR} TRIMMED_VERSION_MAJOR) +DEPAD_NUM(${UHD_VERSION_MINOR} TRIMMED_VERSION_MINOR) +DEPAD_NUM(${UHD_VERSION_PATCH} TRIMMED_VERSION_PATCH) +SET(TRIMMED_UHD_VERSION "${TRIMMED_VERSION_MAJOR}.${TRIMMED_VERSION_MINOR}.${TRIMMED_VERSION_PATCH}") ######################################################################## # Version information discovery through git log |