Skip to content

Commit

Permalink
CMake: add tigervnc library
Browse files Browse the repository at this point in the history
  • Loading branch information
KangLin committed Feb 28, 2025
1 parent 62c606d commit cfc4074
Show file tree
Hide file tree
Showing 18 changed files with 319 additions and 57 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
build*/
*.[ao]
*.mo
*.la
*.lo
*.user
.deps
.libs

Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ include(CheckTypeSize)
include(CheckCSourceCompiles)
include(CheckCXXSourceCompiles)
include(CheckCSourceRuns)
include(CMakePackageConfigHelpers)
include(CMakeParseArguments)
include(GenerateExportHeader)

include(CMakeMacroLibtoolFile)

Expand Down
46 changes: 46 additions & 0 deletions common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,49 @@ if(NOT WIN32)
set_target_properties(core rdr network rfb
PROPERTIES COMPILE_FLAGS -fPIC)
endif()

add_library(tigervnc STATIC
$<TARGET_OBJECTS:core>
$<TARGET_OBJECTS:rdr>
$<TARGET_OBJECTS:network>
$<TARGET_OBJECTS:rfb>)
target_link_libraries(tigervnc PUBLIC core rdr network rfb)

# cmake version configure file
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/tigervncConfigVersion.cmake"
VERSION ${VERSION}
COMPATIBILITY AnyNewerVersion)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/tigervncConfigVersion.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/tigervnc"
COMPONENT Development
)

# Generate an export header file, which is required when generating DLLs using msvc
GENERATE_EXPORT_HEADER(tigervnc)
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/tigervnc_export.h
DESTINATION ${CMAKE_BINARY_DIR})
list(APPEND INSTALL_HEAD_FILES ${CMAKE_CURRENT_BINARY_DIR}/tigervnc_export.h)
set_target_properties(tigervnc PROPERTIES
PUBLIC_HEADER "${INSTALL_HEAD_FILES}" # Install head files
)

# Install head and library file
INSTALL(TARGETS tigervnc
EXPORT tigervncConfig
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/tigervnc
COMPONENT Development
INCLUDES DESTINATION tigervnc
)
# Export cmake configure file
export(TARGETS tigervnc
APPEND FILE ${CMAKE_CURRENT_BINARY_DIR}/tigervncConfig.cmake
)
install(EXPORT tigervncConfig
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/tigervnc"
COMPONENT Development
)

