diff options
author | Martin Braun <martin.braun@ettus.com> | 2018-11-13 21:53:22 -0800 |
---|---|---|
committer | Brent Stapleton <bstapleton@g.hmc.edu> | 2018-11-14 14:10:09 -0800 |
commit | a69ab0c23a0c38e3fed3e412df36538d8959d23c (patch) | |
tree | e6669a138dad84f79c46588f43a38c69dda90246 /host/cmake/Modules | |
parent | 4247f025020d7dd1f696dfbd3cce248957d6ace7 (diff) | |
download | uhd-a69ab0c23a0c38e3fed3e412df36538d8959d23c.tar.gz uhd-a69ab0c23a0c38e3fed3e412df36538d8959d23c.tar.bz2 uhd-a69ab0c23a0c38e3fed3e412df36538d8959d23c.zip |
cmake: Update coding style to use lowercase commands
Also updates our coding style file.
Ancient CMake versions required upper-case commands. Later command
names became case-insensitive. Now the preferred style is lower-case.
Run the following shell code (with GNU compliant sed):
cmake --help-command-list | grep -v "cmake version" | while read c; do
echo 's/\b'"$(echo $c | tr '[:lower:]' '[:upper:]')"'\(\s*\)(/'"$c"'\1(/g'
done > convert.sed \
&& git ls-files -z -- bootstrap '*.cmake' '*.cmake.in' \
'*CMakeLists.txt' | xargs -0 gsed -i -f convert.sed && rm convert.sed
(Make sure the backslashes don't get mangled!)
Diffstat (limited to 'host/cmake/Modules')
-rw-r--r-- | host/cmake/Modules/CMakeParseArgumentsCopy.cmake | 6 | ||||
-rw-r--r-- | host/cmake/Modules/CodeCoverage.cmake | 102 | ||||
-rw-r--r-- | host/cmake/Modules/FindDocutils.cmake | 4 | ||||
-rw-r--r-- | host/cmake/Modules/FindGPSD.cmake | 28 | ||||
-rw-r--r-- | host/cmake/Modules/FindGZip.cmake | 4 | ||||
-rw-r--r-- | host/cmake/Modules/FindLIBERIO.cmake | 8 | ||||
-rw-r--r-- | host/cmake/Modules/FindUSB1.cmake | 8 | ||||
-rw-r--r-- | host/cmake/Modules/UHDBuildInfo.cmake | 66 | ||||
-rw-r--r-- | host/cmake/Modules/UHDComponent.cmake | 208 | ||||
-rw-r--r-- | host/cmake/Modules/UHDConfig.cmake.in | 96 | ||||
-rw-r--r-- | host/cmake/Modules/UHDConfigVersion.cmake.in | 140 | ||||
-rw-r--r-- | host/cmake/Modules/UHDGlobalDefs.cmake | 20 | ||||
-rw-r--r-- | host/cmake/Modules/UHDLog.cmake | 114 | ||||
-rw-r--r-- | host/cmake/Modules/UHDPackage.cmake | 256 | ||||
-rw-r--r-- | host/cmake/Modules/UHDPython.cmake | 96 | ||||
-rw-r--r-- | host/cmake/Modules/UHDUnitTest.cmake | 4 | ||||
-rw-r--r-- | host/cmake/Modules/UHDVersion.cmake | 144 |
17 files changed, 652 insertions, 652 deletions
diff --git a/host/cmake/Modules/CMakeParseArgumentsCopy.cmake b/host/cmake/Modules/CMakeParseArgumentsCopy.cmake index 7ce4c49ae..a7e78bbdc 100644 --- a/host/cmake/Modules/CMakeParseArgumentsCopy.cmake +++ b/host/cmake/Modules/CMakeParseArgumentsCopy.cmake @@ -1,6 +1,6 @@ -# CMAKE_PARSE_ARGUMENTS(<prefix> <options> <one_value_keywords> <multi_value_keywords> args...) +# 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 +# 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. @@ -17,7 +17,7 @@ # 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 +# 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. diff --git a/host/cmake/Modules/CodeCoverage.cmake b/host/cmake/Modules/CodeCoverage.cmake index a0b0ef526..e19c6399d 100644 --- a/host/cmake/Modules/CodeCoverage.cmake +++ b/host/cmake/Modules/CodeCoverage.cmake @@ -43,11 +43,11 @@ # 1. Copy this file into your cmake modules path. # # 2. Add the following line to your CMakeLists.txt: -# INCLUDE(CodeCoverage) +# include(CodeCoverage) # # 3. Set compiler flags to turn off optimization and enable coverage: -# SET(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage") -# SET(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage") +# set(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage") +# set(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage") # # 3. Use the function SETUP_TARGET_FOR_COVERAGE to create a custom make target # which runs your test executable and produces a lcov code coverage report: @@ -68,48 +68,48 @@ # # Check prereqs -FIND_PROGRAM( GCOV_PATH gcov ) -FIND_PROGRAM( LCOV_PATH lcov ) -FIND_PROGRAM( GENHTML_PATH genhtml ) -FIND_PROGRAM( GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/tests) - -IF(NOT GCOV_PATH) - MESSAGE(FATAL_ERROR "gcov not found! Aborting...") -ENDIF() # NOT GCOV_PATH - -IF("${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang") - IF("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 3) - MESSAGE(FATAL_ERROR "Clang version must be 3.0.0 or greater! Aborting...") - ENDIF() -ELSEIF(NOT CMAKE_COMPILER_IS_GNUCXX) - MESSAGE(FATAL_ERROR "Compiler is not GNU gcc! Aborting...") -ENDIF() # CHECK VALID COMPILER - -SET(CMAKE_CXX_FLAGS_COVERAGE +find_program( GCOV_PATH gcov ) +find_program( LCOV_PATH lcov ) +find_program( GENHTML_PATH genhtml ) +find_program( GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/tests) + +if(NOT GCOV_PATH) + message(FATAL_ERROR "gcov not found! Aborting...") +endif() # NOT GCOV_PATH + +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang") + if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 3) + message(FATAL_ERROR "Clang version must be 3.0.0 or greater! Aborting...") + endif() +elseif(NOT CMAKE_COMPILER_IS_GNUCXX) + message(FATAL_ERROR "Compiler is not GNU gcc! Aborting...") +endif() # CHECK VALID COMPILER + +set(CMAKE_CXX_FLAGS_COVERAGE "-g -O0 --coverage -fprofile-arcs -ftest-coverage" CACHE STRING "Flags used by the C++ compiler during coverage builds." FORCE ) -SET(CMAKE_C_FLAGS_COVERAGE +set(CMAKE_C_FLAGS_COVERAGE "-g -O0 --coverage -fprofile-arcs -ftest-coverage" CACHE STRING "Flags used by the C compiler during coverage builds." FORCE ) -SET(CMAKE_EXE_LINKER_FLAGS_COVERAGE +set(CMAKE_EXE_LINKER_FLAGS_COVERAGE "" CACHE STRING "Flags used for linking binaries during coverage builds." FORCE ) -SET(CMAKE_SHARED_LINKER_FLAGS_COVERAGE +set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE "" CACHE STRING "Flags used by the shared libraries linker during coverage builds." FORCE ) -MARK_AS_ADVANCED( +mark_as_advanced( CMAKE_CXX_FLAGS_COVERAGE CMAKE_C_FLAGS_COVERAGE CMAKE_EXE_LINKER_FLAGS_COVERAGE CMAKE_SHARED_LINKER_FLAGS_COVERAGE ) -IF ( NOT (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "Coverage")) - MESSAGE( WARNING "Code coverage results with an optimized (non-Debug) build may be misleading" ) -ENDIF() # NOT CMAKE_BUILD_TYPE STREQUAL "Debug" +if ( NOT (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "Coverage")) + message( WARNING "Code coverage results with an optimized (non-Debug) build may be misleading" ) +endif() # NOT CMAKE_BUILD_TYPE STREQUAL "Debug" # Param _targetname The name of new the custom make target @@ -120,23 +120,23 @@ ENDIF() # NOT CMAKE_BUILD_TYPE STREQUAL "Debug" # HTML report is generated in _outputname/index.html # Optional fourth parameter is passed as arguments to _testrunner # Pass them in list form, e.g.: "-j;2" for -j 2 -FUNCTION(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname) +function(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname) - IF(NOT LCOV_PATH) - MESSAGE(FATAL_ERROR "lcov not found! Aborting...") - ENDIF() # NOT LCOV_PATH + if(NOT LCOV_PATH) + message(FATAL_ERROR "lcov not found! Aborting...") + endif() # NOT LCOV_PATH - IF(NOT GENHTML_PATH) - MESSAGE(FATAL_ERROR "genhtml not found! Aborting...") - ENDIF() # NOT GENHTML_PATH + if(NOT GENHTML_PATH) + message(FATAL_ERROR "genhtml not found! Aborting...") + endif() # NOT GENHTML_PATH - SET(coverage_info "${CMAKE_BINARY_DIR}/${_outputname}.info") - SET(coverage_cleaned "${coverage_info}.cleaned") + set(coverage_info "${CMAKE_BINARY_DIR}/${_outputname}.info") + set(coverage_cleaned "${coverage_info}.cleaned") - SEPARATE_ARGUMENTS(test_command UNIX_COMMAND "${_testrunner}") + separate_arguments(test_command UNIX_COMMAND "${_testrunner}") # Setup target - ADD_CUSTOM_TARGET(${_targetname} + add_custom_target(${_targetname} # Cleanup lcov ${LCOV_PATH} --directory . --zerocounters @@ -155,29 +155,29 @@ FUNCTION(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname) ) # Show info where to find the report - ADD_CUSTOM_COMMAND(TARGET ${_targetname} POST_BUILD + add_custom_command(TARGET ${_targetname} POST_BUILD COMMAND ; COMMENT "Open ./${_outputname}/index.html in your browser to view the coverage report." ) -ENDFUNCTION() # SETUP_TARGET_FOR_COVERAGE +endfunction() # SETUP_TARGET_FOR_COVERAGE # Param _targetname The name of new the custom make target # Param _testrunner The name of the target which runs the tests # Param _outputname cobertura output is generated as _outputname.xml # Optional fourth parameter is passed as arguments to _testrunner # Pass them in list form, e.g.: "-j;2" for -j 2 -FUNCTION(SETUP_TARGET_FOR_COVERAGE_COBERTURA _targetname _testrunner _outputname) +function(SETUP_TARGET_FOR_COVERAGE_COBERTURA _targetname _testrunner _outputname) - IF(NOT PYTHON_EXECUTABLE) - MESSAGE(FATAL_ERROR "Python not found! Aborting...") - ENDIF() # NOT PYTHON_EXECUTABLE + if(NOT PYTHON_EXECUTABLE) + message(FATAL_ERROR "Python not found! Aborting...") + endif() # NOT PYTHON_EXECUTABLE - IF(NOT GCOVR_PATH) - MESSAGE(FATAL_ERROR "gcovr not found! Aborting...") - ENDIF() # NOT GCOVR_PATH + if(NOT GCOVR_PATH) + message(FATAL_ERROR "gcovr not found! Aborting...") + endif() # NOT GCOVR_PATH - ADD_CUSTOM_TARGET(${_targetname} + add_custom_target(${_targetname} # Run tests ${_testrunner} ${ARGV3} @@ -189,9 +189,9 @@ FUNCTION(SETUP_TARGET_FOR_COVERAGE_COBERTURA _targetname _testrunner _outputname ) # Show info where to find the report - ADD_CUSTOM_COMMAND(TARGET ${_targetname} POST_BUILD + add_custom_command(TARGET ${_targetname} POST_BUILD COMMAND ; COMMENT "Cobertura code coverage report saved in ${_outputname}.xml." ) -ENDFUNCTION() # SETUP_TARGET_FOR_COVERAGE_COBERTURA +endfunction() # SETUP_TARGET_FOR_COVERAGE_COBERTURA diff --git a/host/cmake/Modules/FindDocutils.cmake b/host/cmake/Modules/FindDocutils.cmake index 7b103879e..2f7f3fa6a 100644 --- a/host/cmake/Modules/FindDocutils.cmake +++ b/host/cmake/Modules/FindDocutils.cmake @@ -6,6 +6,6 @@ # ######################################################################## -FIND_PROGRAM(RST2HTML_EXECUTABLE NAMES rst2html rst2html.py) -INCLUDE(FindPackageHandleStandardArgs) +find_program(RST2HTML_EXECUTABLE NAMES rst2html rst2html.py) +include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Docutils DEFAULT_MSG RST2HTML_EXECUTABLE) diff --git a/host/cmake/Modules/FindGPSD.cmake b/host/cmake/Modules/FindGPSD.cmake index 3e29c7498..92216438f 100644 --- a/host/cmake/Modules/FindGPSD.cmake +++ b/host/cmake/Modules/FindGPSD.cmake @@ -12,40 +12,40 @@ # also defined, but not for general use are # LIBGPS_LIBRARY, where to find the GPSD library. -INCLUDE(FindPkgConfig) +include(FindPkgConfig) PKG_CHECK_MODULES(PC_GPSD "libgps") PKG_CHECK_MODULES(PC_GPSD_V3_11 "libgps >= 3.11") -IF(PC_GPSD_FOUND AND NOT PC_GPSD_V3_11_FOUND) - MESSAGE(WARNING "GPSD version found is too old") -ENDIF(PC_GPSD_FOUND AND NOT PC_GPSD_V3_11_FOUND) +if(PC_GPSD_FOUND AND NOT PC_GPSD_V3_11_FOUND) + message(WARNING "GPSD version found is too old") +endif(PC_GPSD_FOUND AND NOT PC_GPSD_V3_11_FOUND) -IF(PC_GPSD_V3_11_FOUND) - FIND_PATH( +if(PC_GPSD_V3_11_FOUND) + find_path( LIBGPS_INCLUDE_DIR NAMES gps.h HINTS ${PC_GPSD_INCLUDE_DIR} ) - SET( + set( LIBGPS_NAMES ${LIBGPS_NAMES} gps ) - FIND_LIBRARY( + find_library( LIBGPS_LIBRARY NAMES ${LIBGPS_NAMES} HINTS ${PC_GPSD_LIBDIR} ) -ENDIF(PC_GPSD_V3_11_FOUND) +endif(PC_GPSD_V3_11_FOUND) # handle the QUIETLY and REQUIRED arguments and set LIBGPS_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBGPS DEFAULT_MSG LIBGPS_LIBRARY LIBGPS_INCLUDE_DIR) -IF(LIBGPS_FOUND) - SET(LIBGPS_LIBRARIES ${LIBGPS_LIBRARY}) -ENDIF(LIBGPS_FOUND) +if(LIBGPS_FOUND) + set(LIBGPS_LIBRARIES ${LIBGPS_LIBRARY}) +endif(LIBGPS_FOUND) -MARK_AS_ADVANCED(LIBGPS_LIBRARY LIBGPS_INCLUDE_DIR) +mark_as_advanced(LIBGPS_LIBRARY LIBGPS_INCLUDE_DIR) diff --git a/host/cmake/Modules/FindGZip.cmake b/host/cmake/Modules/FindGZip.cmake index 029e95a22..2964529b2 100644 --- a/host/cmake/Modules/FindGZip.cmake +++ b/host/cmake/Modules/FindGZip.cmake @@ -6,6 +6,6 @@ # ######################################################################## -FIND_PROGRAM(GZIP_EXECUTABLE NAMES gzip) -INCLUDE(FindPackageHandleStandardArgs) +find_program(GZIP_EXECUTABLE NAMES gzip) +include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(GZip DEFAULT_MSG GZIP_EXECUTABLE) diff --git a/host/cmake/Modules/FindLIBERIO.cmake b/host/cmake/Modules/FindLIBERIO.cmake index 9a29e52e8..77fd49735 100644 --- a/host/cmake/Modules/FindLIBERIO.cmake +++ b/host/cmake/Modules/FindLIBERIO.cmake @@ -13,22 +13,22 @@ # also defined, but not for general use are # LIBERIO_LIBRARY, where to find the liberio library. -FIND_PACKAGE(PkgConfig) +find_package(PkgConfig) PKG_CHECK_MODULES(PC_LIBERIO QUIET liberio >= 0.3) -FIND_PATH(LIBERIO_INCLUDE_DIR liberio/liberio.h +find_path(LIBERIO_INCLUDE_DIR liberio/liberio.h HINTS $ENV{LIBERIO_DIR}/include ${PC_LIBERIO_INCLUDE_DIR} PATH_SUFFIXES liberio ) -FIND_LIBRARY(LIBERIO_LIBRARY +find_library(LIBERIO_LIBRARY NAMES erio liberio HINTS $ENV{LIBERIO_DIR}/lib ${PC_LIBERIO_LIBDIR} ${PC_LIBERIO_LIBRARY_DIRS} ) include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBERIO DEFAULT_MSG LIBERIO_LIBRARY LIBERIO_INCLUDE_DIR) -MARK_AS_ADVANCED(LIBERIO_INCLUDE_DIR LIBERIO_LIBRARY) +mark_as_advanced(LIBERIO_INCLUDE_DIR LIBERIO_LIBRARY) set(LIBERIO_LIBRARIES ${LIBERIO_LIBRARY}) set(LIBERIO_INCLUDE_DIRS ${LIBERIO_INCLUDE_DIR}) diff --git a/host/cmake/Modules/FindUSB1.cmake b/host/cmake/Modules/FindUSB1.cmake index 7c4a8fb6b..3763d715b 100644 --- a/host/cmake/Modules/FindUSB1.cmake +++ b/host/cmake/Modules/FindUSB1.cmake @@ -3,10 +3,10 @@ #sets LIBUSB_FOUND, LIBUSB_LIBRARIES, LIBUSB_INCLUDE_DIRS #override LIBUSB_LIBRARIES LIBUSB_INCLUDE_DIRS to manually set -INCLUDE(FindPkgConfig) +include(FindPkgConfig) PKG_CHECK_MODULES(PC_LIBUSB QUIET libusb-1.0) -FIND_PATH(LIBUSB_INCLUDE_DIRS +find_path(LIBUSB_INCLUDE_DIRS NAMES libusb.h HINTS $ENV{LIBUSB_DIR}/include $ENV{LIBUSB_DIR}/include/libusb-1.0 ${PC_LIBUSB_INCLUDEDIR} ${PC_LIBUSB_INCLUDEDIR}/libusb-1.0 @@ -27,7 +27,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR CMAKE_SYSTEM_NAME STREQUAL "kFreeBSD" list(APPEND libusb1_library_names usb) endif() -FIND_LIBRARY(LIBUSB_LIBRARIES +find_library(LIBUSB_LIBRARIES NAMES ${libusb1_library_names} HINTS $ENV{LIBUSB_DIR}/lib ${PC_LIBUSB_LIBDIR} PATHS /usr/local/lib /usr/lib /opt/local/lib @@ -59,4 +59,4 @@ endif(HAVE_LIBUSB_STRERROR) include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBUSB DEFAULT_MSG LIBUSB_LIBRARIES LIBUSB_INCLUDE_DIRS) -MARK_AS_ADVANCED(LIBUSB_INCLUDE_DIRS LIBUSB_LIBRARIES) +mark_as_advanced(LIBUSB_INCLUDE_DIRS LIBUSB_LIBRARIES) diff --git a/host/cmake/Modules/UHDBuildInfo.cmake b/host/cmake/Modules/UHDBuildInfo.cmake index 21b1e3c1d..468635b15 100644 --- a/host/cmake/Modules/UHDBuildInfo.cmake +++ b/host/cmake/Modules/UHDBuildInfo.cmake @@ -8,46 +8,46 @@ # We need this to be macro because GET_DIRECTORY_PROPERTY works with # the current directory. # -MACRO(UHD_LOAD_BUILD_INFO) - MESSAGE(STATUS "") - MESSAGE(STATUS "Loading build info.") +macro(UHD_LOAD_BUILD_INFO) + message(STATUS "") + message(STATUS "Loading build info.") # Build date - IF(IGNORE_BUILD_DATE) - SET(UHD_BUILD_DATE "") - ELSE() - EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c + if(IGNORE_BUILD_DATE) + set(UHD_BUILD_DATE "") + else() + execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import time; print(time.strftime('%a, %d %b %Y %H:%M:%S', time.gmtime()))" OUTPUT_VARIABLE UHD_BUILD_DATE OUTPUT_STRIP_TRAILING_WHITESPACE ) - ENDIF(IGNORE_BUILD_DATE) + endif(IGNORE_BUILD_DATE) # Compiler name - IF(MSVC) - IF(MSVC10) - SET(UHD_C_COMPILER "MSVC 2010") - SET(UHD_CXX_COMPILER "MSVC 2010") - ELSEIF(MSVC11) - SET(UHD_C_COMPILER "MSVC 2012") - SET(UHD_CXX_COMPILER "MSVC 2012") - ELSEIF(MSVC12) - SET(UHD_C_COMPILER "MSVC 2013") - SET(UHD_CXX_COMPILER "MSVC 2013") - ELSEIF(MSVC14) - SET(UHD_C_COMPILER "MSVC 2015") - SET(UHD_CXX_COMPILER "MSVC 2015") - ELSE() + if(MSVC) + if(MSVC10) + set(UHD_C_COMPILER "MSVC 2010") + set(UHD_CXX_COMPILER "MSVC 2010") + elseif(MSVC11) + set(UHD_C_COMPILER "MSVC 2012") + set(UHD_CXX_COMPILER "MSVC 2012") + elseif(MSVC12) + set(UHD_C_COMPILER "MSVC 2013") + set(UHD_CXX_COMPILER "MSVC 2013") + elseif(MSVC14) + set(UHD_C_COMPILER "MSVC 2015") + set(UHD_CXX_COMPILER "MSVC 2015") + else() # Go with the ugly string - SET(UHD_C_COMPILER "MSVC ${CMAKE_C_COMPILER_VERSION}") - SET(UHD_CXX_COMPILER "MSVC ${CMAKE_CXX_COMPILER_VERSION}") - ENDIF(MSVC10) - ELSE() - SET(UHD_C_COMPILER "${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION}") - SET(UHD_CXX_COMPILER "${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}") - ENDIF(MSVC) + set(UHD_C_COMPILER "MSVC ${CMAKE_C_COMPILER_VERSION}") + set(UHD_CXX_COMPILER "MSVC ${CMAKE_CXX_COMPILER_VERSION}") + endif(MSVC10) + else() + set(UHD_C_COMPILER "${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION}") + set(UHD_CXX_COMPILER "${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}") + endif(MSVC) # Compiler flags - GET_DIRECTORY_PROPERTY(uhd_flags COMPILE_DEFINITIONS) - SET(UHD_C_FLAGS "${uhd_flags}${CMAKE_C_FLAGS}") # CMAKE_C_FLAGS starts with a space - SET(UHD_CXX_FLAGS "${uhd_flags}${CMAKE_CXX_FLAGS}") # CMAKE_CXX_FLAGS starts with a space -ENDMACRO(UHD_LOAD_BUILD_INFO) + get_directory_property(uhd_flags COMPILE_DEFINITIONS) + set(UHD_C_FLAGS "${uhd_flags}${CMAKE_C_FLAGS}") # CMAKE_C_FLAGS starts with a space + set(UHD_CXX_FLAGS "${uhd_flags}${CMAKE_CXX_FLAGS}") # CMAKE_CXX_FLAGS starts with a space +endmacro(UHD_LOAD_BUILD_INFO) diff --git a/host/cmake/Modules/UHDComponent.cmake b/host/cmake/Modules/UHDComponent.cmake index b18f651ea..db8806be9 100644 --- a/host/cmake/Modules/UHDComponent.cmake +++ b/host/cmake/Modules/UHDComponent.cmake @@ -6,8 +6,8 @@ # ######################################################################## -SET(_uhd_enabled_components "" CACHE INTERNAL "" FORCE) -SET(_uhd_disabled_components "" CACHE INTERNAL "" FORCE) +set(_uhd_enabled_components "" CACHE INTERNAL "" FORCE) +set(_uhd_disabled_components "" CACHE INTERNAL "" FORCE) ######################################################################## # Register a component into the system @@ -22,29 +22,29 @@ SET(_uhd_disabled_components "" CACHE INTERNAL "" FORCE) # "FOO" which is enabled by calling CMake with -DENABLE_FOO=ON. It defaults to # ON, unless DEPENDENCY_FOUND is false, in which case it becomes false. ######################################################################## -MACRO(LIBUHD_REGISTER_COMPONENT name var enb deps dis req) - MESSAGE(STATUS "") - MESSAGE(STATUS "Configuring ${name} support...") - FOREACH(dep ${deps}) - MESSAGE(STATUS " Dependency ${dep} = ${${dep}}") - ENDFOREACH(dep) +macro(LIBUHD_REGISTER_COMPONENT name var enb deps dis req) + message(STATUS "") + message(STATUS "Configuring ${name} support...") + foreach(dep ${deps}) + message(STATUS " Dependency ${dep} = ${${dep}}") + endforeach(dep) # If user specified option, store here. Note: If the user doesn't specify # this option on the cmake command line, both user_enabled and # user_disabled will be false! - IF("${${var}}" STREQUAL "OFF") - SET(user_disabled TRUE) - ELSE() - SET(user_disabled FALSE) - ENDIF("${${var}}" STREQUAL "OFF") - IF("${${var}}" STREQUAL "ON") - SET(user_enabled TRUE) - ELSE() - SET(user_enabled FALSE) - ENDIF("${${var}}" STREQUAL "ON") + if("${${var}}" STREQUAL "OFF") + set(user_disabled TRUE) + else() + set(user_disabled FALSE) + endif("${${var}}" STREQUAL "OFF") + if("${${var}}" STREQUAL "ON") + set(user_enabled TRUE) + else() + set(user_enabled FALSE) + endif("${${var}}" STREQUAL "ON") #setup the dependent option for this component - INCLUDE(CMakeDependentOption) + include(CMakeDependentOption) CMAKE_DEPENDENT_OPTION(${var} "enable ${name} support" ${enb} "${deps}" ${dis}) # There are two failure cases: @@ -52,105 +52,105 @@ MACRO(LIBUHD_REGISTER_COMPONENT name var enb deps dis req) # requirements are not met. # 2) The user did not explicitly turn off this component (-DENABLE_FOO=OFF) # but it is flagged as required by ${req} - IF(NOT ${var} AND user_enabled) # Case 1) - MESSAGE(FATAL_ERROR "Dependencies for required component ${name} not met.") - ENDIF(NOT ${var} AND user_enabled) - IF(NOT ${var} AND ${req} AND NOT user_disabled) # Case 2) - MESSAGE(FATAL_ERROR "Dependencies for required component ${name} not met.") - ENDIF(NOT ${var} AND ${req} AND NOT user_disabled) + if(NOT ${var} AND user_enabled) # Case 1) + message(FATAL_ERROR "Dependencies for required component ${name} not met.") + endif(NOT ${var} AND user_enabled) + if(NOT ${var} AND ${req} AND NOT user_disabled) # Case 2) + message(FATAL_ERROR "Dependencies for required component ${name} not met.") + endif(NOT ${var} AND ${req} AND NOT user_disabled) #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}) - MESSAGE(STATUS " Override with -D${var}=ON/OFF") + 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}) + message(STATUS " Override with -D${var}=ON/OFF") #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) -ENDMACRO(LIBUHD_REGISTER_COMPONENT) + set(_uhd_enabled_components ${_uhd_enabled_components} CACHE INTERNAL "" FORCE) + set(_uhd_disabled_components ${_uhd_disabled_components} CACHE INTERNAL "" FORCE) +endmacro(LIBUHD_REGISTER_COMPONENT) ######################################################################## # Install only if appropriate for package and if component is enabled ######################################################################## -FUNCTION(UHD_INSTALL) +function(UHD_INSTALL) include(CMakeParseArgumentsCopy) - CMAKE_PARSE_ARGUMENTS(UHD_INSTALL "" "DESTINATION;COMPONENT" "TARGETS;FILES;PROGRAMS" ${ARGN}) + 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_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 "devel") - 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) + 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 "devel") + 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) - MESSAGE(STATUS "") - MESSAGE(STATUS "######################################################") - MESSAGE(STATUS "# UHD enabled components ") - MESSAGE(STATUS "######################################################") - FOREACH(comp ${_uhd_enabled_components}) - MESSAGE(STATUS " * ${comp}") - ENDFOREACH(comp) +function(UHD_PRINT_COMPONENT_SUMMARY) + message(STATUS "") + message(STATUS "######################################################") + message(STATUS "# UHD enabled components ") + message(STATUS "######################################################") + foreach(comp ${_uhd_enabled_components}) + message(STATUS " * ${comp}") + endforeach(comp) - MESSAGE(STATUS "") - MESSAGE(STATUS "######################################################") - MESSAGE(STATUS "# UHD disabled components ") - MESSAGE(STATUS "######################################################") - FOREACH(comp ${_uhd_disabled_components}) - MESSAGE(STATUS " * ${comp}") - ENDFOREACH(comp) + message(STATUS "") + message(STATUS "######################################################") + message(STATUS "# UHD disabled components ") + message(STATUS "######################################################") + foreach(comp ${_uhd_disabled_components}) + message(STATUS " * ${comp}") + endforeach(comp) - MESSAGE(STATUS "") -ENDFUNCTION(UHD_PRINT_COMPONENT_SUMMARY) + message(STATUS "") +endfunction(UHD_PRINT_COMPONENT_SUMMARY) diff --git a/host/cmake/Modules/UHDConfig.cmake.in b/host/cmake/Modules/UHDConfig.cmake.in index 4651e3a9c..30b0d92ff 100644 --- a/host/cmake/Modules/UHDConfig.cmake.in +++ b/host/cmake/Modules/UHDConfig.cmake.in @@ -25,50 +25,50 @@ set(ENV{UHD_CONFIG_USED} TRUE) # set default values -SET(UHD_FOUND TRUE) -SET(UHD_RFNOC_FOUND @UHD_RFNOC_FOUND@) -SET(UHD_INCLUDE_HINTS) -SET(UHD_LIBDIR_HINTS) -SET(UHD_DIR $ENV{UHD_DIR}) - -IF(UHD_DIR) - LIST(APPEND UHD_INCLUDE_HINTS ${UHD_DIR}/include) - LIST(APPEND UHD_LIBDIR_HINTS ${UHD_DIR}/lib) -ENDIF() - -INCLUDE(FindPkgConfig) -IF(PKG_CONFIG_FOUND) - IF(NOT ${CMAKE_VERSION} VERSION_LESS "2.8.0") - SET(UHD_QUIET "QUIET") - ENDIF() +set(UHD_FOUND TRUE) +set(UHD_RFNOC_FOUND @UHD_RFNOC_FOUND@) +set(UHD_INCLUDE_HINTS) +set(UHD_LIBDIR_HINTS) +set(UHD_DIR $ENV{UHD_DIR}) + +if(UHD_DIR) + list(APPEND UHD_INCLUDE_HINTS ${UHD_DIR}/include) + list(APPEND UHD_LIBDIR_HINTS ${UHD_DIR}/lib) +endif() + +include(FindPkgConfig) +if(PKG_CONFIG_FOUND) + if(NOT ${CMAKE_VERSION} VERSION_LESS "2.8.0") + set(UHD_QUIET "QUIET") + endif() PKG_CHECK_MODULES(PC_UHD ${UHD_QUIET} uhd) - IF(PC_UHD_FOUND) - LIST(APPEND UHD_INCLUDE_HINTS ${PC_UHD_INCLUDEDIR}) - LIST(APPEND UHD_LIBDIR_HINTS ${PC_UHD_LIBDIR}) - ENDIF() -ENDIF() + if(PC_UHD_FOUND) + list(APPEND UHD_INCLUDE_HINTS ${PC_UHD_INCLUDEDIR}) + list(APPEND UHD_LIBDIR_HINTS ${PC_UHD_LIBDIR}) + endif() +endif() -LIST(APPEND UHD_INCLUDE_HINTS ${CMAKE_INSTALL_PREFIX}/include) -LIST(APPEND UHD_LIBDIR_HINTS ${CMAKE_INSTALL_PREFIX}/lib) +list(APPEND UHD_INCLUDE_HINTS ${CMAKE_INSTALL_PREFIX}/include) +list(APPEND UHD_LIBDIR_HINTS ${CMAKE_INSTALL_PREFIX}/lib) # Search for static libs if so required -IF( UHD_USE_STATIC_LIBS ) - SET( _UHD_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) - IF(WIN32) - SET(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) - ELSE() - SET(CMAKE_FIND_LIBRARY_SUFFIXES .a ) - ENDIF() +if( UHD_USE_STATIC_LIBS ) + set( _UHD_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + if(WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + else() + set(CMAKE_FIND_LIBRARY_SUFFIXES .a ) + endif() # This is set during build of UHD to match the installed version: - SET(UHD_STATIC_LIB_DEPS "@UHD_LINK_LIST_STATIC@") -ENDIF() + set(UHD_STATIC_LIB_DEPS "@UHD_LINK_LIST_STATIC@") +endif() # Verify that <uhd/config.hpp> and libuhd are available, and, if a # version is provided, that UHD meets the version requirements -- no # matter what pkg-config might think. -FIND_PATH( +find_path( UHD_INCLUDE_DIRS NAMES uhd/config.hpp HINTS ${UHD_INCLUDE_HINTS} @@ -76,7 +76,7 @@ FIND_PATH( /usr/include ) -FIND_LIBRARY( +find_library( UHD_LIBRARIES NAMES uhd HINTS ${UHD_LIBDIR_HINTS} @@ -85,25 +85,25 @@ FIND_LIBRARY( ) # Set up linker flags for static linking: -IF(UHD_USE_STATIC_LIBS) - IF(WIN32) - MESSAGE(FATAL_ERROR "Static linking not available on Windows") - ELSE(WIN32) +if(UHD_USE_STATIC_LIBS) + if(WIN32) + message(FATAL_ERROR "Static linking not available on Windows") + else(WIN32) # This works for gcc and Clang: - SET(UHD_STATIC_LIB_LINK_FLAG "-Wl,-whole-archive ${UHD_LIBRARIES} -Wl,-no-whole-archive") - ENDIF(WIN32) + set(UHD_STATIC_LIB_LINK_FLAG "-Wl,-whole-archive ${UHD_LIBRARIES} -Wl,-no-whole-archive") + endif(WIN32) # Restore the library suffixes, if we changed them: - SET(CMAKE_FIND_LIBRARY_SUFFIXES ${_UHD_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) -ENDIF(UHD_USE_STATIC_LIBS) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${_UHD_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) +endif(UHD_USE_STATIC_LIBS) -IF(UHD_LIBRARIES AND UHD_INCLUDE_DIRS) +if(UHD_LIBRARIES AND UHD_INCLUDE_DIRS) - INCLUDE(FindPackageHandleStandardArgs) + include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(UHD DEFAULT_MSG UHD_LIBRARIES UHD_INCLUDE_DIRS) - MARK_AS_ADVANCED(UHD_LIBRARIES UHD_INCLUDE_DIRS) + mark_as_advanced(UHD_LIBRARIES UHD_INCLUDE_DIRS) -ELSEIF(UHD_FIND_REQUIRED) +elseif(UHD_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "UHD is required, but was not found.") + message(FATAL_ERROR "UHD is required, but was not found.") -ENDIF() +endif() diff --git a/host/cmake/Modules/UHDConfigVersion.cmake.in b/host/cmake/Modules/UHDConfigVersion.cmake.in index 9945789b1..5e3e9558e 100644 --- a/host/cmake/Modules/UHDConfigVersion.cmake.in +++ b/host/cmake/Modules/UHDConfigVersion.cmake.in @@ -19,14 +19,14 @@ set(ENV{UHD_CONFIG_VERSION_USED} TRUE) # version values as set in cmake/Modules/UHDVersion.cmake, placed # statically in here to avoid using Python all over again. -SET(MAJOR_VERSION @UHD_VERSION_MAJOR@) -SET(API_VERSION @UHD_VERSION_API@) -SET(ABI_VERSION @UHD_VERSION_ABI@) -SET(PATCH_VERSION @UHD_VERSION_PATCH@) -SET(DEVEL_VERSION @UHD_VERSION_DEVEL@) +set(MAJOR_VERSION @UHD_VERSION_MAJOR@) +set(API_VERSION @UHD_VERSION_API@) +set(ABI_VERSION @UHD_VERSION_ABI@) +set(PATCH_VERSION @UHD_VERSION_PATCH@) +set(DEVEL_VERSION @UHD_VERSION_DEVEL@) -SET(PACKAGE_VERSION @UHD_VERSION@) -SET(ENV{UHD_PACKAGE_VERSION} ${PACKAGE_VERSION}) +set(PACKAGE_VERSION @UHD_VERSION@) +set(ENV{UHD_PACKAGE_VERSION} ${PACKAGE_VERSION}) # There is a bug in CMake whereby calling "find_package(FOO)" within # "find_package(FOO)" results in the version being checked in the @@ -34,62 +34,62 @@ SET(ENV{UHD_PACKAGE_VERSION} ${PACKAGE_VERSION}) # "PACKAGE_FIND_VERSION" and if empty set return variables to TRUE to # make CMake happy. Not the best solution, but it does the trick. -IF(NOT PACKAGE_FIND_VERSION) - SET(PACKAGE_VERSION_COMPATIBLE TRUE) - SET(PACKAGE_VERSION_EXACT TRUE) - RETURN() -ENDIF(NOT PACKAGE_FIND_VERSION) +if(NOT PACKAGE_FIND_VERSION) + set(PACKAGE_VERSION_COMPATIBLE TRUE) + set(PACKAGE_VERSION_EXACT TRUE) + return() +endif(NOT PACKAGE_FIND_VERSION) # Development branches of UHD don't have a patch version. This is a hack # to add a fake patch version that should be higher than anything the user # requests. -IF(DEVEL_VERSION) - SET(PACKAGE_VERSION "${MAJOR_VERSION}.${API_VERSION}.${ABI_VERSION}.999") -ENDIF(DEVEL_VERSION) +if(DEVEL_VERSION) + set(PACKAGE_VERSION "${MAJOR_VERSION}.${API_VERSION}.${ABI_VERSION}.999") +endif(DEVEL_VERSION) # assume incorrect versioning by default -SET(PACKAGE_VERSION_COMPATIBLE FALSE) -SET(PACKAGE_VERSION_EXACT FALSE) +set(PACKAGE_VERSION_COMPATIBLE FALSE) +set(PACKAGE_VERSION_EXACT FALSE) # do not use ABI for now -SET(UHD_USE_ABI FALSE) +set(UHD_USE_ABI FALSE) # leave the ABI checking in, for now, just in case it is wanted in the # future. This code works nicely to find the ABI compatibility # version from <uhd/version.hpp>. -IF(UHD_USE_ABI) +if(UHD_USE_ABI) # find ABI compatible version from <uhd/version.hpp> - SET(UHD_INCLUDE_HINTS) - SET(UHD_DIR $ENV{UHD_DIR}) + set(UHD_INCLUDE_HINTS) + set(UHD_DIR $ENV{UHD_DIR}) - IF(UHD_DIR) - LIST(APPEND UHD_INCLUDE_HINTS ${UHD_DIR}/include) - ENDIF() + if(UHD_DIR) + list(APPEND UHD_INCLUDE_HINTS ${UHD_DIR}/include) + endif() - INCLUDE(FindPkgConfig) - IF(PKG_CONFIG_FOUND) - IF(NOT ${CMAKE_VERSION} VERSION_LESS "2.8.0") - SET(UHD_QUIET "QUIET") - ENDIF() - IF(PACKAGE_VERSION_EXACT) + include(FindPkgConfig) + if(PKG_CONFIG_FOUND) + if(NOT ${CMAKE_VERSION} VERSION_LESS "2.8.0") + set(UHD_QUIET "QUIET") + endif() + if(PACKAGE_VERSION_EXACT) PKG_CHECK_MODULES(PC_UHD ${UHD_QUIET} uhd=${UHD_FIND_VERSION}) - ELSE() + else() PKG_CHECK_MODULES(PC_UHD ${UHD_QUIET} uhd>=${UHD_FIND_VERSION}) - ENDIF() - IF(PC_UHD_FOUND) - LIST(APPEND UHD_INCLUDE_HINTS ${PC_UHD_INCLUDEDIR}) - ENDIF() - ENDIF() + endif() + if(PC_UHD_FOUND) + list(APPEND UHD_INCLUDE_HINTS ${PC_UHD_INCLUDEDIR}) + endif() + endif() - LIST(APPEND UHD_INCLUDE_HINTS ${CMAKE_INSTALL_PREFIX}/include) + list(APPEND UHD_INCLUDE_HINTS ${CMAKE_INSTALL_PREFIX}/include) # Verify that <uhd/config.hpp> and libuhd are available, and, if a # version is provided, that UHD meets the version requirements -- no # matter what pkg-config might think. - FIND_PATH( + find_path( UHD_INCLUDE_DIR NAMES uhd/version.hpp HINTS ${UHD_INCLUDE_HINTS} @@ -97,72 +97,72 @@ IF(UHD_USE_ABI) /usr/include ) - IF(UHD_INCLUDE_DIR) + if(UHD_INCLUDE_DIR) # extract the UHD API version from the installed header - FILE(STRINGS "${UHD_INCLUDE_DIR}/uhd/version.hpp" + file(STRINGS "${UHD_INCLUDE_DIR}/uhd/version.hpp" UHD_STRING_VERSION REGEX "UHD_VERSION_ABI_STRING") - STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" + string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" UHD_ABI_VERSION_CONCISE ${UHD_STRING_VERSION}) # convert UHD_FIND_VERSION into concise #.#.# format for comparison - STRING(REGEX REPLACE "([^\\.]*)\\.([^\\.]*)\\.([^\\.]*)" + string(REGEX REPLACE "([^\\.]*)\\.([^\\.]*)\\.([^\\.]*)" "\\1.\\2.\\3" UHD_ABI_VERSION_TMP ${UHD_ABI_VERSION_CONCISE}) - STRING(REPLACE "0" "" UHD_ABI_MAJOR ${CMAKE_MATCH_1}) - STRING(REPLACE "0" "" UHD_ABI_MINOR ${CMAKE_MATCH_2}) - STRING(REPLACE "0" "" UHD_ABI_PATCH ${CMAKE_MATCH_3}) + string(REPLACE "0" "" UHD_ABI_MAJOR ${CMAKE_MATCH_1}) + string(REPLACE "0" "" UHD_ABI_MINOR ${CMAKE_MATCH_2}) + string(REPLACE "0" "" UHD_ABI_PATCH ${CMAKE_MATCH_3}) # fix the case where the version number is "000" - IF(NOT UHD_ABI_MAJOR) - SET(UHD_ABI_MAJOR "0") - ENDIF() - IF(NOT UHD_ABI_MINOR) - SET(UHD_ABI_MINOR "0") - ENDIF() - IF(NOT UHD_ABI_PATCH) - SET(UHD_ABI_PATCH "0") - ENDIF() + if(NOT UHD_ABI_MAJOR) + set(UHD_ABI_MAJOR "0") + endif() + if(NOT UHD_ABI_MINOR) + set(UHD_ABI_MINOR "0") + endif() + if(NOT UHD_ABI_PATCH) + set(UHD_ABI_PATCH "0") + endif() - SET(UHD_ABI_VERSION_CONCISE ${UHD_ABI_MAJOR}.${UHD_ABI_MINOR}.${UHD_ABI_PATCH}) + set(UHD_ABI_VERSION_CONCISE ${UHD_ABI_MAJOR}.${UHD_ABI_MINOR}.${UHD_ABI_PATCH}) - ELSE(UHD_INCLUDE_DIR) + else(UHD_INCLUDE_DIR) # no header found ... not a good sign! Assume ABI version is the # same as that known internally here. Let UHDConfig.cmake fail if # it cannot find <uhd/config.hpp> or "libuhd" ... - SET(UHD_ABI_VERSION_CONCISE ${PACKAGE_VERSION}) + set(UHD_ABI_VERSION_CONCISE ${PACKAGE_VERSION}) - ENDIF(UHD_INCLUDE_DIR) + endif(UHD_INCLUDE_DIR) # check for ABI compatibility, both: # ACTUAL VERSION >= DESIRED VERSION >= ABI VERSION - IF(NOT ${PACKAGE_FIND_VERSION} VERSION_LESS ${UHD_ABI_VERSION_CONCISE} AND + if(NOT ${PACKAGE_FIND_VERSION} VERSION_LESS ${UHD_ABI_VERSION_CONCISE} AND NOT ${PACKAGE_FIND_VERSION} VERSION_GREATER ${PACKAGE_VERSION}) - SET(PACKAGE_VERSION_COMPATIBLE TRUE) - ENDIF() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + endif() -ELSE(UHD_USE_ABI) +else(UHD_USE_ABI) # use API only, and assume compatible of requested <= actual # which is the same as "not >" - IF(NOT ${PACKAGE_FIND_VERSION} VERSION_GREATER ${PACKAGE_VERSION}) - SET(PACKAGE_VERSION_COMPATIBLE TRUE) - ENDIF() + if(NOT ${PACKAGE_FIND_VERSION} VERSION_GREATER ${PACKAGE_VERSION}) + set(PACKAGE_VERSION_COMPATIBLE TRUE) + endif() -ENDIF(UHD_USE_ABI) +endif(UHD_USE_ABI) # check for exact version -IF(${PACKAGE_FIND_VERSION} VERSION_EQUAL ${PACKAGE_VERSION}) - SET(PACKAGE_VERSION_EXACT TRUE) -ENDIF() +if(${PACKAGE_FIND_VERSION} VERSION_EQUAL ${PACKAGE_VERSION}) + set(PACKAGE_VERSION_EXACT TRUE) +endif() # Undo our patch-version-number hack -SET(PACKAGE_VERSION @UHD_VERSION@) +set(PACKAGE_VERSION @UHD_VERSION@) diff --git a/host/cmake/Modules/UHDGlobalDefs.cmake b/host/cmake/Modules/UHDGlobalDefs.cmake index d21519479..47bb83511 100644 --- a/host/cmake/Modules/UHDGlobalDefs.cmake +++ b/host/cmake/Modules/UHDGlobalDefs.cmake @@ -7,22 +7,22 @@ # This file sets up all the stuff for the config.h file -INCLUDE(CheckCXXSymbolExistsCopy) +include(CheckCXXSymbolExistsCopy) ## Check for std::log2 CHECK_CXX_SYMBOL_EXISTS(log2 cmath HAVE_LOG2) ## Macros for the version number -IF(UHD_VERSION_DEVEL) - MATH(EXPR UHD_VERSION_ADDED "1000000 * ${UHD_VERSION_MAJOR} + 10000 * ${UHD_VERSION_API} + 100 * ${UHD_VERSION_ABI} + 99") -ELSE() - MATH(EXPR UHD_VERSION_ADDED "1000000 * ${UHD_VERSION_MAJOR} + 10000 * ${UHD_VERSION_API} + 100 * ${UHD_VERSION_ABI} + ${UHD_VERSION_PATCH}") -ENDIF(UHD_VERSION_DEVEL) +if(UHD_VERSION_DEVEL) + math(EXPR UHD_VERSION_ADDED "1000000 * ${UHD_VERSION_MAJOR} + 10000 * ${UHD_VERSION_API} + 100 * ${UHD_VERSION_ABI} + 99") +else() + math(EXPR UHD_VERSION_ADDED "1000000 * ${UHD_VERSION_MAJOR} + 10000 * ${UHD_VERSION_API} + 100 * ${UHD_VERSION_ABI} + ${UHD_VERSION_PATCH}") +endif(UHD_VERSION_DEVEL) ## RFNoC -IF(ENABLE_RFNOC) - ADD_DEFINITIONS(-DUHD_RFNOC_ENABLED) -ENDIF(ENABLE_RFNOC) +if(ENABLE_RFNOC) + add_definitions(-DUHD_RFNOC_ENABLED) +endif(ENABLE_RFNOC) ## make sure the code knows about config.h -ADD_DEFINITIONS(-DHAVE_CONFIG_H) +add_definitions(-DHAVE_CONFIG_H) diff --git a/host/cmake/Modules/UHDLog.cmake b/host/cmake/Modules/UHDLog.cmake index 4bc1daf13..18643e672 100644 --- a/host/cmake/Modules/UHDLog.cmake +++ b/host/cmake/Modules/UHDLog.cmake @@ -1,72 +1,72 @@ ######################################################################## # Logging Variables ######################################################################## -IF(CMAKE_BUILD_TYPE STREQUAL "Debug") - SET(UHD_LOG_MIN_LEVEL "debug" CACHE STRING "Set UHD log level to {trace, debug, info, warning, error, fatal}") - SET(UHD_LOG_CONSOLE_DISABLE "OFF" CACHE BOOL "Disable UHD logging to stderr") - SET(UHD_LOG_FILE_LEVEL "trace" CACHE STRING "SET UHD file logging level to {trace, debug, info, warning, error, fatal}") - SET(UHD_LOG_CONSOLE_LEVEL "debug" CACHE STRING "SET UHD file logging level to {trace, debug, info, warning, error, fatal}") -ELSE() - SET(UHD_LOG_MIN_LEVEL "debug" CACHE STRING "Set UHD log level to {trace, debug, info, warning, error, fatal}") - SET(UHD_LOG_CONSOLE_DISABLE "OFF" CACHE BOOL "Disable UHD logging to stderr") - SET(UHD_LOG_FILE_LEVEL "info" CACHE STRING "SET UHD file logging level to {trace, debug, info, warning, error, fatal}") - SET(UHD_LOG_CONSOLE_LEVEL "info" CACHE STRING "SET UHD file logging level to {trace, debug, info, warning, error, fatal}") -ENDIF() +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + set(UHD_LOG_MIN_LEVEL "debug" CACHE STRING "Set UHD log level to {trace, debug, info, warning, error, fatal}") + set(UHD_LOG_CONSOLE_DISABLE "OFF" CACHE BOOL "Disable UHD logging to stderr") + set(UHD_LOG_FILE_LEVEL "trace" CACHE STRING "SET UHD file logging level to {trace, debug, info, warning, error, fatal}") + set(UHD_LOG_CONSOLE_LEVEL "debug" CACHE STRING "SET UHD file logging level to {trace, debug, info, warning, error, fatal}") +else() + set(UHD_LOG_MIN_LEVEL "debug" CACHE STRING "Set UHD log level to {trace, debug, info, warning, error, fatal}") + set(UHD_LOG_CONSOLE_DISABLE "OFF" CACHE BOOL "Disable UHD logging to stderr") + set(UHD_LOG_FILE_LEVEL "info" CACHE STRING "SET UHD file logging level to {trace, debug, info, warning, error, fatal}") + set(UHD_LOG_CONSOLE_LEVEL "info" CACHE STRING "SET UHD file logging level to {trace, debug, info, warning, error, fatal}") +endif() -FUNCTION(UHD_LOG_LEVEL_CONVERT ARG1 ARG2) +function(UHD_LOG_LEVEL_CONVERT ARG1 ARG2) string(TOLOWER "${ARG1}" LOG_LEVEL_LOWER) - IF(LOG_LEVEL_LOWER STREQUAL "trace") - ADD_DEFINITIONS(-D${ARG2}=0) - ELSEIF(LOG_LEVEL_LOWER STREQUAL "debug") - ADD_DEFINITIONS(-D${ARG2}=1) - ELSEIF(LOG_LEVEL_LOWER STREQUAL "info") - ADD_DEFINITIONS(-D${ARG2}=2) - ELSEIF(LOG_LEVEL_LOWER STREQUAL "warning") - ADD_DEFINITIONS(-D${ARG2}=3) - ELSEIF(LOG_LEVEL_LOWER STREQUAL "error") - ADD_DEFINITIONS(-D${ARG2}=4) - ELSEIF(LOG_LEVEL_LOWER STREQUAL "fatal") - ADD_DEFINITIONS(-D${ARG2}=5) - ELSE() - ADD_DEFINITIONS(-D${ARG2}=${ARG1}) - ENDIF() -ENDFUNCTION() + if(LOG_LEVEL_LOWER STREQUAL "trace") + add_definitions(-D${ARG2}=0) + elseif(LOG_LEVEL_LOWER STREQUAL "debug") + add_definitions(-D${ARG2}=1) + elseif(LOG_LEVEL_LOWER STREQUAL "info") + add_definitions(-D${ARG2}=2) + elseif(LOG_LEVEL_LOWER STREQUAL "warning") + add_definitions(-D${ARG2}=3) + elseif(LOG_LEVEL_LOWER STREQUAL "error") + add_definitions(-D${ARG2}=4) + elseif(LOG_LEVEL_LOWER STREQUAL "fatal") + add_definitions(-D${ARG2}=5) + else() + add_definitions(-D${ARG2}=${ARG1}) + endif() +endfunction() UHD_LOG_LEVEL_CONVERT(${UHD_LOG_MIN_LEVEL} "UHD_LOG_MIN_LEVEL") UHD_LOG_LEVEL_CONVERT(${UHD_LOG_CONSOLE_LEVEL} "UHD_LOG_CONSOLE_LEVEL") UHD_LOG_LEVEL_CONVERT(${UHD_LOG_FILE_LEVEL} "UHD_LOG_FILE_LEVEL") -IF(UHD_LOG_CONSOLE_DISABLE) - ADD_DEFINITIONS(-DUHD_LOG_CONSOLE_DISABLE) -ELSE() - IF(UHD_LOG_CONSOLE_TIME) - ADD_DEFINITIONS(-DUHD_LOG_CONSOLE_TIME) - ENDIF() - IF(UHD_LOG_CONSOLE_THREAD) - ADD_DEFINITIONS(-DUHD_LOG_CONSOLE_THREAD) - ENDIF() - IF(UHD_LOG_CONSOLE_SRC) - ADD_DEFINITIONS(-DUHD_LOG_CONSOLE_SRC) - ENDIF() -ENDIF() +if(UHD_LOG_CONSOLE_DISABLE) + add_definitions(-DUHD_LOG_CONSOLE_DISABLE) +else() + if(UHD_LOG_CONSOLE_TIME) + add_definitions(-DUHD_LOG_CONSOLE_TIME) + endif() + if(UHD_LOG_CONSOLE_THREAD) + add_definitions(-DUHD_LOG_CONSOLE_THREAD) + endif() + if(UHD_LOG_CONSOLE_SRC) + add_definitions(-DUHD_LOG_CONSOLE_SRC) + endif() +endif() -SET(UHD_LOG_FASTPATH_DISABLE "OFF" CACHE BOOL "Disable printing of fastpath logging symbols to stderr (DOSU)") -IF(UHD_LOG_FASTPATH_DISABLE) - ADD_DEFINITIONS(-DUHD_LOG_FASTPATH_DISABLE) -ENDIF() +set(UHD_LOG_FASTPATH_DISABLE "OFF" CACHE BOOL "Disable printing of fastpath logging symbols to stderr (DOSU)") +if(UHD_LOG_FASTPATH_DISABLE) + add_definitions(-DUHD_LOG_FASTPATH_DISABLE) +endif() -IF(MSVC OR CYGWIN) - SET(UHD_LOG_CONSOLE_COLOR "OFF" CACHE BOOL "Enable color output on the terminal") -ELSE() - SET(UHD_LOG_CONSOLE_COLOR "ON" CACHE BOOL "Enable color output on the terminal") -ENDIF() +if(MSVC OR CYGWIN) + set(UHD_LOG_CONSOLE_COLOR "OFF" CACHE BOOL "Enable color output on the terminal") +else() + set(UHD_LOG_CONSOLE_COLOR "ON" CACHE BOOL "Enable color output on the terminal") +endif() -IF(UHD_LOG_CONSOLE_COLOR) - ADD_DEFINITIONS(-DUHD_LOG_CONSOLE_COLOR) -ENDIF() +if(UHD_LOG_CONSOLE_COLOR) + add_definitions(-DUHD_LOG_CONSOLE_COLOR) +endif() -SET(UHD_LOG_FILE "" CACHE FILE "Set UHD log file to a file in a existing directory") -IF(NOT UHD_LOG_FILE STREQUAL "") - ADD_DEFINITIONS(-DUHD_LOG_FILE=${UHD_LOG_FILE}) -ENDIF() +set(UHD_LOG_FILE "" CACHE FILE "Set UHD log file to a file in a existing directory") +if(NOT UHD_LOG_FILE STREQUAL "") + add_definitions(-DUHD_LOG_FILE=${UHD_LOG_FILE}) +endif() diff --git a/host/cmake/Modules/UHDPackage.cmake b/host/cmake/Modules/UHDPackage.cmake index 1ba981398..9c418f331 100644 --- a/host/cmake/Modules/UHDPackage.cmake +++ b/host/cmake/Modules/UHDPackage.cmake @@ -6,169 +6,169 @@ # ######################################################################## -INCLUDE(UHDVersion) #sets version information +include(UHDVersion) #sets version information -SET(UHD_RELEASE_MODE "${UHD_RELEASE_MODE}" CACHE BOOL "set UHD to release mode to build installers") +set(UHD_RELEASE_MODE "${UHD_RELEASE_MODE}" CACHE BOOL "set UHD to release mode to build installers") ######################################################################## # Setup additional defines for OS types ######################################################################## -IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") - SET(LINUX TRUE) -ENDIF() +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(LINUX TRUE) +endif() -IF(NOT CMAKE_CROSSCOMPILING AND LINUX AND EXISTS "/etc/debian_version") - SET(DEBIAN TRUE) -ENDIF() +if(NOT CMAKE_CROSSCOMPILING AND LINUX AND EXISTS "/etc/debian_version") + set(DEBIAN TRUE) +endif() -IF(NOT CMAKE_CROSSCOMPILING AND LINUX AND EXISTS "/etc/redhat-release") - SET(REDHAT TRUE) -ENDIF() +if(NOT CMAKE_CROSSCOMPILING AND LINUX AND EXISTS "/etc/redhat-release") + set(REDHAT TRUE) +endif() ######################################################################## # Set generator type for recognized systems ######################################################################## -IF(CPACK_GENERATOR) +if(CPACK_GENERATOR) #already set -ELSEIF(APPLE) - SET(CPACK_GENERATOR PackageMaker) -ELSEIF(WIN32) - SET(CPACK_GENERATOR NSIS) -ELSEIF(DEBIAN) - SET(CPACK_GENERATOR DEB) -ELSEIF(REDHAT) - SET(CPACK_GENERATOR RPM) -ELSE() - SET(CPACK_GENERATOR TGZ) -ENDIF() +elseif(APPLE) + set(CPACK_GENERATOR PackageMaker) +elseif(WIN32) + set(CPACK_GENERATOR NSIS) +elseif(DEBIAN) + set(CPACK_GENERATOR DEB) +elseif(REDHAT) + set(CPACK_GENERATOR RPM) +else() + set(CPACK_GENERATOR TGZ) +endif() ######################################################################## # Setup package file name ######################################################################## -IF(DEBIAN AND LIBUHD_PKG) - SET(CPACK_PACKAGE_FILE_NAME "libuhd${UHD_VERSION_MAJOR}_${UHD_VERSION}_${CMAKE_SYSTEM_PROCESSOR}" CACHE INTERNAL "") -ELSEIF(DEBIAN AND LIBUHDDEV_PKG) - SET(CPACK_PACKAGE_FILE_NAME "libuhd-dev_${UHD_VERSION}_${CMAKE_SYSTEM_PROCESSOR}" CACHE INTERNAL "") -ELSEIF(DEBIAN AND UHDHOST_PKG) - SET(CPACK_PACKAGE_FILE_NAME "uhd-host_${UHD_VERSION}_${CMAKE_SYSTEM_PROCESSOR}" CACHE INTERNAL "") -ELSE() - IF(DEBIAN OR REDHAT) - FIND_PROGRAM(LSB_RELEASE_EXECUTABLE lsb_release) - - IF(LSB_RELEASE_EXECUTABLE) +if(DEBIAN AND LIBUHD_PKG) + set(CPACK_PACKAGE_FILE_NAME "libuhd${UHD_VERSION_MAJOR}_${UHD_VERSION}_${CMAKE_SYSTEM_PROCESSOR}" CACHE INTERNAL "") +elseif(DEBIAN AND LIBUHDDEV_PKG) + set(CPACK_PACKAGE_FILE_NAME "libuhd-dev_${UHD_VERSION}_${CMAKE_SYSTEM_PROCESSOR}" CACHE INTERNAL "") +elseif(DEBIAN AND UHDHOST_PKG) + set(CPACK_PACKAGE_FILE_NAME "uhd-host_${UHD_VERSION}_${CMAKE_SYSTEM_PROCESSOR}" CACHE INTERNAL "") +else() + if(DEBIAN OR REDHAT) + find_program(LSB_RELEASE_EXECUTABLE lsb_release) + + if(LSB_RELEASE_EXECUTABLE) #extract system information by executing the commands - EXECUTE_PROCESS( + execute_process( COMMAND ${LSB_RELEASE_EXECUTABLE} --short --id OUTPUT_VARIABLE LSB_ID OUTPUT_STRIP_TRAILING_WHITESPACE ) - EXECUTE_PROCESS( + 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}" CACHE INTERNAL "") - ENDIF(LSB_RELEASE_EXECUTABLE) - ENDIF(DEBIAN OR REDHAT) -ENDIF(DEBIAN AND LIBUHD_PKG) + set(CPACK_PACKAGE_FILE_NAME "uhd_${UHD_VERSION}_${LSB_ID}-${LSB_RELEASE}-${CMAKE_SYSTEM_PROCESSOR}" CACHE INTERNAL "") + endif(LSB_RELEASE_EXECUTABLE) + endif(DEBIAN OR REDHAT) +endif(DEBIAN AND LIBUHD_PKG) -IF(${CPACK_GENERATOR} STREQUAL NSIS) +if(${CPACK_GENERATOR} STREQUAL NSIS) - ENABLE_LANGUAGE(C) + enable_language(C) include(CheckTypeSize) check_type_size("void*[8]" BIT_WIDTH BUILTIN_TYPES_ONLY) # If CMake option given, specify MSVC version in installer filename - IF(SPECIFY_MSVC_VERSION) - IF(MSVC90) # Visual Studio 2008 (9.0) - SET(MSVC_VERSION "VS2008") - ELSEIF(MSVC10) # Visual Studio 2010 (10.0) - SET(MSVC_VERSION "VS2010") - ELSEIF(MSVC11) # Visual Studio 2012 (11.0) - SET(MSVC_VERSION "VS2012") - ELSEIF(MSVC12) # Visual Studio 2013 (12.0) - SET(MSVC_VERSION "VS2013") - ELSEIF(MSVC14) # Visual Studio 2015 (14.0) - SET(MSVC_VERSION "VS2015") - ENDIF() - SET(CPACK_PACKAGE_FILE_NAME "uhd_${UHD_VERSION}_Win${BIT_WIDTH}_${MSVC_VERSION}" CACHE INTERNAL "") - ELSE() - SET(CPACK_PACKAGE_FILE_NAME "uhd_${UHD_VERSION}_Win${BIT_WIDTH}" CACHE INTERNAL "") - ENDIF(SPECIFY_MSVC_VERSION) - - SET(CPACK_PACKAGE_INSTALL_DIRECTORY "${CMAKE_PROJECT_NAME}") -ENDIF() + if(SPECIFY_MSVC_VERSION) + if(MSVC90) # Visual Studio 2008 (9.0) + set(MSVC_VERSION "VS2008") + elseif(MSVC10) # Visual Studio 2010 (10.0) + set(MSVC_VERSION "VS2010") + elseif(MSVC11) # Visual Studio 2012 (11.0) + set(MSVC_VERSION "VS2012") + elseif(MSVC12) # Visual Studio 2013 (12.0) + set(MSVC_VERSION "VS2013") + elseif(MSVC14) # Visual Studio 2015 (14.0) + set(MSVC_VERSION "VS2015") + endif() + set(CPACK_PACKAGE_FILE_NAME "uhd_${UHD_VERSION}_Win${BIT_WIDTH}_${MSVC_VERSION}" CACHE INTERNAL "") + else() + set(CPACK_PACKAGE_FILE_NAME "uhd_${UHD_VERSION}_Win${BIT_WIDTH}" CACHE INTERNAL "") + endif(SPECIFY_MSVC_VERSION) + + set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CMAKE_PROJECT_NAME}") +endif() ######################################################################## # Setup CPack General ######################################################################## -SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Ettus Research - USRP Hardware Driver") -SET(CPACK_PACKAGE_VENDOR "Ettus Research (National Instruments)") -SET(CPACK_PACKAGE_CONTACT "Ettus Research <support@ettus.com>") -SET(CPACK_PACKAGE_VERSION "${UHD_VERSION}") -SET(CPACK_RESOURCE_FILE_WELCOME ${CMAKE_SOURCE_DIR}/README.md) -SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE) +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Ettus Research - USRP Hardware Driver") +set(CPACK_PACKAGE_VENDOR "Ettus Research (National Instruments)") +set(CPACK_PACKAGE_CONTACT "Ettus Research <support@ettus.com>") +set(CPACK_PACKAGE_VERSION "${UHD_VERSION}") +set(CPACK_RESOURCE_FILE_WELCOME ${CMAKE_SOURCE_DIR}/README.md) +set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE) ######################################################################## # Setup CPack Source ######################################################################## -SET(CPACK_SOURCE_PACKAGE_FILE_NAME "uhd-${UHD_VERSION}" CACHE INTERNAL "") -SET(CPACK_SOURCE_IGNORE_FILES "\\\\.git*;\\\\.swp$") +set(CPACK_SOURCE_PACKAGE_FILE_NAME "uhd-${UHD_VERSION}" CACHE INTERNAL "") +set(CPACK_SOURCE_IGNORE_FILES "\\\\.git*;\\\\.swp$") ######################################################################## # Setup CPack Components ######################################################################## -SET(CPACK_COMPONENT_LIBRARIES_GROUP "Development") -SET(CPACK_COMPONENT_PYTHONAPI_GROUP "Development") -SET(CPACK_COMPONENT_HEADERS_GROUP "Development") -SET(CPACK_COMPONENT_UTILITIES_GROUP "Runtime") -SET(CPACK_COMPONENT_EXAMPLES_GROUP "Runtime") -SET(CPACK_COMPONENT_MANUAL_GROUP "Documentation") -SET(CPACK_COMPONENT_DOXYGEN_GROUP "Documentation") -SET(CPACK_COMPONENT_README_GROUP "Documentation") - -SET(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries") -SET(CPACK_COMPONENT_PYTHONAPI_DISPLAY_NAME "UHD Python API") -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_MANUAL_DISPLAY_NAME "Manual") -SET(CPACK_COMPONENT_DOXYGEN_DISPLAY_NAME "Doxygen") -SET(CPACK_COMPONENT_README_DISPLAY_NAME "Readme") -SET(CPACK_COMPONENT_IMAGES_DISPLAY_NAME "Images") - -SET(CPACK_COMPONENT_LIBRARIES_DESCRIPTION "Dynamic link library") -SET(CPACK_COMPONENT_PYTHONAPI_DESCRIPTION "UHD Python API") -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_MANUAL_DESCRIPTION "Manual/application notes (rst and html)") -SET(CPACK_COMPONENT_DOXYGEN_DESCRIPTION "API documentation (html)") -SET(CPACK_COMPONENT_README_DESCRIPTION "Readme files (txt)") -SET(CPACK_COMPONENT_IMAGES_DESCRIPTION "FPGA and firmware images") - -SET(CPACK_COMPONENT_README_REQUIRED TRUE) - -SET(CPACK_COMPONENT_UTILITIES_DEPENDS libraries) -SET(CPACK_COMPONENT_EXAMPLES_DEPENDS libraries) -SET(CPACK_COMPONENT_TESTS_DEPENDS libraries) - -SET(CPACK_COMPONENTS_ALL libraries pythonapi headers utilities examples manual doxygen readme images) +set(CPACK_COMPONENT_LIBRARIES_GROUP "Development") +set(CPACK_COMPONENT_PYTHONAPI_GROUP "Development") +set(CPACK_COMPONENT_HEADERS_GROUP "Development") +set(CPACK_COMPONENT_UTILITIES_GROUP "Runtime") +set(CPACK_COMPONENT_EXAMPLES_GROUP "Runtime") +set(CPACK_COMPONENT_MANUAL_GROUP "Documentation") +set(CPACK_COMPONENT_DOXYGEN_GROUP "Documentation") +set(CPACK_COMPONENT_README_GROUP "Documentation") + +set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries") +set(CPACK_COMPONENT_PYTHONAPI_DISPLAY_NAME "UHD Python API") +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_MANUAL_DISPLAY_NAME "Manual") +set(CPACK_COMPONENT_DOXYGEN_DISPLAY_NAME "Doxygen") +set(CPACK_COMPONENT_README_DISPLAY_NAME "Readme") +set(CPACK_COMPONENT_IMAGES_DISPLAY_NAME "Images") + +set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION "Dynamic link library") +set(CPACK_COMPONENT_PYTHONAPI_DESCRIPTION "UHD Python API") +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_MANUAL_DESCRIPTION "Manual/application notes (rst and html)") +set(CPACK_COMPONENT_DOXYGEN_DESCRIPTION "API documentation (html)") +set(CPACK_COMPONENT_README_DESCRIPTION "Readme files (txt)") +set(CPACK_COMPONENT_IMAGES_DESCRIPTION "FPGA and firmware images") + +set(CPACK_COMPONENT_README_REQUIRED TRUE) + +set(CPACK_COMPONENT_UTILITIES_DEPENDS libraries) +set(CPACK_COMPONENT_EXAMPLES_DEPENDS libraries) +set(CPACK_COMPONENT_TESTS_DEPENDS libraries) + +set(CPACK_COMPONENTS_ALL libraries pythonapi headers utilities examples manual doxygen readme images) ######################################################################## # Setup CPack Debian ######################################################################## -SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libboost-all-dev, python-requests") -SET(CPACK_DEBIAN_PACKAGE_RECOMMENDS "python, python-tk") -FOREACH(filename preinst postinst prerm postrm) - LIST(APPEND CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA ${CMAKE_BINARY_DIR}/debian/${filename}) - FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/debian) - CONFIGURE_FILE( +set(CPACK_DEBIAN_PACKAGE_DEPENDS "libboost-all-dev, python-requests") +set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "python, python-tk") +foreach(filename preinst postinst prerm postrm) + list(APPEND CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA ${CMAKE_BINARY_DIR}/debian/${filename}) + file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/debian) + configure_file( ${CMAKE_SOURCE_DIR}/cmake/debian/${filename}.in ${CMAKE_BINARY_DIR}/debian/${filename} @ONLY) -ENDFOREACH(filename) -CONFIGURE_FILE( +endforeach(filename) +configure_file( ${CMAKE_SOURCE_DIR}/cmake/debian/watch ${CMAKE_BINARY_DIR}/debian/watch @ONLY) @@ -176,37 +176,37 @@ CONFIGURE_FILE( ######################################################################## # Setup CPack RPM ######################################################################## -SET(CPACK_RPM_PACKAGE_REQUIRES "boost-devel, python-requests") +set(CPACK_RPM_PACKAGE_REQUIRES "boost-devel, python-requests") -FOREACH(filename post_install post_uninstall pre_install pre_uninstall) - STRING(TOUPPER ${filename} filename_upper) - LIST(APPEND CPACK_RPM_${filename_upper}_SCRIPT_FILE ${CMAKE_BINARY_DIR}/redhat/${filename}) - FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/redhat) - CONFIGURE_FILE( +foreach(filename post_install post_uninstall pre_install pre_uninstall) + string(TOUPPER ${filename} filename_upper) + list(APPEND CPACK_RPM_${filename_upper}_SCRIPT_FILE ${CMAKE_BINARY_DIR}/redhat/${filename}) + file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/redhat) + configure_file( ${CMAKE_SOURCE_DIR}/cmake/redhat/${filename}.in ${CMAKE_BINARY_DIR}/redhat/${filename} @ONLY) -ENDFOREACH(filename) +endforeach(filename) ######################################################################## # Setup CPack NSIS ######################################################################## -SET(CPACK_NSIS_MODIFY_PATH ON) +set(CPACK_NSIS_MODIFY_PATH ON) -SET(HLKM_ENV "\\\"SYSTEM\\\\CurrentControlSet\\\\Control\\\\Session Manager\\\\Environment\\\"") +set(HLKM_ENV "\\\"SYSTEM\\\\CurrentControlSet\\\\Control\\\\Session Manager\\\\Environment\\\"") -SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS " +set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS " WriteRegStr HKLM ${HLKM_ENV} \\\"UHD_PKG_PATH\\\" \\\"$INSTDIR\\\" ") -SET(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS " +set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS " DeleteRegValue HKLM ${HLKM_ENV} \\\"UHD_PKG_PATH\\\" ") -IF(WIN32) +if(WIN32) #Install necessary runtime DLL's - INCLUDE(InstallRequiredSystemLibraries) -ENDIF(WIN32) + include(InstallRequiredSystemLibraries) +endif(WIN32) ######################################################################## -INCLUDE(CPack) #include after setting vars +include(CPack) #include after setting vars diff --git a/host/cmake/Modules/UHDPython.cmake b/host/cmake/Modules/UHDPython.cmake index f8f3686c8..fb5874ada 100644 --- a/host/cmake/Modules/UHDPython.cmake +++ b/host/cmake/Modules/UHDPython.cmake @@ -5,58 +5,58 @@ # SPDX-License-Identifier: GPL-3.0-or-later # -IF(NOT DEFINED INCLUDED_UHD_PYTHON_CMAKE) -SET(INCLUDED_UHD_PYTHON_CMAKE TRUE) +if(NOT DEFINED INCLUDED_UHD_PYTHON_CMAKE) +set(INCLUDED_UHD_PYTHON_CMAKE TRUE) ######################################################################## # Setup Python ######################################################################## -MESSAGE(STATUS "") -MESSAGE(STATUS "Configuring the python interpreter...") +message(STATUS "") +message(STATUS "Configuring the python interpreter...") #this allows the user to override PYTHON_EXECUTABLE -IF(PYTHON_EXECUTABLE) +if(PYTHON_EXECUTABLE) - SET(PYTHONINTERP_FOUND TRUE) + set(PYTHONINTERP_FOUND TRUE) #otherwise if not set, try to automatically find it -ELSE(PYTHON_EXECUTABLE) +else(PYTHON_EXECUTABLE) #use the built-in find script - IF(ENABLE_PYTHON3) - FIND_PACKAGE(PythonInterp 3.0) - ELSE(ENABLE_PYTHON3) - FIND_PACKAGE(PythonInterp 2.0) - ENDIF(ENABLE_PYTHON3) + if(ENABLE_PYTHON3) + find_package(PythonInterp 3.0) + else(ENABLE_PYTHON3) + find_package(PythonInterp 2.0) + endif(ENABLE_PYTHON3) #and if that fails use the find program routine - IF(NOT PYTHONINTERP_FOUND) - IF(ENABLE_PYTHON3) - FIND_PROGRAM(PYTHON_EXECUTABLE NAMES python3 python3.5 python3.6) - ELSE(ENABLE_PYTHON3) - FIND_PROGRAM(PYTHON_EXECUTABLE NAMES python2 python2.7) - ENDIF(ENABLE_PYTHON3) + if(NOT PYTHONINTERP_FOUND) + if(ENABLE_PYTHON3) + find_program(PYTHON_EXECUTABLE NAMES python3 python3.5 python3.6) + else(ENABLE_PYTHON3) + find_program(PYTHON_EXECUTABLE NAMES python2 python2.7) + endif(ENABLE_PYTHON3) - IF(PYTHON_EXECUTABLE) - SET(PYTHONINTERP_FOUND TRUE) - ENDIF(PYTHON_EXECUTABLE) - ENDIF(NOT PYTHONINTERP_FOUND) + if(PYTHON_EXECUTABLE) + set(PYTHONINTERP_FOUND TRUE) + endif(PYTHON_EXECUTABLE) + endif(NOT PYTHONINTERP_FOUND) -ENDIF(PYTHON_EXECUTABLE) +endif(PYTHON_EXECUTABLE) #make the path to the executable appear in the cmake gui -SET(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE FILEPATH "python interpreter") +set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE FILEPATH "python interpreter") -MESSAGE(STATUS "Python interpreter: ${PYTHON_EXECUTABLE}") -MESSAGE(STATUS "Override with: -DPYTHON_EXECUTABLE=<path-to-python>") +message(STATUS "Python interpreter: ${PYTHON_EXECUTABLE}") +message(STATUS "Override with: -DPYTHON_EXECUTABLE=<path-to-python>") -IF(NOT PYTHONINTERP_FOUND) - MESSAGE(FATAL_ERROR "Error: Python interpreter required by the build system.") -ENDIF(NOT PYTHONINTERP_FOUND) +if(NOT PYTHONINTERP_FOUND) + message(FATAL_ERROR "Error: Python interpreter 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( +macro(PYTHON_CHECK_MODULE desc mod cmd have) + message(STATUS "") + message(STATUS "Python checking for ${desc}") + execute_process( COMMAND ${PYTHON_EXECUTABLE} -c " ######################################### from distutils.version import LooseVersion @@ -68,19 +68,19 @@ exit(0) #########################################" RESULT_VARIABLE ${have} ) - IF(${have} EQUAL 0) - MESSAGE(STATUS "Python checking for ${desc} - found") - SET(${have} TRUE) - ELSEIF(${have} EQUAL 1) - MESSAGE(STATUS "Python checking for ${desc} - \"import ${mod}\" failed") - SET(${have} FALSE) - ELSEIF(${have} EQUAL 2) - MESSAGE(STATUS "Python checking for ${desc} - \"assert ${cmd}\" failed") - SET(${have} FALSE) - ELSE() - MESSAGE(STATUS "Python checking for ${desc} - unknown error") - SET(${have} FALSE) - ENDIF() -ENDMACRO(PYTHON_CHECK_MODULE) + if(${have} EQUAL 0) + message(STATUS "Python checking for ${desc} - found") + set(${have} TRUE) + elseif(${have} EQUAL 1) + message(STATUS "Python checking for ${desc} - \"import ${mod}\" failed") + set(${have} FALSE) + elseif(${have} EQUAL 2) + message(STATUS "Python checking for ${desc} - \"assert ${cmd}\" failed") + set(${have} FALSE) + else() + message(STATUS "Python checking for ${desc} - unknown error") + set(${have} FALSE) + endif() +endmacro(PYTHON_CHECK_MODULE) -ENDIF(NOT DEFINED INCLUDED_UHD_PYTHON_CMAKE) +endif(NOT DEFINED INCLUDED_UHD_PYTHON_CMAKE) diff --git a/host/cmake/Modules/UHDUnitTest.cmake b/host/cmake/Modules/UHDUnitTest.cmake index db245484c..7937db4d3 100644 --- a/host/cmake/Modules/UHDUnitTest.cmake +++ b/host/cmake/Modules/UHDUnitTest.cmake @@ -36,8 +36,8 @@ function(UHD_ADD_TEST test_name) #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}") + #add_test(${ARGV}) + #set_tests_properties(${test_name} PROPERTIES ENVIRONMENT "${environs}") if(UNIX) set(LD_PATH_VAR "LD_LIBRARY_PATH") diff --git a/host/cmake/Modules/UHDVersion.cmake b/host/cmake/Modules/UHDVersion.cmake index 2cee7db6f..0021ddec9 100644 --- a/host/cmake/Modules/UHDVersion.cmake +++ b/host/cmake/Modules/UHDVersion.cmake @@ -6,8 +6,8 @@ # ######################################################################## -INCLUDE(UHDPython) #requires python for parsing -FIND_PACKAGE(Git QUIET) +include(UHDPython) #requires python for parsing +find_package(Git QUIET) ######################################################################## # Setup Version Numbers @@ -17,64 +17,64 @@ FIND_PACKAGE(Git QUIET) # - Increment patch for bugfixes and docs # - set UHD_VERSION_DEVEL to true for master and development branches ######################################################################## -SET(UHD_VERSION_MAJOR 3) -SET(UHD_VERSION_API 14) -SET(UHD_VERSION_ABI 0) -SET(UHD_VERSION_PATCH 0) -SET(UHD_VERSION_DEVEL TRUE) +set(UHD_VERSION_MAJOR 3) +set(UHD_VERSION_API 14) +set(UHD_VERSION_ABI 0) +set(UHD_VERSION_PATCH 0) +set(UHD_VERSION_DEVEL TRUE) ######################################################################## # If we're on a development branch, we skip the patch version ######################################################################## -IF(DEFINED UHD_VERSION_PATCH_OVERRIDE) - SET(UHD_VERSION_DEVEL FALSE) - SET(UHD_VERSION_PATCH ${UHD_VERSION_PATCH_OVERRIDE}) -ENDIF(DEFINED UHD_VERSION_PATCH_OVERRIDE) -IF(NOT DEFINED UHD_VERSION_DEVEL) - SET(UHD_VERSION_DEVEL FALSE) -ENDIF(NOT DEFINED UHD_VERSION_DEVEL) -SET(UHD_GIT_BRANCH "") -IF(GIT_FOUND) - EXECUTE_PROCESS( +if(DEFINED UHD_VERSION_PATCH_OVERRIDE) + set(UHD_VERSION_DEVEL FALSE) + set(UHD_VERSION_PATCH ${UHD_VERSION_PATCH_OVERRIDE}) +endif(DEFINED UHD_VERSION_PATCH_OVERRIDE) +if(NOT DEFINED UHD_VERSION_DEVEL) + set(UHD_VERSION_DEVEL FALSE) +endif(NOT DEFINED UHD_VERSION_DEVEL) +set(UHD_GIT_BRANCH "") +if(GIT_FOUND) + execute_process( WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD OUTPUT_VARIABLE _git_branch OUTPUT_STRIP_TRAILING_WHITESPACE RESULT_VARIABLE _git_branch_result ) - IF(_git_branch_result EQUAL 0) - SET(UHD_GIT_BRANCH ${_git_branch}) - IF(UHD_GIT_BRANCH MATCHES "^UHD-") - MESSAGE(STATUS "Operating on release branch (${UHD_GIT_BRANCH}).") - SET(UHD_VERSION_DEVEL FALSE) - ELSEIF(UHD_GIT_BRANCH STREQUAL "master") - MESSAGE(STATUS "Operating on master branch.") - SET(UHD_VERSION_DEVEL TRUE) - ELSE() - MESSAGE(STATUS "Working off of feature or development branch. Updating version number.") - EXECUTE_PROCESS( + if(_git_branch_result EQUAL 0) + set(UHD_GIT_BRANCH ${_git_branch}) + if(UHD_GIT_BRANCH MATCHES "^UHD-") + message(STATUS "Operating on release branch (${UHD_GIT_BRANCH}).") + set(UHD_VERSION_DEVEL FALSE) + elseif(UHD_GIT_BRANCH STREQUAL "master") + message(STATUS "Operating on master branch.") + set(UHD_VERSION_DEVEL TRUE) + else() + message(STATUS "Working off of feature or development branch. Updating version number.") + execute_process( COMMAND ${PYTHON_EXECUTABLE} -c "print('${_git_branch}'.replace('/', '-'))" OUTPUT_VARIABLE _git_safe_branch OUTPUT_STRIP_TRAILING_WHITESPACE ) - SET(UHD_VERSION_PATCH ${_git_safe_branch}) - SET(UHD_VERSION_DEVEL TRUE) - ENDIF() - ELSE() - MESSAGE(STATUS "Could not determine git branch. Probably building from tarball.") - ENDIF() -ELSE(GIT_FOUND) - MESSAGE(WARNING "Could not detect git executable! Could not determine exact version of UHD!") -ENDIF(GIT_FOUND) -IF(DEFINED UHD_GIT_BRANCH_OVERRIDE) - MESSAGE(STATUS "Overriding auto-detected git branch and setting to: ${UHD_GIT_BRANCH_OVERRIDE}") - SET(UHD_GIT_BRANCH ${UHD_GIT_BRANCH_OVERRIDE}) -ENDIF(DEFINED UHD_GIT_BRANCH_OVERRIDE) + set(UHD_VERSION_PATCH ${_git_safe_branch}) + set(UHD_VERSION_DEVEL TRUE) + endif() + else() + message(STATUS "Could not determine git branch. Probably building from tarball.") + endif() +else(GIT_FOUND) + message(WARNING "Could not detect git executable! Could not determine exact version of UHD!") +endif(GIT_FOUND) +if(DEFINED UHD_GIT_BRANCH_OVERRIDE) + message(STATUS "Overriding auto-detected git branch and setting to: ${UHD_GIT_BRANCH_OVERRIDE}") + set(UHD_GIT_BRANCH ${UHD_GIT_BRANCH_OVERRIDE}) +endif(DEFINED UHD_GIT_BRANCH_OVERRIDE) ######################################################################## # Version information discovery through git log ######################################################################## #grab the git ref id for the current head -EXECUTE_PROCESS( +execute_process( WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} describe --always --abbrev=8 --long OUTPUT_VARIABLE _git_describe OUTPUT_STRIP_TRAILING_WHITESPACE @@ -82,9 +82,9 @@ EXECUTE_PROCESS( ) #only set the build info on success -IF(_git_describe_result EQUAL 0) - IF(NOT UHD_GIT_COUNT) - EXECUTE_PROCESS( +if(_git_describe_result EQUAL 0) + if(NOT UHD_GIT_COUNT) + execute_process( WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ${PYTHON_EXECUTABLE} -c " try: @@ -94,9 +94,9 @@ except IndexError: " OUTPUT_VARIABLE UHD_GIT_COUNT OUTPUT_STRIP_TRAILING_WHITESPACE ) - ENDIF() - IF(NOT UHD_GIT_HASH) - EXECUTE_PROCESS( + endif() + if(NOT UHD_GIT_HASH) + execute_process( WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ${PYTHON_EXECUTABLE} -c " try: @@ -106,42 +106,42 @@ except IndexError: " OUTPUT_VARIABLE UHD_GIT_HASH OUTPUT_STRIP_TRAILING_WHITESPACE ) - ENDIF() -ENDIF() + endif() +endif() ## Set default values if all fails. Make sure they're identical to the ones above. -IF(NOT UHD_GIT_COUNT) - SET(UHD_GIT_COUNT "0") -ENDIF() +if(NOT UHD_GIT_COUNT) + set(UHD_GIT_COUNT "0") +endif() -IF(NOT UHD_GIT_HASH) - SET(UHD_GIT_HASH "unknown") -ENDIF() +if(NOT UHD_GIT_HASH) + set(UHD_GIT_HASH "unknown") +endif() -IF(UHD_RELEASE_MODE) - SET(UHD_GIT_HASH ${UHD_RELEASE_MODE}) +if(UHD_RELEASE_MODE) + set(UHD_GIT_HASH ${UHD_RELEASE_MODE}) #Ignore UHD_GIT_COUNT in UHD_VERSION if the string 'release' is in UHD_RELEASE_MODE - EXECUTE_PROCESS( + execute_process( WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ${PYTHON_EXECUTABLE} -c "print ('release' in '${UHD_RELEASE_MODE}') or ('rc' in '${UHD_RELEASE_MODE}')" OUTPUT_VARIABLE TRIM_UHD_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE ) -ENDIF() +endif() ######################################################################## # Define the derived version variables: -IF(DEFINED UHD_VERSION) - SET(UHD_VERSION "${UHD_VERSION}" CACHE STRING "Set UHD_VERSION to a custom value") -ELSEIF(TRIM_UHD_VERSION STREQUAL "True") - SET(UHD_VERSION "${UHD_VERSION_MAJOR}.${UHD_VERSION_API}.${UHD_VERSION_ABI}.${UHD_VERSION_PATCH}-${UHD_GIT_HASH}") -ELSE() - SET(UHD_VERSION "${UHD_VERSION_MAJOR}.${UHD_VERSION_API}.${UHD_VERSION_ABI}.${UHD_VERSION_PATCH}-${UHD_GIT_COUNT}-${UHD_GIT_HASH}") -ENDIF() -IF(DEFINED UHD_ABI_VERSION) - SET(UHD_ABI_VERSION "${UHD_ABI_VERSION}" +if(DEFINED UHD_VERSION) + set(UHD_VERSION "${UHD_VERSION}" CACHE STRING "Set UHD_VERSION to a custom value") +elseif(TRIM_UHD_VERSION STREQUAL "True") + set(UHD_VERSION "${UHD_VERSION_MAJOR}.${UHD_VERSION_API}.${UHD_VERSION_ABI}.${UHD_VERSION_PATCH}-${UHD_GIT_HASH}") +else() + set(UHD_VERSION "${UHD_VERSION_MAJOR}.${UHD_VERSION_API}.${UHD_VERSION_ABI}.${UHD_VERSION_PATCH}-${UHD_GIT_COUNT}-${UHD_GIT_HASH}") +endif() +if(DEFINED UHD_ABI_VERSION) + set(UHD_ABI_VERSION "${UHD_ABI_VERSION}" CACHE STRING "Set UHD_ABI_VERSION to a custom value") -ELSE() - SET(UHD_ABI_VERSION "${UHD_VERSION_MAJOR}.${UHD_VERSION_API}.${UHD_VERSION_ABI}") -ENDIF() +else() + set(UHD_ABI_VERSION "${UHD_VERSION_MAJOR}.${UHD_VERSION_API}.${UHD_VERSION_ABI}") +endif() |