summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorBrian P. Hinz <bphinz@users.sf.net>2014-11-03 23:48:01 -0500
committerBrian P. Hinz <bphinz@users.sf.net>2014-11-03 23:48:01 -0500
commit86ad23eddd52cb11c5bdbb3b6505be6a0841f78b (patch)
treebcce775e39395075bb83d2a8167eda7f3a9104e7 /cmake
parent2773ff93719b1781366a7ef0d057bdd730c38d5e (diff)
parent0500ef8921b8e443d0624c41c229bcea3ea2729d (diff)
downloadtigervnc-86ad23eddd52cb11c5bdbb3b6505be6a0841f78b.tar.gz
tigervnc-86ad23eddd52cb11c5bdbb3b6505be6a0841f78b.zip
Merge remote-tracking branch 'upstream/master' into buildfixes
Diffstat (limited to 'cmake')
-rw-r--r--cmake/Modules/CMakeMacroLibtoolFile.cmake65
-rw-r--r--cmake/StaticBuild.cmake40
2 files changed, 79 insertions, 26 deletions
diff --git a/cmake/Modules/CMakeMacroLibtoolFile.cmake b/cmake/Modules/CMakeMacroLibtoolFile.cmake
index 0afb7a62..f2ea7f80 100644
--- a/cmake/Modules/CMakeMacroLibtoolFile.cmake
+++ b/cmake/Modules/CMakeMacroLibtoolFile.cmake
@@ -14,7 +14,21 @@ macro(libtool_create_control_file _target)
# 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("${library}" MATCHES "[^.+\\${CMAKE_STATIC_LIBRARY_SUFFIX}]$")
@@ -31,23 +45,46 @@ macro(libtool_create_control_file _target)
# No shared library extension matched. Check whether target is a CMake
# target.
get_target_property(_ltp ${library} TYPE)
- if(NOT _ltp AND NOT ${library} STREQUAL "general")
- # Not a CMake target, so use find_library() to attempt to locate the
+ if(_ltp OR ${library} STREQUAL "general")
+ # Target is a CMake target, so ignore (CMake targets are static
+ # libs in TigerVNC.)
+ 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, so extract the path and library name, then add the
+ # 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.
- 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}")
+ 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 shared library found, so ignore target.
+ # No library found, so ignore target.
endif()
- else()
- # Target is a CMake target, so ignore if (CMake targets are static
- # libs in TigerVNC.)
+ # Need to clear FL to get new results next loop
+ unset(FL CACHE)
endif()
endif()
else()
@@ -69,6 +106,8 @@ macro(libtool_create_control_file _target)
else()
# No absolute pathname found. Ignore it.
endif()
+ # Need to clear FL to get new results next loop
+ unset(FL CACHE)
endif()
endif()
endforeach()
@@ -76,10 +115,6 @@ macro(libtool_create_control_file _target)
# Write the libtool control file for the static library
get_filename_component(_lname ${_target_location} NAME_WE)
set(_laname ${CMAKE_CURRENT_BINARY_DIR}/${_lname}.la)
-
- if(BUILD_STATIC)
- set(_target_dependency_libs "${_target_dependency_libs} -L${CMAKE_BINARY_DIR}/staticlib")
- endif()
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")
diff --git a/cmake/StaticBuild.cmake b/cmake/StaticBuild.cmake
index 84fe0a8e..49706bd3 100644
--- a/cmake/StaticBuild.cmake
+++ b/cmake/StaticBuild.cmake
@@ -8,7 +8,7 @@
#
option(BUILD_STATIC
- "Link statically against most libraries, if possible" ON)
+ "Link statically against most libraries, if possible" OFF)
if(BUILD_STATIC)
message(STATUS "Attempting to link static binaries...")
@@ -39,7 +39,7 @@ if(BUILD_STATIC)
set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -ltasn1")
endif()
if(NETTLE_LIBRARY)
- set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -lnettle -lhogweed -lgmp -lcrypt32")
+ set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -lnettle -lhogweed -lgmp")
endif()
if(GCRYPT_LIBRARY)
set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -lgcrypt -lgpg-error")
@@ -47,31 +47,45 @@ if(BUILD_STATIC)
set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -Wl,-Bdynamic")
+ # GnuTLS uses various crypto-api stuff
+ if (WIN32)
+ set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -lcrypt32")
+ endif()
+
# nanosleep() lives here on Solaris
if(${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
- set(GNUTLS_LIBRARIES ${GNUTLS_LIBRARIES} -lrt)
+ set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -lrt")
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} comctl32)
+ set(FLTK_LIBRARIES "${FLTK_LIBRARIES} -lcomctl32")
elseif(APPLE)
- set(FLTK_LIBRARIES ${FLTK_LIBRARIES} "-framework Cocoa")
+ set(FLTK_LIBRARIES "${FLTK_LIBRARIES} -framework Cocoa")
else()
- set(FLTK_LIBRARIES ${FLTK_LIBRARIES} m)
+ set(FLTK_LIBRARIES "${FLTK_LIBRARIES} -lm")
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" fontconfig Xext -R/usr/sfw/lib)
+ set(FLTK_LIBRARIES "${FLTK_LIBRARIES} ${X11_Xcursor_LIB} ${X11_Xfixes_LIB} -Wl,-Bstatic -lXft -Wl,-Bdynamic -lfontconfig -lXext -R/usr/sfw/lib")
else()
- set(FLTK_LIBRARIES ${FLTK_LIBRARIES} "-Wl,-Bstatic -lXcursor -lXfixes -lXft -lfontconfig -lexpat -lfreetype -lbz2 -lXrender -lXext -lXinerama -Wl,-Bdynamic")
+ set(FLTK_LIBRARIES "${FLTK_LIBRARIES} -Wl,-Bstatic -lXcursor -lXfixes -lXft -lfontconfig -lexpat -lfreetype -lbz2 -lXrender -lXext -lXinerama -Wl,-Bdynamic")
endif()
- set(FLTK_LIBRARIES ${FLTK_LIBRARIES} X11)
+ set(FLTK_LIBRARIES "${FLTK_LIBRARIES} -lX11")
endif()
endif()
@@ -79,7 +93,7 @@ if(BUILD_STATIC)
# 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" X11)
+ set(X11_LIBRARIES "-Wl,-Bstatic -lXext -Wl,-Bdynamic -lX11")
if(X11_XTest_LIB)
set(X11_XTest_LIB "-Wl,-Bstatic -lXtst -Wl,-Bdynamic")
endif()
@@ -92,7 +106,11 @@ if(BUILD_STATIC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -nodefaultlibs")
set(STATIC_BASE_LIBRARIES "-Wl,-Bstatic -lstdc++ -Wl,-Bdynamic")
if(WIN32)
- set(STATIC_BASE_LIBRARIES "${STATIC_BASE_LIBRARIES} -lmingw32 -lmoldname -lmingwex -lgcc -lgcc_eh -lmsvcrt -lkernel32")
+ 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()