Skip to content

Commit

Permalink
Build: Require CMake 3.16+
Browse files Browse the repository at this point in the history
This eliminates various build system hacks.  Among the platforms that
TurboVNC currently supports, only RHEL 7 doesn't have CMake 3.16+ yet,
and RHEL 7 will be EOL before TurboVNC 3.2 is released.  Also, it's easy
enough to install a newer version of CMake into a non-system directory
if the system-supplied version isn't new enough.  (Our official Linux
build image already does that.)

This commit also modifies the Xvnc build system so that it uses imported
targets for OpenGL and OpenSSL.  We don't use imported targets for the
various X11 libraries, because doing so would necessitate calling
target_link_libraries() to specify every dependency (including indirect
dependencies) between every Xvnc module and every X11 library.  That
would make the build system more complex and error-prone.  Imported
targets are really more suitable for single-scope dependencies.

This commit also significantly streamlines the TurboVNC Viewer build, in
exchange for requiring CMake 3.21+.  (The need to include a resource,
namely the timestamp file, with no file extension and located under the
build directory, necessitates the RESOURCES option to add_jar(), which
was introduced in CMake 3.21.)
  • Loading branch information
dcommander committed Jan 31, 2024
1 parent 3961a6c commit 1ff6858
Show file tree
Hide file tree
Showing 12 changed files with 105 additions and 212 deletions.
9 changes: 2 additions & 7 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ Build Requirements

### All Systems

