diff options
author | Michael Dickens <michael.dickens@ettus.com> | 2014-09-24 13:35:24 -0400 |
---|---|---|
committer | Johnathan Corgan <johnathan@corganlabs.com> | 2014-10-13 13:36:02 -0700 |
commit | 037ddca197674da611f2a8ffceab45e9134eb9bc (patch) | |
tree | d9886cdae709ded8047937310bbbe71da8d75e93 /cmake/Modules | |
parent | 687c637fd80a926fb13ef5285991e4fdee50bd1b (diff) |
cmake: FindUHD: add in checks to see whether UHDConfig*.cmake were used via the ENV variables; CACHE variables are unreliable from withing UHDConfig*.cmake for some reason. In the case where UHDConfig*.cmake were used, do not do checking for UHD here. Print out appropriate errors if REQUIRED is set.
Diffstat (limited to 'cmake/Modules')
-rw-r--r-- | cmake/Modules/FindUHD.cmake | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/cmake/Modules/FindUHD.cmake b/cmake/Modules/FindUHD.cmake index cfb89b11ce..21cb0942c3 100644 --- a/cmake/Modules/FindUHD.cmake +++ b/cmake/Modules/FindUHD.cmake @@ -2,7 +2,7 @@ # Find the library for the USRP Hardware Driver ######################################################################## -# make this file non-reentrant +# make this file non-reentrant within the current context if(__INCLUDED_FIND_UHD_CMAKE) return() endif() @@ -20,6 +20,12 @@ unset(CMAKE_MODULE_PATH) # handle REQUIRED internally later unset(UHD_FOUND) +# set that UHDConfig.cmake was not used. Have to use the ENV, since +# UHDConfigVersion does not allow CACHE changes and UHDConfig might +# not allow CACHE changes. +set(ENV{UHD_CONFIG_USED} FALSE) +set(ENV{UHD_CONFIG_VERSION_USED} FALSE) + # was the version specified? unset(LOCAL_UHD_FIND_VERSION) if(UHD_FIND_VERSION) @@ -42,10 +48,10 @@ find_package( # restore CMAKE_MODULE_PATH set(CMAKE_MODULE_PATH ${SAVED_CMAKE_MODULE_PATH}) -# check if UHD was found above -if(NOT UHD_FOUND) +# check if UHDConfig was used above +if(NOT $ENV{UHD_CONFIG_VERSION_USED}) - # Not found; try the "old" method (not as robust) + # Not used; try the "old" method (not as robust) include(FindPkgConfig) pkg_check_modules(PC_UHD uhd) @@ -67,7 +73,7 @@ if(NOT UHD_FOUND) PATHS /usr/local/lib /usr/lib ) -endif(NOT UHD_FOUND) +endif(NOT $ENV{UHD_CONFIG_VERSION_USED}) if(UHD_LIBRARIES AND UHD_INCLUDE_DIRS) @@ -79,7 +85,9 @@ if(UHD_LIBRARIES AND UHD_INCLUDE_DIRS) mark_as_advanced(UHD_LIBRARIES UHD_INCLUDE_DIRS) elseif(UHD_FIND_REQUIRED) - - message(FATAL_ERROR "UHD is required, but was not found.") - + if($ENV{UHD_CONFIG_VERSION_USED} AND NOT $ENV{UHD_CONFIG_USED}) + message(FATAL_ERROR "The found UHD version ($ENV{UHD_PACKAGE_VERSION}) is not compatible with the version required (${UHD_FIND_VERSION}).") + else() + message(FATAL_ERROR "UHD is required, but was not found.") + endif() endif() |