Skip to content

Commit

Permalink
Avoid temporary cmake variables
Browse files Browse the repository at this point in the history
Modern cmake has better support for adding source files and libraries
incrementally, so let's use that to clean things up.
  • Loading branch information
CendioOssman committed Jun 7, 2022
1 parent 15fc3e2 commit 6c7c022
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 61 deletions.
6 changes: 2 additions & 4 deletions common/network/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
include_directories(${CMAKE_SOURCE_DIR}/common)

set(NETWORK_SOURCES
add_library(network STATIC
Socket.cxx
TcpSocket.cxx)

if(NOT WIN32)
set(NETWORK_SOURCES ${NETWORK_SOURCES} UnixSocket.cxx)
target_sources(network PRIVATE UnixSocket.cxx)
endif()

add_library(network STATIC ${NETWORK_SOURCES})

if(WIN32)
target_link_libraries(network ws2_32)
endif()
Expand Down
9 changes: 4 additions & 5 deletions common/rdr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@ add_library(rdr STATIC
ZlibInStream.cxx
ZlibOutStream.cxx)

set(RDR_LIBRARIES ${ZLIB_LIBRARIES} os)
target_link_libraries(rdr ${ZLIB_LIBRARIES} os)

if(GNUTLS_FOUND)
set(RDR_LIBRARIES ${RDR_LIBRARIES} ${GNUTLS_LIBRARIES})
target_link_libraries(rdr ${GNUTLS_LIBRARIES})
endif()
if(WIN32)
set(RDR_LIBRARIES ${RDR_LIBRARIES} ws2_32)
target_link_libraries(rdr ws2_32)
endif()

target_link_libraries(rdr ${RDR_LIBRARIES})

if(UNIX)
libtool_create_control_file(rdr)
endif()
37 changes: 13 additions & 24 deletions common/rfb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include_directories(${CMAKE_SOURCE_DIR}/common ${JPEG_INCLUDE_DIR} ${PIXMAN_INCLUDE_DIR})

set(RFB_SOURCES
add_library(rfb STATIC
Blacklist.cxx
Congestion.cxx
CConnection.cxx
Expand Down Expand Up @@ -64,48 +64,37 @@ set(RFB_SOURCES
encodings.cxx
util.cxx)

target_link_libraries(rfb os rdr)
target_link_libraries(rfb ${JPEG_LIBRARIES} ${PIXMAN_LIBRARY})

if(ENABLE_H264 AND NOT H264_LIBS STREQUAL "NONE")
set(RFB_SOURCES ${RFB_SOURCES} H264Decoder.cxx H264DecoderContext.cxx)
target_sources(rfb PRIVATE H264Decoder.cxx H264DecoderContext.cxx)
if(H264_LIBS STREQUAL "LIBAV")
set(RFB_SOURCES ${RFB_SOURCES} H264LibavDecoderContext.cxx)
target_sources(rfb PRIVATE H264LibavDecoderContext.cxx)
elseif(H264_LIBS STREQUAL "WIN")
set(RFB_SOURCES ${RFB_SOURCES} H264WinDecoderContext.cxx)
target_sources(rfb PRIVATE H264WinDecoderContext.cxx)
endif()
endif()

if(UNIX)
set(RFB_SOURCES ${RFB_SOURCES} Logger_syslog.cxx)
target_sources(rfb PRIVATE Logger_syslog.cxx)
endif()

if(WIN32)
include_directories(${CMAKE_SOURCE_DIR}/win)
set(RFB_SOURCES ${RFB_SOURCES} WinPasswdValidator.cxx)
target_sources(rfb PRIVATE WinPasswdValidator.cxx)
endif(WIN32)

set(RFB_LIBRARIES ${JPEG_LIBRARIES} ${PIXMAN_LIBRARY} os rdr)

if(UNIX AND NOT APPLE)
set(RFB_SOURCES ${RFB_SOURCES} UnixPasswordValidator.cxx
UnixPasswordValidator.h pam.c pam.h)
set(RFB_LIBRARIES ${RFB_LIBRARIES} ${PAM_LIBS})
target_sources(rfb PRIVATE UnixPasswordValidator.cxx pam.c)
target_link_libraries(rfb ${PAM_LIBS})
endif()

if(GNUTLS_FOUND)
set(RFB_SOURCES
${RFB_SOURCES}
CSecurityTLS.cxx
SSecurityTLS.cxx
)
set(RFB_LIBRARIES
${RFB_LIBRARIES}
${GNUTLS_LIBRARIES}
)
target_sources(rfb PRIVATE CSecurityTLS.cxx SSecurityTLS.cxx)
target_link_libraries(rfb ${GNUTLS_LIBRARIES})
endif()

add_library(rfb STATIC ${RFB_SOURCES})

target_link_libraries(rfb ${RFB_LIBRARIES})

if(UNIX)
libtool_create_control_file(rfb)
endif()
15 changes: 7 additions & 8 deletions tests/perf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,20 @@ target_link_libraries(encperf test_util rfb)

if (BUILD_VIEWER)
include_directories(${FLTK_INCLUDE_DIR})
set(FBPERF_SOURCES
add_executable(fbperf
fbperf.cxx
${CMAKE_SOURCE_DIR}/vncviewer/PlatformPixelBuffer.cxx
${CMAKE_SOURCE_DIR}/vncviewer/Surface.cxx)
if(WIN32)
set(FBPERF_SOURCES ${FBPERF_SOURCES} ${CMAKE_SOURCE_DIR}/vncviewer/Surface_Win32.cxx)
target_sources(fbperf PRIVATE ${CMAKE_SOURCE_DIR}/vncviewer/Surface_Win32.cxx)
elseif(APPLE)
set(FBPERF_SOURCES
${FBPERF_SOURCES} ${CMAKE_SOURCE_DIR}/vncviewer/Surface_OSX.cxx
${FBPERF_SOURCES} ${CMAKE_SOURCE_DIR}/vncviewer/keysym2ucs.c
${FBPERF_SOURCES} ${CMAKE_SOURCE_DIR}/vncviewer/cocoa.mm)
target_sources(fbperf PRIVATE
${CMAKE_SOURCE_DIR}/vncviewer/Surface_OSX.cxx
${CMAKE_SOURCE_DIR}/vncviewer/keysym2ucs.c
${CMAKE_SOURCE_DIR}/vncviewer/cocoa.mm)
else()
set(FBPERF_SOURCES ${FBPERF_SOURCES} ${CMAKE_SOURCE_DIR}/vncviewer/Surface_X11.cxx)
target_sources(fbperf PRIVATE ${CMAKE_SOURCE_DIR}/vncviewer/Surface_X11.cxx)
endif()
add_executable(fbperf ${FBPERF_SOURCES})
target_link_libraries(fbperf test_util rfb ${FLTK_LIBRARIES} ${GETTEXT_LIBRARIES})
if(WIN32)
target_link_libraries(fbperf msimg32)
Expand Down
29 changes: 13 additions & 16 deletions vncviewer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ include_directories(${FLTK_INCLUDE_DIR})
include_directories(${GETTEXT_INCLUDE_DIR})

include_directories(${CMAKE_SOURCE_DIR}/common)
set(VNCVIEWER_SOURCES

add_executable(vncviewer
menukey.cxx
BaseTouchHandler.cxx
CConn.cxx
Expand All @@ -21,36 +22,32 @@ set(VNCVIEWER_SOURCES
MonitorIndicesParameter.cxx
vncviewer.cxx)

if(WIN32 AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
set_target_properties(vncviewer PROPERTIES WIN32_EXECUTABLE TRUE)
endif()

if(WIN32)
# Since vncviewer.rc is generated, local includes will be looking
# in the wrong directory. We need to help it out.
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
configure_file(vncviewer.rc.in vncviewer.rc)
set(VNCVIEWER_SOURCES
${VNCVIEWER_SOURCES}
${CMAKE_CURRENT_BINARY_DIR}/vncviewer.rc)
target_sources(vncviewer PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/vncviewer.rc)
endif()

if(WIN32)
set(VNCVIEWER_SOURCES ${VNCVIEWER_SOURCES} Win32TouchHandler.cxx win32.c)
target_sources(vncviewer PRIVATE Win32TouchHandler.cxx win32.c)
elseif(APPLE)
set(VNCVIEWER_SOURCES ${VNCVIEWER_SOURCES} cocoa.mm osx_to_qnum.c)
target_sources(vncviewer PRIVATE cocoa.mm osx_to_qnum.c)
else()
set(VNCVIEWER_SOURCES ${VNCVIEWER_SOURCES} GestureHandler.cxx XInputTouchHandler.cxx xkb_to_qnum.c)
target_sources(vncviewer PRIVATE GestureHandler.cxx XInputTouchHandler.cxx xkb_to_qnum.c)
endif()

if(WIN32)
set(VNCVIEWER_SOURCES ${VNCVIEWER_SOURCES} Surface_Win32.cxx)
target_sources(vncviewer PRIVATE Surface_Win32.cxx)
elseif(APPLE)
set(VNCVIEWER_SOURCES ${VNCVIEWER_SOURCES} Surface_OSX.cxx)
else()
set(VNCVIEWER_SOURCES ${VNCVIEWER_SOURCES} Surface_X11.cxx)
endif()

if(WIN32 AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
add_executable(vncviewer WIN32 ${VNCVIEWER_SOURCES})
target_sources(vncviewer PRIVATE Surface_OSX.cxx)
else()
add_executable(vncviewer ${VNCVIEWER_SOURCES})
target_sources(vncviewer PRIVATE Surface_X11.cxx)
endif()

target_link_libraries(vncviewer rfb network rdr os ${FLTK_LIBRARIES} ${GETTEXT_LIBRARIES} ${H264_LIBRARIES})
Expand Down
6 changes: 2 additions & 4 deletions win/rfb_win32/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set(RFB_WIN32_SOURCES
add_library(rfb_win32 STATIC
AboutDialog.cxx
Clipboard.cxx
CurrentUser.cxx
Expand Down Expand Up @@ -32,9 +32,7 @@ set(RFB_WIN32_SOURCES
WMWindowCopyRect.cxx)

if(BUILD_WINVNC)
set(RFB_WIN32_SOURCES ${RFB_WIN32_SOURCES} CleanDesktop.cxx)
target_sources(rfb_win32 PRIVATE ${RFB_WIN32_SOURCES} CleanDesktop.cxx)
endif()

add_library(rfb_win32 STATIC ${RFB_WIN32_SOURCES})

target_link_libraries(rfb_win32 user32.lib comctl32.lib wtsapi32.lib version.lib)

0 comments on commit 6c7c022

Please sign in to comment.