Initial commit

This commit is contained in:
matt
2020-09-20 12:16:44 +00:00
parent 09a4460ddb
commit 408c005d3e
839 changed files with 190481 additions and 0 deletions

80
cmake/BuildPackages.cmake Normal file
View File

@@ -0,0 +1,80 @@
# This file is included from the top-level CMakeLists.txt. We just store it
# here to avoid cluttering up that file.
#
# Windows installer (Inno Setup)
#
if(WIN32)
if(CMAKE_SIZEOF_VOID_P MATCHES 8)
set(INST_NAME ${CMAKE_PROJECT_NAME}64-${VERSION})
set(INST_DEFS -DWIN64)
else()
set(INST_NAME ${CMAKE_PROJECT_NAME}-${VERSION})
endif()
if(BUILD_WINVNC)
set(INST_DEFS ${INST_DEFS} -DBUILD_WINVNC)
set(INST_DEPS ${INST_DEPS} winvnc4 wm_hooks vncconfig)
endif()
configure_file(release/kasmvnc.iss.in release/kasmvnc.iss)
add_custom_target(installer
iscc -o. ${INST_DEFS} -F${INST_NAME} release/kasmvnc.iss
DEPENDS ${INST_DEPS}
SOURCES release/kasmvnc.iss)
endif() # WIN32
#
# Mac DMG
#
if(APPLE)
set(DEFAULT_OSX_X86_BUILD ${CMAKE_SOURCE_DIR}/osxx86)
set(OSX_X86_BUILD ${DEFAULT_OSX_X86_BUILD} CACHE PATH
"Directory containing 32-bit OS X build to include in universal binaries (default: ${DEFAULT_OSX_X86_BUILD})")
configure_file(release/makemacapp.in release/makemacapp)
configure_file(release/Info.plist.in release/Info.plist)
add_custom_target(dmg sh release/makemacapp
SOURCES release/makemacapp)
add_custom_target(udmg sh release/makemacapp universal
SOURCES release/makemacapp)
endif() # APPLE
#
# Binary tarball
#
if(UNIX)
configure_file(release/maketarball.in release/maketarball)
set(TARBALL_DEPENDS vncpasswd vncconfig)
add_custom_target(tarball sh release/maketarball
DEPENDS ${TARBALL_DEPENDS}
SOURCES release/maketarball)
add_custom_target(servertarball sh release/maketarball server
DEPENDS ${TARBALL_DEPENDS}
SOURCES release/maketarball)
endif() #UNIX
#
# Common
#
install(FILES ${CMAKE_SOURCE_DIR}/LICENCE.TXT DESTINATION ${DOC_DIR})
install(FILES ${CMAKE_SOURCE_DIR}/README.md DESTINATION ${DOC_DIR})

View File

