uwac: generate .pc and cmake find-module
authorBernhard Miklautz <bernhard.miklautz@thincast.com>
Thu, 25 Feb 2016 22:47:32 +0000 (23:47 +0100)
committerBernhard Miklautz <bernhard.miklautz@thincast.com>
Thu, 25 Feb 2016 22:47:32 +0000 (23:47 +0100)
uwac/CMakeLists.txt
uwac/uwac.pc.in [new file with mode: 0644]
uwac/uwacConfig.cmake.in [new file with mode: 0644]
uwac/uwacVersion.cmake [new file with mode: 0644]

index dc8c9f0..369ba2d 100644 (file)
@@ -25,3 +25,28 @@ set(UWAC_API_VERSION "${UWAC_VERSION_MAJOR}")
 
 add_subdirectory(include)
 add_subdirectory(libuwac)
+
+set(UWAC_INCLUDE_DIR "include/uwac${UWAC_VERSION_MAJOR}")
+# cmake package
+if(${CMAKE_VERSION} VERSION_GREATER "2.8.10")
+
+       export(PACKAGE uwac)
+
+       set(UWAC_CMAKE_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/uwac${UWAC_VERSION_MAJOR}")
+
+
+       configure_package_config_file(uwacConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/uwacConfig.cmake
+               INSTALL_DESTINATION ${UWAC_CMAKE_INSTALL_DIR}
+               PATH_VARS UWAC_INCLUDE_DIR)
+
+       write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/uwacConfigVersion.cmake
+               VERSION ${UWAC_VERSION} COMPATIBILITY SameMajorVersion)
+
+       install(FILES ${CMAKE_CURRENT_BINARY_DIR}/uwacConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/uwacConfigVersion.cmake
+               DESTINATION ${UWAC_CMAKE_INSTALL_DIR})
+
+       install(EXPORT uwac DESTINATION ${UWAC_CMAKE_INSTALL_DIR})
+endif()
+
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/uwac.pc.in ${CMAKE_CURRENT_BINARY_DIR}/uwac${UWAC_VERSION_MAJOR}.pc @ONLY)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/uwac${UWAC_VERSION_MAJOR}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
diff --git a/uwac/uwac.pc.in b/uwac/uwac.pc.in
new file mode 100644 (file)
index 0000000..66b477e
--- /dev/null
@@ -0,0 +1,15 @@
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=@CMAKE_INSTALL_PREFIX@
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
+includedir=${prefix}/@UWAC_INCLUDE_DIR@
+libs=-luwac
+
+Name: uwac 
+Description: uwac: using wayland as a client
+URL: http://www.freerdp.com/
+Version: @UWAC_VERSION@
+Requires:
+Requires.private: wayland-client xkbcommon freerdp@FREERDP_VERSION_MAJOR@
+Libs: -L${libdir} ${libs}
+Libs.private: 
+Cflags: -I${includedir}
diff --git a/uwac/uwacConfig.cmake.in b/uwac/uwacConfig.cmake.in
new file mode 100644 (file)
index 0000000..2433842
--- /dev/null
@@ -0,0 +1,9 @@
+@PACKAGE_INIT@
+
+set(UWAC_VERSION_MAJOR "@UWAC_VERSION_MAJOR@")
+set(UWAC_VERSION_MINOR "@UWAC_VERSION_MINOR@")
+set(UWAC_VERSION_REVISION "@UWAC_VERSION_REVISION@")
+
+set_and_check(UWAC_INCLUDE_DIR "@PACKAGE_UWAC_INCLUDE_DIR@")
+
+include("${CMAKE_CURRENT_LIST_DIR}/uwac.cmake")
diff --git a/uwac/uwacVersion.cmake b/uwac/uwacVersion.cmake
new file mode 100644 (file)
index 0000000..2a789d7
--- /dev/null
@@ -0,0 +1,46 @@
+# This is a basic version file for the Config-mode of find_package().
+# It is used by write_basic_package_version_file() as input file for configure_file()
+# to create a version-file which can be installed along a config.cmake file.
+#
+# The created file sets PACKAGE_VERSION_EXACT if the current version string and
+# the requested version string are exactly the same and it sets
+# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version,
+# but only if the requested major version is the same as the current one.
+# The variable CVF_VERSION must be set before calling configure_file().
+
+
+set(PACKAGE_VERSION "0.0.1")
+
+if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
+  set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+
+  if("0.0.1" MATCHES "^([0-9]+)\\.")
+    set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}")
+  else()
+    set(CVF_VERSION_MAJOR "0.0.1")
+  endif()
+
+  if("${PACKAGE_FIND_VERSION_MAJOR}" STREQUAL "${CVF_VERSION_MAJOR}")
+    set(PACKAGE_VERSION_COMPATIBLE TRUE)
+  else()
+    set(PACKAGE_VERSION_COMPATIBLE FALSE)
+  endif()
+
+  if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
+      set(PACKAGE_VERSION_EXACT TRUE)
+  endif()
+endif()
+
+
+# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
+if("${CMAKE_SIZEOF_VOID_P}"  STREQUAL ""  OR "8" STREQUAL "")
+   return()
+endif()
+
+# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
+if(NOT "${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
+  math(EXPR installedBits "8 * 8")
+  set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
+  set(PACKAGE_VERSION_UNSUITABLE TRUE)
+endif()