Skip to content

Commit

Permalink
Update build system so it will compile on Windows 10.
Browse files Browse the repository at this point in the history
With this commit, TigerVNC will compile for Windows using MSYS2, MinGW-w64 and Inno Setup 6.  The resulting binaries have some dll dependencies (even with BUILD_STATIC).  The required dll dependencies are not included in the installer.

Unfortunately, the latest version of MSYS2 and MinGW-w64 do not produce a working executable for Windows 7.
  • Loading branch information
mriphysicist committed Jun 24, 2020
1 parent 38726ce commit d164808
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion cmake/StaticBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,21 @@ if(BUILD_STATIC)

# gettext is included in libc on many unix systems
if(NOT LIBC_HAS_DGETTEXT)
set(GETTEXT_LIBRARIES "-Wl,-Bstatic -lintl -liconv -Wl,-Bdynamic")
FIND_LIBRARY(UNISTRING_LIBRARY NAMES unistring libunistring
HINTS ${PC_GETTEXT_LIBDIR} ${PC_GETTEXT_LIBRARY_DIRS})

set(GETTEXT_LIBRARIES "-Wl,-Bstatic")

set(GETTEXT_LIBRARIES "${GETTEXT_LIBRARIES} -lintl")

set(GETTEXT_LIBRARIES "${GETTEXT_LIBRARIES} -liconv")

set(GETTEXT_LIBRARIES "${GETTEXT_LIBRARIES} -Wl,-Bdynamic")

if(UNISTRING_LIBRARY)
set(GETTEXT_LIBRARIES "${GETTEXT_LIBRARIES} -lunistring")
endif()

if(APPLE)
set(GETTEXT_LIBRARIES "${GETTEXT_LIBRARIES} -framework Carbon")
endif()
Expand All @@ -38,6 +52,8 @@ if(BUILD_STATIC)
HINTS ${PC_GNUTLS_LIBDIR} ${PC_GNUTLS_LIBRARY_DIRS})
FIND_LIBRARY(TASN1_LIBRARY NAMES tasn1 libtasn1
HINTS ${PC_GNUTLS_LIBDIR} ${PC_GNUTLS_LIBRARY_DIRS})
FIND_LIBRARY(IDN2_LIBRARY NAMES idn2 libidn2
HINTS ${PC_GETTEXT_LIBDIR} ${PC_GETTEXT_LIBRARY_DIRS})

set(GNUTLS_LIBRARIES "-Wl,-Bstatic -lgnutls")

Expand All @@ -50,6 +66,9 @@ if(BUILD_STATIC)
if(GCRYPT_LIBRARY)
set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -lgcrypt -lgpg-error")
endif()
if(IDN2_LIBRARY)
set(GETTEXT_LIBRARIES "${GETTEXT_LIBRARIES} -lidn2")
endif()

set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -Wl,-Bdynamic")

Expand All @@ -58,6 +77,10 @@ if(BUILD_STATIC)
set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -lcrypt32")
# And sockets
set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -lws2_32")
# link ncrypt and unistring statically
set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -Wl,-Bstatic -lncrypt -Wl,-Bdynamic")
# p11-kit only available as dynamic library for MSYS2 on Windows and dynamic linking of unistring is required
set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -lp11-kit -lunistring")
endif()

if(${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
Expand Down Expand Up @@ -135,6 +158,11 @@ if(BUILD_STATIC_GCC)
endif()
if(WIN32)
set(STATIC_BASE_LIBRARIES "${STATIC_BASE_LIBRARIES} -lmingw32 -lgcc_eh -lgcc -lmoldname -lmingwex -lmsvcrt")
find_package(Threads)
if(CMAKE_USE_PTHREADS_INIT)
# pthread has to be statically linked after libraries above and before kernel32
set(STATIC_BASE_LIBRARIES "${STATIC_BASE_LIBRARIES} -Wl,-Bstatic -lpthread -Wl,-Bdynamic")
endif()
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
Expand Down

0 comments on commit d164808

Please sign in to comment.