@@ -0,0 +1,145 @@
macro(libtool_create_control_file _target)
get_target_property(_target_type ${_target} TYPE)
message("-- Creating static libtool control file for target ${_target}")
# No support for shared libraries, as KasmVNC only needs libtool config
# files for static libraries.
if("${_target_type}" MATCHES "^[^STATIC_LIBRARY]$")
message(ERROR " - trying to use libtool_create_control_file for non-static library target.")
endif()
#
# Parse the target_LIB_DEPENDS variable to determine which libraries to put
# into libtool control file as library dependencies, and handle a few corner
# cases.
#
# First we need to split up any internal entries
set(target_libs "")
foreach(library ${${_target}_LIB_DEPENDS})
if("${library}" MATCHES " ")
string(REPLACE " " ";" lib_list "${library}")
list(APPEND target_libs ${lib_list})
else()
list(APPEND target_libs "${library}")
endif()
endforeach()
set(STATIC_MODE OFF)
foreach(library ${target_libs})
# Assume all entries are shared libs if platform-specific static library
# extension is not matched.
if(NOT "${library}" MATCHES "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$")
if("${library}" MATCHES ".+\\${CMAKE_SHARED_LIBRARY_SUFFIX}$")
# Shared library extension matched, so extract the path and library
# name, then add the result to the libtool dependency libs. This
# will always be an absolute path, because that's what CMake uses
# internally.
get_filename_component(_shared_lib ${library} NAME_WE)
get_filename_component(_shared_lib_path ${library} PATH)
string(REPLACE "lib" "" _shared_lib ${_shared_lib})
set(_target_dependency_libs "${_target_dependency_libs} -L${_shared_lib_path} -l${_shared_lib}")
else()
# No shared library extension matched. Check whether target is a CMake
# target.
if(TARGET ${library})
# Target is a CMake target, so ignore (CMake targets are static
# libs in KasmVNC.)
elseif(${library} STREQUAL "-Wl,-Bstatic")
# All following libraries should be static
set(STATIC_MODE ON)
elseif(${library} STREQUAL "-Wl,-Bdynamic")
# All following libraries should be dynamic
set(STATIC_MODE OFF)
else()
# Normal library, so use find_library() to attempt to locate the
# library in a system directory.
# Need to remove -l prefix
if (${library} MATCHES "^\\${CMAKE_LINK_LIBRARY_FLAG}")
string(REPLACE ${CMAKE_LINK_LIBRARY_FLAG} "" library ${library})
endif()
if(STATIC_MODE)
set(library ${CMAKE_STATIC_LIBRARY_PREFIX}${library}${CMAKE_STATIC_LIBRARY_SUFFIX})
endif()
find_library(FL ${library})
if(FL)
# Found library. Depending on if it's static or not we might
# extract the path and library name, then add the
# result to the libtool dependency libs.
if(STATIC_MODE)
set(_target_dependency_libs "${_target_dependency_libs} ${FL}")
else()
get_filename_component(_shared_lib ${FL} NAME_WE)
get_filename_component(_shared_lib_path ${FL} PATH)
string(REPLACE "lib" "" _shared_lib ${_shared_lib})
set(_target_dependency_libs "${_target_dependency_libs} -L${_shared_lib_path} -l${_shared_lib}")
endif()
else()
# No library found, so ignore target.
endif()
# Need to clear FL to get new results next loop
unset(FL CACHE)
endif()
endif()
else()
# Detected a static library. Check whether the library pathname is
# absolute and, if not, use find_library() to get the absolute path.
get_filename_component(_name ${library} NAME)
string(REPLACE "${_name}" "" _path ${library})
if(NOT "${_path}" STREQUAL "")
# Pathname is absolute, so add it to the libtool library dependencies
# as-is.
set(_target_dependency_libs "${_target_dependency_libs} ${library}")
else()
# Pathname is not absolute, so use find_library() to get the absolute
# path.
find_library(FL ${library})
if(FL)
# Absolute pathname found. Add it.
set(_target_dependency_libs "${_target_dependency_libs} ${FL}")
else()
# No absolute pathname found. Ignore it.
endif()
# Need to clear FL to get new results next loop
unset(FL CACHE)
endif()
endif()
endforeach()
# Write the libtool control file for the static library
set(_lname ${CMAKE_STATIC_LIBRARY_PREFIX}${_target})
set(_laname ${CMAKE_CURRENT_BINARY_DIR}/${_lname}.la)
file(WRITE ${_laname} "# ${_lname}.la - a libtool library file\n# Generated by ltmain.sh (GNU libtool) 2.2.6b\n")
file(APPEND ${_laname} "dlname=''\n\n")
file(APPEND ${_laname} "library_names=''\n\n")
file(APPEND ${_laname} "old_library='${_lname}${CMAKE_STATIC_LIBRARY_SUFFIX}'\n\n")
file(APPEND ${_laname} "inherited_linker_flags=''\n\n")
file(APPEND ${_laname} "dependency_libs=' ${_target_dependency_libs}'\n\n")
file(APPEND ${_laname} "weak_library_names=''\n\n")
file(APPEND ${_laname} "current=\n")
file(APPEND ${_laname} "age=\n")
file(APPEND ${_laname} "revision=\n\n")
file(APPEND ${_laname} "installed=no\n\n")
file(APPEND ${_laname} "shouldnotlink=no\n\n")
file(APPEND ${_laname} "dlopen=''\n")
file(APPEND ${_laname} "dlpreopen=''\n\n")
file(APPEND ${_laname} "libdir='/usr/lib'\n\n")
# Make sure the timestamp is updated to trigger other make invocations
add_custom_command(TARGET ${_target} POST_BUILD COMMAND
"${CMAKE_COMMAND}" -E touch "${_laname}")
# Add custom command to symlink the static library so that autotools finds
# the library in .libs. These are executed after the specified target build.
add_custom_command(TARGET ${_target} POST_BUILD COMMAND
"${CMAKE_COMMAND}" -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/.libs")
add_custom_command(TARGET ${_target} POST_BUILD COMMAND
"${CMAKE_COMMAND}" -E create_symlink ../${_lname}${CMAKE_STATIC_LIBRARY_SUFFIX} "${CMAKE_CURRENT_BINARY_DIR}/.libs/${_lname}${CMAKE_STATIC_LIBRARY_SUFFIX}")
endmacro()

View File

@@ -0,0 +1,66 @@
# From: http://gitorious.org/gammu/mainline/blobs/master/cmake/FindIconv.cmake
# - Try to find Iconv
# Once done this will define
#
# ICONV_FOUND - system has Iconv
# ICONV_INCLUDE_DIR - the Iconv include directory
# ICONV_LIBRARIES - Link these to use Iconv
# ICONV_SECOND_ARGUMENT_IS_CONST - the second argument for iconv() is const
#
include(CheckCCompilerFlag)
include(CheckCXXSourceCompiles)
IF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
# Already in cache, be silent
SET(ICONV_FIND_QUIETLY TRUE)
ENDIF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
FIND_PATH(ICONV_INCLUDE_DIR iconv.h)
FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv c)
IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
SET(ICONV_FOUND TRUE)
ENDIF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES})
IF(ICONV_FOUND)
check_c_compiler_flag("-Werror" ICONV_HAVE_WERROR)
set (CMAKE_C_FLAGS_BACKUP "${CMAKE_C_FLAGS}")
if(ICONV_HAVE_WERROR)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
endif(ICONV_HAVE_WERROR)
check_c_source_compiles("
#include <iconv.h>
int main(){
iconv_t conv = 0;
const char* in = 0;
size_t ilen = 0;
char* out = 0;
size_t olen = 0;
iconv(conv, &in, &ilen, &out, &olen);
return 0;
}
" ICONV_SECOND_ARGUMENT_IS_CONST )
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS_BACKUP}")
ENDIF(ICONV_FOUND)
set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_LIBRARIES)
IF(ICONV_FOUND)
IF(NOT ICONV_FIND_QUIETLY)
MESSAGE(STATUS "Found Iconv: ${ICONV_LIBRARIES}")
ENDIF(NOT ICONV_FIND_QUIETLY)
ELSE(ICONV_FOUND)
IF(Iconv_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find Iconv")
ENDIF(Iconv_FIND_REQUIRED)
ENDIF(ICONV_FOUND)
MARK_AS_ADVANCED(
ICONV_INCLUDE_DIR
ICONV_LIBRARIES
ICONV_SECOND_ARGUMENT_IS_CONST
)

142
cmake/StaticBuild.cmake Normal file
View File

@@ -0,0 +1,142 @@
#
# Best-effort magic that tries to produce semi-static binaries
# (i.e. only depends on "safe" libraries like libc and libX11)
#
# Note that this often fails as there is no way to automatically
# determine the dependencies of the libraries we depend on, and
# a lot of details change with each different build environment.
#
option(BUILD_STATIC
"Link statically against most libraries, if possible" OFF)
option(BUILD_STATIC_GCC
"Link statically against only libgcc and libstdc++" OFF)
if(BUILD_STATIC)
message(STATUS "Attempting to link static binaries...")
set(BUILD_STATIC_GCC 1)
set(JPEG_LIBRARIES "-Wl,-Bstatic -ljpeg -Wl,-Bdynamic")
if(WIN32)
set(ZLIB_LIBRARIES "-Wl,-Bstatic -lz -Wl,-Bdynamic")
endif()
# gettext is included in libc on many unix systems
if(NOT LIBC_HAS_DGETTEXT)
set(GETTEXT_LIBRARIES "-Wl,-Bstatic -lintl -liconv -Wl,-Bdynamic")
endif()
if(GNUTLS_FOUND)
# GnuTLS has historically had different crypto backends
FIND_LIBRARY(GCRYPT_LIBRARY NAMES gcrypt libgcrypt
HINTS ${PC_GNUTLS_LIBDIR} ${PC_GNUTLS_LIBRARY_DIRS})
FIND_LIBRARY(NETTLE_LIBRARY NAMES nettle libnettle
HINTS ${PC_GNUTLS_LIBDIR} ${PC_GNUTLS_LIBRARY_DIRS})
FIND_LIBRARY(TASN1_LIBRARY NAMES tasn1 libtasn1
HINTS ${PC_GNUTLS_LIBDIR} ${PC_GNUTLS_LIBRARY_DIRS})
set(GNUTLS_LIBRARIES "-Wl,-Bstatic -lgnutls")
if(TASN1_LIBRARY)
set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -ltasn1")
endif()
if(NETTLE_LIBRARY)
set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -lnettle -lhogweed -lgmp")
endif()
if(GCRYPT_LIBRARY)
set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -lgcrypt -lgpg-error")
endif()
set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -Wl,-Bdynamic")
if (WIN32)
# GnuTLS uses various crypto-api stuff
set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -lcrypt32")
# And sockets
set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -lws2_32")
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
# nanosleep() lives here on Solaris
set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -lrt")
# and socket functions are hidden here
set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -lsocket")
endif()
# GnuTLS uses gettext and zlib, so make sure those are always
# included and in the proper order
set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} ${ZLIB_LIBRARIES}")
set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} ${GETTEXT_LIBRARIES}")
# The last variables might introduce whitespace, which CMake
# throws a hissy fit about
string(STRIP ${GNUTLS_LIBRARIES} GNUTLS_LIBRARIES)
endif()
if(FLTK_FOUND)
set(FLTK_LIBRARIES "-Wl,-Bstatic -lfltk_images -lpng -ljpeg -lfltk -Wl,-Bdynamic")
if(WIN32)
set(FLTK_LIBRARIES "${FLTK_LIBRARIES} -lcomctl32")
elseif(APPLE)
set(FLTK_LIBRARIES "${FLTK_LIBRARIES} -framework Cocoa")
else()
set(FLTK_LIBRARIES "${FLTK_LIBRARIES} -lm -ldl")
endif()
if(X11_FOUND AND NOT APPLE)
if(${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
set(FLTK_LIBRARIES "${FLTK_LIBRARIES} ${X11_Xcursor_LIB} ${X11_Xfixes_LIB} -Wl,-Bstatic -lXft -Wl,-Bdynamic -lfontconfig -lXrender -lXext -R/usr/sfw/lib -L=/usr/sfw/lib -lfreetype -lsocket -lnsl")
else()
set(FLTK_LIBRARIES "${FLTK_LIBRARIES} -Wl,-Bstatic -lXcursor -lXfixes -lXft -lfontconfig -lexpat -lfreetype -lpng -lbz2 -lXrender -lXext -lXinerama -Wl,-Bdynamic")
endif()
set(FLTK_LIBRARIES "${FLTK_LIBRARIES} -lX11")
endif()
endif()
# X11 libraries change constantly on Linux systems so we have to link
# them statically, even libXext. libX11 is somewhat stable, although
# even it has had an ABI change once or twice.
if(X11_FOUND AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
set(X11_LIBRARIES "-Wl,-Bstatic -lXext -Wl,-Bdynamic -lX11")
if(X11_XTest_LIB)
set(X11_XTest_LIB "-Wl,-Bstatic -lXtst -Wl,-Bdynamic")
endif()
if(X11_Xdamage_LIB)
set(X11_Xdamage_LIB "-Wl,-Bstatic -lXdamage -Wl,-Bdynamic")
endif()
if(X11_Xrandr_LIB)
set(X11_Xrandr_LIB "-Wl,-Bstatic -lXrandr -lXrender -Wl,-Bdynamic")
endif()
endif()
endif()
if(BUILD_STATIC_GCC)
# This ensures that we don't depend on libstdc++ or libgcc_s
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -nodefaultlibs")
set(STATIC_BASE_LIBRARIES "-Wl,-Bstatic -lstdc++ -Wl,-Bdynamic")
if(ENABLE_ASAN AND NOT WIN32 AND NOT APPLE)
set(STATIC_BASE_LIBRARIES "${STATIC_BASE_LIBRARIES} -Wl,-Bstatic -lasan -Wl,-Bdynamic -ldl -lm -lpthread")
endif()
if(ENABLE_TSAN AND NOT WIN32 AND NOT APPLE AND CMAKE_SIZEOF_VOID_P MATCHES 8)
# libtsan redefines some C++ symbols which then conflict with a
# statically linked libstdc++. Work around this by allowing multiple
# definitions. The linker will pick the first one (i.e. the one
# from libtsan).
set(STATIC_BASE_LIBRARIES "${STATIC_BASE_LIBRARIES} -Wl,-z -Wl,muldefs -Wl,-Bstatic -ltsan -Wl,-Bdynamic -ldl -lm")
endif()
if(WIN32)
set(STATIC_BASE_LIBRARIES "${STATIC_BASE_LIBRARIES} -lmingw32 -lgcc_eh -lgcc -lmoldname -lmingwex -lmsvcrt")
set(STATIC_BASE_LIBRARIES "${STATIC_BASE_LIBRARIES} -luser32 -lkernel32 -ladvapi32 -lshell32")
# mingw has some fun circular dependencies that requires us to link
# these things again
set(STATIC_BASE_LIBRARIES "${STATIC_BASE_LIBRARIES} -lmingw32 -lgcc_eh -lgcc -lmoldname -lmingwex -lmsvcrt")
else()
set(STATIC_BASE_LIBRARIES "${STATIC_BASE_LIBRARIES} -lgcc -lgcc_eh -lc")
endif()
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} ${STATIC_BASE_LIBRARIES}")
endif()

View File

@@ -0,0 +1,24 @@
# This code is from the CMake FAQ
if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
list(REVERSE files)
foreach (file ${files})
message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
if (EXISTS "$ENV{DESTDIR}${file}")
execute_process(
COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}"
OUTPUT_VARIABLE rm_out
RESULT_VARIABLE rm_retval
)
if(NOT ${rm_retval} EQUAL 0)
message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
endif (NOT ${rm_retval} EQUAL 0)
else (EXISTS "$ENV{DESTDIR}${file}")
message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
endif (EXISTS "$ENV{DESTDIR}${file}")
endforeach(file)