Skip to content

Commit d447a2e

Browse files
author
Dimitri Stolnikov
committed
cmake: include resource file for MSVC builds
1 parent 6ee5573 commit d447a2e

File tree

2 files changed

+70
-26
lines changed

2 files changed

+70
-26
lines changed

Diff for: src/CMakeLists.txt

+36-26
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717
# the Free Software Foundation, Inc., 51 Franklin Street,
1818
# Boston, MA 02110-1301, USA.
1919

20-
########################################################################
21-
# Setup library
22-
########################################################################
23-
add_library(rtlsdr_shared SHARED
20+
MACRO(RTLSDR_APPEND_SRCS)
21+
LIST(APPEND rtlsdr_srcs ${ARGV})
22+
ENDMACRO(RTLSDR_APPEND_SRCS)
23+
24+
RTLSDR_APPEND_SRCS(
2425
librtlsdr.c
2526
tuner_e4k.c
2627
tuner_fc0012.c
@@ -29,24 +30,44 @@ add_library(rtlsdr_shared SHARED
2930
tuner_r82xx.c
3031
)
3132

32-
target_link_libraries(rtlsdr_shared
33-
${LIBUSB_LIBRARIES}
34-
)
33+
########################################################################
34+
# Set up Windows DLL resource files
35+
########################################################################
36+
IF(MSVC)
37+
include(${CMAKE_SOURCE_DIR}/cmake/Modules/Version.cmake)
38+
39+
configure_file(
40+
${CMAKE_CURRENT_SOURCE_DIR}/rtlsdr.rc.in
41+
${CMAKE_CURRENT_BINARY_DIR}/rtlsdr.rc
42+
@ONLY)
3543

44+
RTLSDR_APPEND_SRCS(${CMAKE_CURRENT_BINARY_DIR}/rtlsdr.rc)
45+
ENDIF(MSVC)
46+
47+
########################################################################
48+
# Setup shared library variant
49+
########################################################################
50+
add_library(rtlsdr_shared SHARED ${rtlsdr_srcs})
51+
target_link_libraries(rtlsdr_shared ${LIBUSB_LIBRARIES})
3652
set_target_properties(rtlsdr_shared PROPERTIES DEFINE_SYMBOL "rtlsdr_EXPORTS")
3753
set_target_properties(rtlsdr_shared PROPERTIES OUTPUT_NAME rtlsdr)
3854
set_target_properties(rtlsdr_shared PROPERTIES SOVERSION ${MAJOR_VERSION})
3955
set_target_properties(rtlsdr_shared PROPERTIES VERSION ${LIBVER})
4056

41-
add_library(rtlsdr_static STATIC
42-
librtlsdr.c
43-
tuner_e4k.c
44-
tuner_fc0012.c
45-
tuner_fc0013.c
46-
tuner_fc2580.c
47-
tuner_r82xx.c
48-
)
57+
########################################################################
58+
# Setup static library variant
59+
########################################################################
60+
add_library(rtlsdr_static STATIC ${rtlsdr_srcs})
61+
target_link_libraries(rtlsdr_static ${LIBUSB_LIBRARIES})
62+
set_property(TARGET rtlsdr_static APPEND PROPERTY COMPILE_DEFINITIONS "rtlsdr_STATIC" )
63+
if(NOT WIN32)
64+
# Force same library filename for static and shared variants of the library
65+
set_target_properties(rtlsdr_static PROPERTIES OUTPUT_NAME rtlsdr)
66+
endif()
4967

68+
########################################################################
69+
# Setup libraries used in executables
70+
########################################################################
5071
add_library(convenience_static STATIC
5172
convenience/convenience.c
5273
)
@@ -60,17 +81,6 @@ target_link_libraries(convenience_static
6081
)
6182
endif()
6283

63-
target_link_libraries(rtlsdr_static
64-
${LIBUSB_LIBRARIES}
65-
)
66-
67-
set_property(TARGET rtlsdr_static APPEND PROPERTY COMPILE_DEFINITIONS "rtlsdr_STATIC" )
68-
69-
if(NOT WIN32)
70-
# Force same library filename for static and shared variants of the library
71-
set_target_properties(rtlsdr_static PROPERTIES OUTPUT_NAME rtlsdr)
72-
endif()
73-
7484
########################################################################
7585
# Build utility
7686
########################################################################

Diff for: src/rtlsdr.rc.in

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
#include <afxres.h>
3+
4+
VS_VERSION_INFO VERSIONINFO
5+
FILEVERSION 0,0,0,0
6+
PRODUCTVERSION 0,0,0,0
7+
FILEFLAGSMASK 0x3fL
8+
#ifndef NDEBUG
9+
FILEFLAGS 0x0L
10+
#else
11+
FILEFLAGS 0x1L
12+
#endif
13+
FILEOS VOS__WINDOWS32
14+
FILETYPE VFT_DLL
15+
FILESUBTYPE VFT2_DRV_INSTALLABLE
16+
BEGIN
17+
BLOCK "StringFileInfo"
18+
BEGIN
19+
BLOCK "040904b0"
20+
BEGIN
21+
VALUE "FileDescription", "osmocom rtl-sdr"
22+
VALUE "FileVersion", "@VERSION@"
23+
VALUE "InternalName", "rtl-sdr.dll"
24+
VALUE "LegalCopyright", "Licensed under GPLv2"
25+
VALUE "OriginalFilename", "rtl-sdr.dll"
26+
VALUE "ProductName", "osmocom rtl-sdr"
27+
VALUE "ProductVersion", "@VERSION@"
28+
END
29+
END
30+
BLOCK "VarFileInfo"
31+
BEGIN
32+
VALUE "Translation", 0x409, 1200
33+
END
34+
END

0 commit comments

Comments
 (0)