aboutsummaryrefslogtreecommitdiffstats
path: root/host/cmake
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2015-01-19 20:31:15 +0100
committerMartin Braun <martin.braun@ettus.com>2015-01-19 20:31:15 +0100
commitadb20365db6dec7c7a4e23cd8b2feb78e83a7a33 (patch)
tree07b8ba0fdcd0ed1e5308d73852fc7bb5ce0b4770 /host/cmake
parent9e6ff291b464f7ae7cbc7abfe29b34550badeb74 (diff)
parent2a49dbbc8acdd601eb4d541b43bcfa6724333785 (diff)
downloaduhd-adb20365db6dec7c7a4e23cd8b2feb78e83a7a33.tar.gz
uhd-adb20365db6dec7c7a4e23cd8b2feb78e83a7a33.tar.bz2
uhd-adb20365db6dec7c7a4e23cd8b2feb78e83a7a33.zip
Merge branch 'maint'
Conflicts: host/include/uhd/types/CMakeLists.txt
Diffstat (limited to 'host/cmake')
-rw-r--r--host/cmake/Modules/UHDConfig.cmake.in (renamed from host/cmake/Modules/UHDConfig.cmake)25
1 files changed, 25 insertions, 0 deletions
diff --git a/host/cmake/Modules/UHDConfig.cmake b/host/cmake/Modules/UHDConfig.cmake.in
index cf841cc85..78f01706f 100644
--- a/host/cmake/Modules/UHDConfig.cmake
+++ b/host/cmake/Modules/UHDConfig.cmake.in
@@ -60,6 +60,19 @@ ENDIF()
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()
+ # This is set during build of UHD to match the installed version:
+ 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.
@@ -80,6 +93,18 @@ FIND_LIBRARY(
/usr/lib
)
+# 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)
+ # This works for gcc and Clang:
+ 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)
+
IF(UHD_LIBRARIES AND UHD_INCLUDE_DIRS)
INCLUDE(FindPackageHandleStandardArgs)