]> source.dussan.org Git - tigervnc.git/commitdiff
Building the Xvnc server requires libtool control files of rdr, rfb,
authorHenrik Andersson <henrik.andersson@cendio.com>
Thu, 9 Jun 2011 09:13:23 +0000 (09:13 +0000)
committerHenrik Andersson <henrik.andersson@cendio.com>
Thu, 9 Jun 2011 09:13:23 +0000 (09:13 +0000)
network and Xregion, which a cmake build will NOT produce, this macro
tries to create a libtool control file *.la for the specified target
with libdependencies for a static library target.

Due to the automake part of Xvnc references to libtool files in source
tree you need to build vncviewer using cmake in the source tree.

git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4482 3789f03b-4d11-0410-bbf8-ca57d06f2519

CMakeLists.txt
cmake/Modules/CMakeMacroLibtoolFile.cmake [new file with mode: 0644]
common/Xregion/CMakeLists.txt
common/network/CMakeLists.txt
common/rdr/CMakeLists.txt
common/rfb/CMakeLists.txt

index 33606267228b318d6e36c8713c6494af31648b00..6fc3514de10f8b9b04287c3f9004c33064f19fb5 100644 (file)
@@ -14,6 +14,8 @@ include(CheckTypeSize)
 include(CheckCSourceCompiles)
 include(CheckCXXSourceCompiles)
 
+include(CMakeMacroLibtoolFile)
+
 project(tigervnc)
 set(VERSION 1.0.90)
 
diff --git a/cmake/Modules/CMakeMacroLibtoolFile.cmake b/cmake/Modules/CMakeMacroLibtoolFile.cmake
new file mode 100644 (file)
index 0000000..514793e
--- /dev/null
@@ -0,0 +1,92 @@
+macro(libtool_create_control_file _target)
+  # Get target properties to fill into control file
+  get_target_property(_target_location ${_target} LOCATION)
+  get_target_property(_target_type ${_target} TYPE)
+
+  message("-- Creating static libtool control file for target ${_target}")
+  # No support for shared libraries as tigervnc only needs libtool config files
+  # for static libraries
+  if("${_target_type}" MATCHES "^[^STATIC_LIBRARY]$")
+    message(ERROR " -  trying to use libtool_create_control_file on non static library target.")
+  endif()
+
+  #
+  # Parse the target_LIB_DEPENDS of libraries to put into libtool control file
+  # as library dependencies and handle a few corners...
+  #
+  foreach(library ${${_target}_LIB_DEPENDS})
+    # Assume all entries as shared if not platform specific static library
+    # extension is matched
+    if("${library}" MATCHES "[^.+\\${CMAKE_STATIC_LIBRARY_SUFFIX}]$")
+      # Check if we have shared extenstion or not
+      if("${library}" MATCHES ".+\\${CMAKE_SHARED_LIBRARY_SUFFIX}$")
+        # We got an shared library lets cut it down to path and library name then
+       # add to libtool dependency libs, we always assume this is a absoult path
+       # because this is how cmake does..
+       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 suffix found, might also be a cmake target.
+       # Dont continue if we have a target name as lib due to we
+       # assume static linkage against out targets
+       get_target_property(_ltp ${library} TYPE)
+       if(${_ltp})
+         # No cmake target soo let's use find_library to see if we found any useful to use
+         find_library(FL ${library})
+         if(FL)
+           # Found library, lets cut it down to make libtool happy
+           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${_share_lib_path} -l${_shared_lib}")
+         else()
+           # Nothing found, lets ignore it
+         endif()
+       else()
+         # taget detected lets ignore it
+       endif()
+      endif()
+    else()
+      # Detected a static library, we want the absolute path so lets check if we have that
+      # if not try use find_library to get one
+      get_filename_component(_name ${library} NAME)
+      string(REPLACE "${_name}" "" _path ${library})
+      if(NOT "${_path}" MATCHES "")
+       # We got a full path to static library lets add as is to libtool library dependencies
+        set(_target_dependency_libs "${_target_dependency_libs} ${library}")
+      else()
+        # there no path for the static library lets use find_library to find one
+       find_library(FL ${library})
+       if(FL)
+         # got the library lets add it..
+         set(_target_dependency_libs "${_target_dependency_libs} ${FL}")
+       else()
+         # Nothing found, let's ignore it
+       endif()
+      endif()
+    endif()
+  endforeach()
+
+  # Write the libtool control file for static library
+  get_filename_component(_lname ${_target_location} NAME_WE)
+  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}.a'\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=''\n\n")
+
+endmacro()
\ No newline at end of file
index d12554c418c3d1a8679e66590d4dbb6dd1bc85ac..4cc4f0dd8380d9e7163d39ef6539db063d125ac8 100644 (file)
@@ -1,2 +1,4 @@
 add_library(Xregion STATIC
   Region.c)
+
+libtool_create_control_file(Xregion)
index 2afba7c09c93ed5446c815f64905b4e1487b340c..9f664de8c2761d7f09bc3e2cf55d2806675b3664 100644 (file)
@@ -2,3 +2,5 @@ include_directories(${CMAKE_SOURCE_DIR}/common)
 
 add_library(network STATIC
   TcpSocket.cxx)
+
+libtool_create_control_file(network)
index ac4313c9fd21662d34933c807fbd3a7c7bcb668c..6557932d72e3e31af787c02546db324a1813abce 100644 (file)
@@ -23,3 +23,5 @@ if(GNUTLS_FOUND)
 endif()
 
 target_link_libraries(rdr ${RDR_LIBRARIES})
+
+libtool_create_control_file(rdr)
index 70d52c0374e711410c760d6a32f3543605db2c17..4ca9349971ef5bcd0c48b8e2758640785fb78f50 100644 (file)
@@ -87,3 +87,5 @@ endif()
 add_library(rfb STATIC ${RFB_SOURCES})
 
 target_link_libraries(rfb ${RFB_LIBRARIES})
+
+libtool_create_control_file(rfb)