if(UNIX)
libtool_create_control_file(tigervnc)
endif()
46 changes: 42 additions & 4 deletions common/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
add_library(core STATIC
set(INSTALL_HEAD_FILES
Configuration.h
Exception.h
Logger.h
Mutex.h
Region.h
Timer.h
Thread.h
string.h
time.h
xdgdirs.h)
set(HEAD_FILES
${INSTALL_HEAD_FILES}
Logger_file.h
Logger_stdio.h
LogWriter.h)
add_library(core OBJECT
${HEAD_FILES}
Configuration.cxx
Exception.cxx
Logger.cxx
Expand All @@ -13,10 +30,12 @@ add_library(core STATIC
time.cxx
xdgdirs.cxx)

target_include_directories(core PUBLIC ${CMAKE_SOURCE_DIR}/common)
target_include_directories(core SYSTEM PUBLIC ${PIXMAN_INCLUDE_DIRS})
target_include_directories(core PRIVATE
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/common>
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>)
target_include_directories(core PRIVATE ${PIXMAN_INCLUDE_DIRS})
target_link_libraries(core ${PIXMAN_LIBRARIES})
target_link_directories(core PUBLIC ${PIXMAN_LIBRARY_DIRS})
target_link_directories(core PRIVATE ${PIXMAN_LIBRARY_DIRS})

if(UNIX)
target_sources(core PRIVATE Logger_syslog.cxx)
Expand All @@ -34,3 +53,22 @@ endif()
if(UNIX)
libtool_create_control_file(core)
endif()

# Install head files
set_target_properties(core PROPERTIES
PUBLIC_HEADER "${INSTALL_HEAD_FILES}")
# Install head file
INSTALL(TARGETS core
EXPORT coreConfig
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/tigervnc/core
COMPONENT Development
INCLUDES DESTINATION tigervnc
)
# Export cmake configure file
export(TARGETS core
APPEND FILE ${CMAKE_CURRENT_BINARY_DIR}/coreConfig.cmake
)
install(EXPORT coreConfig
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/tigervnc"
COMPONENT Development
)
30 changes: 28 additions & 2 deletions common/network/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
add_library(network STATIC
set(INSTALL_HEAD_FILES
Socket.h
TcpSocket.h)

add_library(network OBJECT
${INSTALL_HEAD_FILES}
Socket.cxx
TcpSocket.cxx)

if(NOT WIN32)
target_sources(network PRIVATE UnixSocket.cxx)
endif()

target_include_directories(network PUBLIC ${CMAKE_SOURCE_DIR}/common)
target_include_directories(network PRIVATE
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/common>
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>)
target_link_libraries(network core rdr)

if(WIN32)
Expand All @@ -16,3 +23,22 @@ endif()
if(UNIX)
libtool_create_control_file(network)
endif()

# Install head files
set_target_properties(network PROPERTIES
PUBLIC_HEADER "${INSTALL_HEAD_FILES}")
# Install head file
INSTALL(TARGETS network
EXPORT networkConfig
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/tigervnc/network
COMPONENT Development
INCLUDES DESTINATION tigervnc
)
# Export cmake configure file
export(TARGETS network
APPEND FILE ${CMAKE_CURRENT_BINARY_DIR}/networkConfig.cmake
)
install(EXPORT networkConfig
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/tigervnc"
COMPONENT Development
)
50 changes: 44 additions & 6 deletions common/rdr/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
add_library(rdr STATIC
set(INSTALL_HEAD_FILES
AESInStream.h
AESOutStream.h
BufferedInStream.h
BufferedOutStream.h
FdInStream.h
FdOutStream.h
FileInStream.h
HexInStream.h
HexOutStream.h
RandomStream.h
TLSException.h
TLSInStream.h
TLSOutStream.h
ZlibInStream.h
ZlibOutStream.h)
add_library(rdr OBJECT
${INSTALL_HEAD_FILES}
AESInStream.cxx
AESOutStream.cxx
BufferedInStream.cxx
Expand All @@ -15,19 +32,21 @@ add_library(rdr STATIC
ZlibInStream.cxx
ZlibOutStream.cxx)

target_include_directories(rdr PUBLIC ${CMAKE_SOURCE_DIR}/common)
target_include_directories(rdr SYSTEM PUBLIC ${ZLIB_INCLUDE_DIRS})
target_include_directories(rdr PRIVATE
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/common>
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>)
target_include_directories(rdr SYSTEM PRIVATE ${ZLIB_INCLUDE_DIRS})
target_link_libraries(rdr core)
target_link_libraries(rdr ${ZLIB_LIBRARIES})

if(GNUTLS_FOUND)
target_include_directories(rdr SYSTEM PUBLIC ${GNUTLS_INCLUDE_DIR})
target_include_directories(rdr SYSTEM PRIVATE ${GNUTLS_INCLUDE_DIR})
target_link_libraries(rdr ${GNUTLS_LIBRARIES})
endif()
if (NETTLE_FOUND)
target_include_directories(rdr SYSTEM PUBLIC ${NETTLE_INCLUDE_DIRS})
target_include_directories(rdr SYSTEM PRIVATE ${NETTLE_INCLUDE_DIRS})
target_link_libraries(rdr ${NETTLE_LIBRARIES})
target_link_directories(rdr PUBLIC ${NETTLE_LIBRARY_DIRS})
target_link_directories(rdr PRIVATE ${NETTLE_LIBRARY_DIRS})
endif()
if(WIN32)
target_link_libraries(rdr ws2_32)
Expand All @@ -36,3 +55,22 @@ endif()
if(UNIX)
libtool_create_control_file(rdr)
endif()

# Install head files
set_target_properties(rdr PROPERTIES
PUBLIC_HEADER "${INSTALL_HEAD_FILES}")
# Install head file
INSTALL(TARGETS rdr
EXPORT rdrConfig
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/tigervnc/rdr
COMPONENT Development
INCLUDES DESTINATION tigervnc
)
# Export cmake configure file
export(TARGETS rdr
APPEND FILE ${CMAKE_CURRENT_BINARY_DIR}/rdrConfig.cmake
)
install(EXPORT rdrConfig
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/tigervnc"
COMPONENT Development
)
100 changes: 91 additions & 9 deletions common/rfb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,65 @@
add_library(rfb STATIC
set(INSTALL_HEAD_FILES
AccessRights.h
Blacklist.h
Congestion.h
CConnection.h
CMsgHandler.h
CMsgReader.h
CMsgWriter.h
CSecurityPlain.h
CSecurityStack.h
CSecurityVeNCrypt.h
CSecurityVncAuth.h
ClientParams.h
ComparingUpdateTracker.h
CopyRectDecoder.h
Cursor.h
DecodeManager.h
Decoder.h
d3des.h
EncodeManager.h
Encoder.h
HextileDecoder.h
HextileEncoder.h
JpegCompressor.h
JpegDecompressor.h
KeyRemapper.h
KeysymStr.h
PixelBuffer.h
PixelFormat.h
RREEncoder.h
RREDecoder.h
RawDecoder.h
RawEncoder.h
SConnection.h
SMsgHandler.h
SMsgReader.h
SMsgWriter.h
ServerCore.h
ServerParams.h
Security.h
SecurityServer.h
SecurityClient.h
SSecurityPlain.h
SSecurityStack.h
SSecurityVncAuth.h
SSecurityVeNCrypt.h
TightDecoder.h
TightEncoder.h
TightJPEGEncoder.h
UpdateTracker.h
VNCSConnectionST.h
VNCServerST.h
ZRLEEncoder.h
ZRLEDecoder.h
encodings.h
obfuscate.h
)
set(HEAD_FILES
${INSTALL_HEAD_FILES}
)
add_library(rfb OBJECT
${HEAD_FILES}
AccessRights.cxx
Blacklist.cxx
Congestion.cxx
Expand Down Expand Up @@ -55,8 +116,10 @@ add_library(rfb STATIC
encodings.cxx
obfuscate.cxx)

target_include_directories(rfb PUBLIC ${CMAKE_SOURCE_DIR}/common)
target_include_directories(rfb SYSTEM PUBLIC ${JPEG_INCLUDE_DIR})
target_include_directories(rfb PRIVATE
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/common>
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>)
target_include_directories(rfb SYSTEM PRIVATE ${JPEG_INCLUDE_DIR})
target_link_libraries(rfb core rdr network)
target_link_libraries(rfb ${JPEG_LIBRARIES} ${PIXMAN_LIBRARIES})

Expand All @@ -67,13 +130,13 @@ if(ENABLE_H264 AND NOT H264_LIBS STREQUAL "NONE")
elseif(H264_LIBS STREQUAL "WIN")
target_sources(rfb PRIVATE H264WinDecoderContext.cxx)
endif()
target_include_directories(rfb SYSTEM PUBLIC ${H264_INCLUDE_DIRS})
target_include_directories(rfb SYSTEM PRIVATE ${H264_INCLUDE_DIRS})
target_link_libraries(rfb ${H264_LIBRARIES})
target_link_directories(rfb PUBLIC ${H264_LIBRARY_DIRS})
target_link_directories(rfb PRIVATE ${H264_LIBRARY_DIRS})
endif()

if(WIN32)
target_include_directories(rfb PUBLIC ${CMAKE_SOURCE_DIR}/win)
target_include_directories(rfb PUBLIC $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/win>)
target_sources(rfb PRIVATE WinPasswdValidator.cxx)
endif(WIN32)

Expand All @@ -84,7 +147,7 @@ endif()

if(GNUTLS_FOUND)
target_sources(rfb PRIVATE CSecurityTLS.cxx SSecurityTLS.cxx)
target_include_directories(rfb SYSTEM PUBLIC ${GNUTLS_INCLUDE_DIR})
target_include_directories(rfb SYSTEM PRIVATE ${GNUTLS_INCLUDE_DIR})
target_link_libraries(rfb ${GNUTLS_LIBRARIES})
# FIXME: Hack to block it marking gnutls_free() as dllimport
if(WIN32 AND BUILD_STATIC)
Expand All @@ -95,14 +158,33 @@ endif()
if (NETTLE_FOUND)
target_sources(rfb PRIVATE CSecurityDH.cxx CSecurityMSLogonII.cxx
CSecurityRSAAES.cxx SSecurityRSAAES.cxx)
target_include_directories(rfb SYSTEM PUBLIC ${NETTLE_INCLUDE_DIRS}
target_include_directories(rfb SYSTEM PRIVATE ${NETTLE_INCLUDE_DIRS}
${GMP_INCLUDE_DIRS})
target_link_libraries(rfb ${HOGWEED_LIBRARIES}
${NETTLE_LIBRARIES} ${GMP_LIBRARIES})
target_link_directories(rfb PUBLIC ${HOGWEED_LIBRARY_DIRS}
target_link_directories(rfb PRIVATE ${HOGWEED_LIBRARY_DIRS}
${NETTLE_LIBRARY_DIRS} ${GMP_LIBRARY_DIRS})
endif()

if(UNIX)
libtool_create_control_file(rfb)
endif()

# Install head files
set_target_properties(rfb PROPERTIES
PUBLIC_HEADER "${INSTALL_HEAD_FILES}")
# Install head file
INSTALL(TARGETS rfb
EXPORT rfbConfig
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/tigervnc/rfb
COMPONENT Development
INCLUDES DESTINATION tigervnc
)
# Export cmake configure file
export(TARGETS rfb
APPEND FILE ${CMAKE_CURRENT_BINARY_DIR}/rfbConfig.cmake
)
install(EXPORT rfbConfig
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/tigervnc"
COMPONENT Development
)
Loading

0 comments on commit cfc4074

Please sign in to comment.