- [CMake](http://www.cmake.org) v2.8.12 or later
* CMake 3.12 or later is required if it is desirable or necessary to use
Python 3 to run the simple web server for noVNC (part of the TurboVNC
Server.)
- [CMake](http://www.cmake.org) v3.16 or later
* CMake 3.21 or later is required if building the TurboVNC Viewer.

- libjpeg-turbo SDK v1.2 or later
* The libjpeg-turbo SDK binary packages can be downloaded from
Expand Down Expand Up @@ -42,7 +40,6 @@ Build Requirements
* [OpenJDK](https://jdk.java.net) 11 or later must be used if building
an installer with a custom JRE (if the `TVNC_INCLUDEJRE` CMake variable is
set to `1`)
* If using JDK 11 or later, CMake 3.11.x or later must also be used


### Windows
Expand Down Expand Up @@ -79,7 +76,6 @@ Build Requirements
* [OpenJDK](https://jdk.java.net) 11 or later must be used if building
an installer with a custom JRE (if the `TVNC_INCLUDEJRE` CMake variable is
set to `1`)
* If using JDK 11 or later, CMake 3.11.x or later must also be used


### Mac
Expand All @@ -93,7 +89,6 @@ Build Requirements
* [OpenJDK](https://jdk.java.net) 11 or later must be used if building
a Mac package/disk image with a custom JRE (if the `TVNC_INCLUDEJRE` CMake
variable is set to `1`)
* If using JDK 11 or later, CMake 3.11.x or later must also be used


Out-of-Tree Builds
Expand Down
10 changes: 1 addition & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,7 @@
# SETUP
###############################################################################

cmake_minimum_required(VERSION 2.8.12...3.28)
# Shut up CMake 3.1 and later
if(POLICY CMP0053)
cmake_policy(SET CMP0053 NEW)
endif()
# Shut up CMake 3.0 and later
if(POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif()
cmake_minimum_required(VERSION 3.16...3.28)

project(TurboVNC NONE)
string(TOLOWER ${CMAKE_PROJECT_NAME} CMAKE_PROJECT_NAME_LC)
Expand Down
8 changes: 4 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
image: Visual Studio 2022

environment:
LJT_VERSION: 3.0.2
LJT_64BIT_SDK: "https://github.com/libjpeg-turbo/libjpeg-turbo/releases/download/%LJT_VERSION%/libjpeg-turbo-%LJT_VERSION%-vc64.exe"
Expand All @@ -19,11 +21,9 @@ install:
c:\installers\libjpeg-turbo-vc.exe /S
set INCLUDE=c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include;c:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\shared;c:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt;c:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um
set LIB=c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\amd64;c:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\ucrt\x64;c:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\um\x64
call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
set PATH=c:\Program Files (x86)\Inno Setup 6;c:\msys64\usr\bin;c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64;c:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE;c:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64;%PATH%
set PATH=c:\Program Files (x86)\Inno Setup 6;c:\msys64\usr\bin;%PATH%
set MSYSTEM=MINGW32
Expand Down
6 changes: 1 addition & 5 deletions cmakescripts/BuildPackages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ if(TVNC_BUILDSERVER)
endif()
set(DEBDEPENDS "${DEBDEPENDS}, dbus-x11, xauth, x11-xkb-utils, xkb-data, libxdmcp6, libxfont2, libpixman-1-0, libgl1-mesa-glx")
if(TVNC_BUILDWEBSERVER)
if(PYTHON_VERSION VERSION_GREATER 3.0 OR PYTHON_VERSION VERSION_EQUAL 3.0)
set(DEBDEPENDS "${DEBDEPENDS}, python3")
else()
set(DEBDEPENDS "${DEBDEPENDS}, python (>= 2.6)")
endif()
set(DEBDEPENDS "${DEBDEPENDS}, python3")
endif()
endif()

Expand Down
232 changes: 82 additions & 150 deletions java/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
find_package(Java REQUIRED)
include(UseJava)

# Allow the default Java compiler flags to be set using an environment variable
if(NOT DEFINED CMAKE_JAVA_COMPILE_FLAGS AND DEFINED ENV{JAVAFLAGS})
Expand All @@ -13,8 +14,6 @@ set(CMAKE_JAVA_COMPILE_FLAGS "${CMAKE_JAVA_COMPILE_FLAGS} -J-Dfile.encoding=UTF8
message(STATUS "CMAKE_JAVA_COMPILE_FLAGS = ${CMAKE_JAVA_COMPILE_FLAGS}")

set(CLASSPATH com/turbovnc/vncviewer)
set(SRCDIR ${CMAKE_CURRENT_SOURCE_DIR})
set(BINDIR ${CMAKE_CURRENT_BINARY_DIR})

string(TIMESTAMP DEFAULT_JAVA_DATE "%Y-%m-%d")
set(JAVA_DATE ${DEFAULT_JAVA_DATE} CACHE STRING "Java date stamp")
Expand All @@ -23,159 +22,91 @@ string(TIMESTAMP DEFAULT_JAVA_TIME "%H:%M:%S")
set(JAVA_TIME ${DEFAULT_JAVA_TIME} CACHE STRING "Java time stamp")
mark_as_advanced(JAVA_TIME)

set(JAVA_SOURCES "")
set(JAVA_CLASSES "")

# We have to explicitly specify some of the JSch classes because it dynamically
# loads them.

set(JSCH_CLASSNAMES
CipherNone
DHEC256
DHEC384
DHEC521
DHG1
DHG14
DHGEX
DHGEX256
UserAuthGSSAPIWithMIC
UserAuthKeyboardInteractive
UserAuthNone
UserAuthPassword
UserAuthPublicKey
jce/AES128CBC
jce/AES128CTR
jce/AES192CBC
jce/AES192CTR
jce/AES256CBC
jce/AES256CTR
jce/ARCFOUR
jce/ARCFOUR128
jce/ARCFOUR256
jce/BlowfishCBC
jce/DH
jce/ECDH256
jce/ECDH384
jce/ECDH521
jce/ECDHN
jce/HMACMD5
jce/HMACMD596
jce/HMACSHA1
jce/HMACSHA196
jce/HMACSHA256
jce/HMACSHA512
jce/KeyPairGenDSA
jce/KeyPairGenECDSA
jce/KeyPairGenRSA
jce/MD5
jce/PBKDF
jce/Random
jce/SHA1
jce/SHA256
jce/SHA384
jce/SHA512
jce/SignatureDSA
jce/SignatureECDSA256
jce/SignatureECDSA384
jce/SignatureECDSA521
jce/SignatureECDSAN
jce/SignatureRSA
jce/SignatureRSAN
jce/SignatureRSASHA256
jce/SignatureRSASHA512
jce/TripleDESCBC
jce/TripleDESCTR
jcraft/Compression
jcraft/HMACMD5
jcraft/HMACMD596
jcraft/HMACSHA1
jcraft/HMACSHA196
jgss/GSSContextKrb5)

foreach(class ${JSCH_CLASSNAMES})
set(JAVA_SOURCES ${JAVA_SOURCES} com/jcraft/jsch/${class}.java)
set(JAVA_CLASSES ${JAVA_CLASSES}
${BINDIR}/com/jcraft/jsch/${class}.class)
endforeach()

file(GLOB DEPEND_SOURCES
${SRCDIR}/${CLASSPATH}/*.java
${SRCDIR}/com/turbovnc/rfb/*.java
${SRCDIR}/com/turbovnc/rdr/*.java
${SRCDIR}/com/turbovnc/network/*.java
${SRCDIR}/com/jcraft/jsch/*.java
${SRCDIR}/com/jcraft/jsch/agentproxy/*.java
${SRCDIR}/com/jcraft/jsch/agentproxy/connector/*.java
${SRCDIR}/com/jcraft/jsch/agentproxy/usocket/*.java
${SRCDIR}/com/jcraft/jsch/jce/*.java
${SRCDIR}/com/jcraft/jsch/jcraft/*.java
${SRCDIR}/com/jcraft/jsch/jgss/*.java
${SRCDIR}/com/jcraft/jzlib/*.java
${SRCDIR}/org/spf4j/base/*.java
${SRCDIR}/org/mindrot/jbcrypt/*.java)
set(JSCH_SOURCES
com/jcraft/jsch/CipherNone.java
com/jcraft/jsch/DHEC256.java
com/jcraft/jsch/DHEC384.java
com/jcraft/jsch/DHEC521.java
com/jcraft/jsch/DHG1.java
com/jcraft/jsch/DHG14.java
com/jcraft/jsch/DHGEX.java
com/jcraft/jsch/DHGEX256.java
com/jcraft/jsch/UserAuthGSSAPIWithMIC.java
com/jcraft/jsch/UserAuthKeyboardInteractive.java
com/jcraft/jsch/UserAuthNone.java
com/jcraft/jsch/UserAuthPassword.java
com/jcraft/jsch/UserAuthPublicKey.java
com/jcraft/jsch/jce/AES128CBC.java
com/jcraft/jsch/jce/AES128CTR.java
com/jcraft/jsch/jce/AES192CBC.java
com/jcraft/jsch/jce/AES192CTR.java
com/jcraft/jsch/jce/AES256CBC.java
com/jcraft/jsch/jce/AES256CTR.java
com/jcraft/jsch/jce/ARCFOUR.java
com/jcraft/jsch/jce/ARCFOUR128.java
com/jcraft/jsch/jce/ARCFOUR256.java
com/jcraft/jsch/jce/BlowfishCBC.java
com/jcraft/jsch/jce/DH.java
com/jcraft/jsch/jce/ECDH256.java
com/jcraft/jsch/jce/ECDH384.java
com/jcraft/jsch/jce/ECDH521.java
com/jcraft/jsch/jce/ECDHN.java
com/jcraft/jsch/jce/HMACMD5.java
com/jcraft/jsch/jce/HMACMD596.java
com/jcraft/jsch/jce/HMACSHA1.java
com/jcraft/jsch/jce/HMACSHA196.java
com/jcraft/jsch/jce/HMACSHA256.java
com/jcraft/jsch/jce/HMACSHA512.java
com/jcraft/jsch/jce/KeyPairGenDSA.java
com/jcraft/jsch/jce/KeyPairGenECDSA.java
com/jcraft/jsch/jce/KeyPairGenRSA.java
com/jcraft/jsch/jce/MD5.java
com/jcraft/jsch/jce/PBKDF.java
com/jcraft/jsch/jce/Random.java
com/jcraft/jsch/jce/SHA1.java
com/jcraft/jsch/jce/SHA256.java
com/jcraft/jsch/jce/SHA384.java
com/jcraft/jsch/jce/SHA512.java
com/jcraft/jsch/jce/SignatureDSA.java
com/jcraft/jsch/jce/SignatureECDSA256.java
com/jcraft/jsch/jce/SignatureECDSA384.java
com/jcraft/jsch/jce/SignatureECDSA521.java
com/jcraft/jsch/jce/SignatureECDSAN.java
com/jcraft/jsch/jce/SignatureRSA.java
com/jcraft/jsch/jce/SignatureRSAN.java
com/jcraft/jsch/jce/SignatureRSASHA256.java
com/jcraft/jsch/jce/SignatureRSASHA512.java
com/jcraft/jsch/jce/TripleDESCBC.java
com/jcraft/jsch/jce/TripleDESCTR.java
com/jcraft/jsch/jcraft/Compression.java
com/jcraft/jsch/jcraft/HMACMD5.java
com/jcraft/jsch/jcraft/HMACMD596.java
com/jcraft/jsch/jcraft/HMACSHA1.java
com/jcraft/jsch/jcraft/HMACSHA196.java
com/jcraft/jsch/jgss/GSSContextKrb5.java)

string(REGEX REPLACE " " ";" CMAKE_JAVA_COMPILE_FLAGS
"${CMAKE_JAVA_COMPILE_FLAGS}")
add_custom_command(OUTPUT ${JAVA_CLASSES}
DEPENDS ${JAVA_SOURCES} ${DEPEND_SOURCES}
COMMAND ${JAVA_COMPILE}
ARGS ${CMAKE_JAVA_COMPILE_FLAGS} -sourcepath ${SRCDIR} -d ${BINDIR}
${CLASSPATH}/VncViewer.java ${CLASSPATH}/ImageDrawTest.java ${JAVA_SOURCES}
WORKING_DIRECTORY ${SRCDIR})

configure_file(${CLASSPATH}/timestamp.in ${CLASSPATH}/timestamp)

if(NOT "${SRCDIR}" STREQUAL "${BINDIR}")

foreach(icon toolbar.png turbovnc.png turbovnc-sm.png turbovnc-128.png
insecure.png secure.png)
add_custom_command(OUTPUT ${BINDIR}/${CLASSPATH}/${icon}
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${SRCDIR}/${CLASSPATH}/${icon} ${BINDIR}/${CLASSPATH}/${icon}
DEPENDS ${SRCDIR}/${CLASSPATH}/${icon})
endforeach()

endif()

string(REGEX REPLACE "jar" "" Java_PATH ${Java_JAR_EXECUTABLE})
string(REGEX REPLACE ".exe" "" Java_PATH ${Java_PATH})

add_custom_command(OUTPUT VncViewer.jar
DEPENDS ${JAVA_CLASSES}
${SRCDIR}/${CLASSPATH}/MANIFEST.MF
${BINDIR}/${CLASSPATH}/timestamp
${BINDIR}/${CLASSPATH}/toolbar.png
${BINDIR}/${CLASSPATH}/turbovnc.png
${BINDIR}/${CLASSPATH}/turbovnc-sm.png
${BINDIR}/${CLASSPATH}/turbovnc-128.png
${BINDIR}/${CLASSPATH}/insecure.png
${BINDIR}/${CLASSPATH}/secure.png
COMMAND ${JAVA_ARCHIVE}
ARGS cfm VncViewer.jar
${SRCDIR}/${CLASSPATH}/MANIFEST.MF
${CLASSPATH}/timestamp
${CLASSPATH}/*.class
com/turbovnc/rfb/*.class
com/turbovnc/rdr/*.class
com/turbovnc/network/*.class
com/jcraft/jzlib/*.class
com/jcraft/jsch/agentproxy/*.class
com/jcraft/jsch/agentproxy/connector/*.class
com/jcraft/jsch/agentproxy/usocket/*.class
com/jcraft/jsch/jgss/*.class
com/jcraft/jsch/jcraft/*.class
com/jcraft/jsch/jce/*.class
com/jcraft/jsch/*.class
org/spf4j/base/*.class
org/mindrot/jbcrypt/*.class
${CLASSPATH}/toolbar.png
${CLASSPATH}/turbovnc.png
${CLASSPATH}/turbovnc-sm.png
${CLASSPATH}/turbovnc-128.png
${CLASSPATH}/insecure.png
${CLASSPATH}/secure.png)

add_custom_target(java ALL DEPENDS VncViewer.jar)
cmake_minimum_required(VERSION 3.21)
add_jar(VncViewer
${CLASSPATH}/VncViewer.java
${CLASSPATH}/ImageDrawTest.java
${JSCH_SOURCES}
MANIFEST ${CLASSPATH}/MANIFEST.MF
RESOURCES
NAMESPACE ${CLASSPATH} ${CMAKE_BINARY_DIR}/java/${CLASSPATH}/timestamp
NAMESPACE ${CLASSPATH} ${CLASSPATH}/toolbar.png
NAMESPACE ${CLASSPATH} ${CLASSPATH}/turbovnc.png
NAMESPACE ${CLASSPATH} ${CLASSPATH}/turbovnc-sm.png
NAMESPACE ${CLASSPATH} ${CLASSPATH}/turbovnc-128.png
NAMESPACE ${CLASSPATH} ${CLASSPATH}/insecure.png
NAMESPACE ${CLASSPATH} ${CLASSPATH}/secure.png)

if(CMAKE_INSTALL_PREFIX STREQUAL "${CMAKE_INSTALL_DEFAULT_PREFIX}" OR WIN32)
set(CMAKE_INSTALL_DEFAULT_JAVADIR "<CMAKE_INSTALL_DATAROOTDIR>/java")
Expand Down Expand Up @@ -216,13 +147,14 @@ if(TVNC_INCLUDEJRE)
-P ${CMAKE_CURRENT_BINARY_DIR}/cmake/BuildJRE.cmake
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/jrestamp
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
DEPENDS VncViewer.jar
DEPENDS VncViewer
COMMENT "Generating Custom Java Runtime Environment (JRE)")
add_custom_target(jrebuild ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/jrestamp java)
add_custom_target(jrebuild ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/jrestamp
VncViewer)
endif()

install(FILES ${BINDIR}/VncViewer.jar DESTINATION ${CMAKE_INSTALL_JAVADIR})
install(FILES ${SRCDIR}/${CLASSPATH}/README.md
install_jar(VncViewer DESTINATION ${CMAKE_INSTALL_JAVADIR})
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${CLASSPATH}/README.md
DESTINATION ${CMAKE_INSTALL_JAVADIR})
if(TVNC_INCLUDEJRE)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/jre
Expand Down
21 changes: 7 additions & 14 deletions unix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,15 @@ execute_process(COMMAND chmod +x vncserver
install(PROGRAMS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/vncserver
DESTINATION ${CMAKE_INSTALL_BINDIR})
if(TVNC_BUILDWEBSERVER)
if(CMAKE_VERSION VERSION_GREATER 3.12 OR
CMAKE_VERSION VERSION_EQUAL 3.12)
find_package(Python 3.0 REQUIRED)
if(CMAKE_SYSTEM_NAME MATCHES "(OpenBSD|FreeBSD|NetBSD|DragonFly)")
set(PYTHON_EXECUTABLE ${Python_EXECUTABLE})
else()
string(REGEX REPLACE "\\.[0-9]+$" "" PYTHON_EXECUTABLE
${Python_EXECUTABLE})
set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} PARENT_SCOPE)
endif()
message(STATUS "PYTHON_EXECUTABLE = ${PYTHON_EXECUTABLE}")
set(PYTHON_VERSION ${Python_VERSION} PARENT_SCOPE)
find_package(Python 3.0 COMPONENTS Interpreter REQUIRED)
if(CMAKE_SYSTEM_NAME MATCHES "(OpenBSD|FreeBSD|NetBSD|DragonFly)")
set(PYTHON_EXECUTABLE ${Python_EXECUTABLE})
else()
find_package(PythonInterp 2.6 REQUIRED)
set(PYTHON_VERSION ${PYTHON_VERSION_STRING} PARENT_SCOPE)
string(REGEX REPLACE "\\.[0-9]+$" "" PYTHON_EXECUTABLE
${Python_EXECUTABLE})
set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} PARENT_SCOPE)
endif()
message(STATUS "PYTHON_EXECUTABLE = ${PYTHON_EXECUTABLE}")
configure_file(webserver.in ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/webserver
@ONLY)
execute_process(COMMAND chmod +x webserver
Expand Down
1 change: 0 additions & 1 deletion unix/Xvnc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ configure_file(include/tvnc_version.h.in

set(OpenGL_GL_PREFERENCE LEGACY)
include(FindOpenGL)
include_directories(${OPENGL_INCLUDE_DIR})

add_subdirectory(lib)
add_subdirectory(programs/Xserver)
Loading

0 comments on commit 1ff6858

Please sign in to comment.