From 933eca17b14cba099eb2f3ee8c31f369b99e6b39 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Fri, 6 Mar 2020 12:53:10 -0800 Subject: cmake: Add CMakeRC module and ::rc namespace This module allows to add binary files into UHD (e.g., for cal data storage) in a platform-independent way. The upstream CMakeRC.cmake is modified in the following way to allow linkage against a shared object: ```diff # Generate the actual static library. Each source file is just a single file # with a character array compiled in containing the contents of the # corresponding resource file. add_library(${name} STATIC ${libcpp}) set_property(TARGET ${name} PROPERTY CMRC_LIBDIR "${libdir}") set_property(TARGET ${name} PROPERTY CMRC_NAMESPACE "${ARG_NAMESPACE}") target_link_libraries(${name} PUBLIC cmrc::base) set_property(TARGET ${name} PROPERTY CMRC_IS_RESOURCE_LIBRARY TRUE) + set_property(TARGET ${name} PROPERTY POSITION_INDEPENDENT_CODE ON) ``` This forces the -fPIC flag for the static object that CMakeRC generates, allowing to link it into a shared object file. The version of CMakeRC used is: a7e355290, cloned from git@github.com:vector-of-bool/cmrc.git. --- host/lib/CMakeLists.txt | 7 ++++++- host/lib/rc/CMakeLists.txt | 11 +++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 host/lib/rc/CMakeLists.txt (limited to 'host/lib') diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt index 18bc47f54..4d747c9c7 100644 --- a/host/lib/CMakeLists.txt +++ b/host/lib/CMakeLists.txt @@ -130,6 +130,11 @@ if(ENABLE_C_API) ) endif(ENABLE_C_API) +######################################################################## +# Add common resource compiler subdirectory +######################################################################## +add_subdirectory(rc) + ######################################################################## # Add DLL resource file to Windows build ######################################################################## @@ -172,7 +177,7 @@ if(ENABLE_MPMD) list(APPEND libuhd_sources $) endif() add_library(uhd SHARED ${libuhd_sources}) -target_link_libraries(uhd ${Boost_LIBRARIES} ${libuhd_libs}) +target_link_libraries(uhd ${Boost_LIBRARIES} ${libuhd_libs} uhd_rc) set_target_properties(uhd PROPERTIES DEFINE_SYMBOL "UHD_DLL_EXPORTS") if(NOT LIBUHDDEV_PKG) set_target_properties(uhd PROPERTIES SOVERSION "${UHD_ABI_VERSION}") diff --git a/host/lib/rc/CMakeLists.txt b/host/lib/rc/CMakeLists.txt new file mode 100644 index 000000000..1595e7e85 --- /dev/null +++ b/host/lib/rc/CMakeLists.txt @@ -0,0 +1,11 @@ +# +# Copyright 2020 Ettus Research, a National Instruments Brand +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +include(CMakeRC) +cmrc_add_resource_library(uhd-resources + ALIAS uhd_rc + NAMESPACE rc +) -- cgit v1.2.3