Browse Source

Create cmake procedure for ubxproto. Remove old one qmake based.
Rename licence file

semlanik 7 years ago
parent
commit
50d29911c7
8 changed files with 145 additions and 42 deletions
  1. 66 0
      CMakeLists.txt
  2. 0 0
      LICENSE
  3. 53 0
      cmake/CMakeGen.cmake
  4. 14 0
      cmake/Config.cmake.in
  5. 11 0
      cmake/ConfigVersion.cmake.in
  6. 1 0
      ubx.c
  7. 0 1
      ubxmessage.h
  8. 0 41
      ubxproto.pro

+ 66 - 0
CMakeLists.txt

@@ -0,0 +1,66 @@
+project(ubxproto C)
+cmake_minimum_required (VERSION 2.8)
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+
+set(UBXPROTO_VERSION 0.14.0)
+set(INSTALL_LIB_DIR ${INSTALL_LIB_DIR} CACHE PATH "Installation directory for libraries")
+set(INSTALL_INCLUDE_DIR "${INSTALL_INCLUDE_DIR}/ubxproto")
+
+#Define include paths
+include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR})
+
+#Set sources
+set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ubx.c)
+
+#Compile object files for both shared and static libraries
+add_library(ubxprotoobjects OBJECT ${SOURCES})
+
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
+
+set(PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/ubxaid.h
+                  ${CMAKE_CURRENT_SOURCE_DIR}/ubxcfg.h
+                  ${CMAKE_CURRENT_SOURCE_DIR}/ubx.h
+                  ${CMAKE_CURRENT_SOURCE_DIR}/ubxlog.h
+                  ${CMAKE_CURRENT_SOURCE_DIR}/ubxmessage.h
+                  ${CMAKE_CURRENT_SOURCE_DIR}/ubxmon.h
+                  ${CMAKE_CURRENT_SOURCE_DIR}/ubxrxm.h
+                  ${CMAKE_CURRENT_SOURCE_DIR}/ubxutils.h)
+
+#Static library target
+add_library(ubxprotostatic STATIC $<TARGET_OBJECTS:ubxprotoobjects>)
+set_target_properties(ubxprotostatic PROPERTIES OUTPUT_NAME ubxproto)
+set_target_properties(ubxprotostatic PROPERTIES LINKER_LANGUAGE C)
+set_target_properties(ubxprotostatic PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADER}")
+set(PROJECT_TARGETS ubxprotostatic)
+
+#Shared library target
+add_library(ubxprotoshared SHARED $<TARGET_OBJECTS:ubxprotoobjects>)
+set_target_properties(ubxprotoshared PROPERTIES LINKER_LANGUAGE C)
+set_target_properties(ubxprotoshared PROPERTIES OUTPUT_NAME ubxproto)
+set_target_properties(ubxprotoshared PROPERTIES SOVERSION ${UBXPROTO_VERSION})
+set(PROJECT_TARGETS ${PROJECT_TARGETS} ubxprotoshared)
+
+set(PROJECT_LIBS ubxproto)
+
+find_package(Doxygen)
+if(DOXYGEN_FOUND)
+  set(DOXYGEN_INPUT ${CMAKE_SOURCE_DIR})
+  set(DOXYGEN_OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/doc")
+  add_custom_target(doc COMMAND ${DOXYGEN_EXECUTABLE} ubxproto.doxyconf
+                    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+                    COMMENT "Generating doxygen documenation")
+else(DOXYGEN_FOUND)
+  message(STATUS "WARNING: Doxygen not found - Reference manual will not be created")
+endif(DOXYGEN_FOUND)
+
+install(TARGETS ${PROJECT_TARGETS}
+        EXPORT ${PROJECT_NAME}Targets
+        ARCHIVE DESTINATION "${SYSROOT}/${PREFIX}/${INSTALL_LIB_DIR}" COMPONENT staticlib
+        LIBRARY DESTINATION "${SYSROOT}/${PREFIX}/${INSTALL_LIB_DIR}" COMPONENT sharedlib
+        PUBLIC_HEADER DESTINATION "${SYSROOT}/${INSTALL_INCLUDE_DIR}"
+        COMPONENT dev
+        )
+install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/doc" DESTINATION "${SYSROOT}/${PREFIX}/${INSTALL_DOC_DIR}/${PROJECT_NAME}")
+
+#Generate cmake find library addtion
+include(CMakeGen)

+ 0 - 0
LGPLv3.txt → LICENSE


+ 53 - 0
cmake/CMakeGen.cmake

@@ -0,0 +1,53 @@
+set(_selfdir_CMakeGen
+"${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+
+if((WIN32) AND (NOT CYGWIN))
+  set(DEF_INSTALL_CMAKE_DIR CMake)
+else()
+  set(DEF_INSTALL_CMAKE_DIR usr/lib/cmake/${PROJECT_NAME})
+endif()
+set(INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH
+  "Installation directory for CMake files")
+  
+# Make relative paths absolute (needed later on)
+foreach(p LIB BIN INCLUDE CMAKE)
+  set(var INSTALL_${p}_DIR)
+  if((DEFINED ${var}) AND (NOT IS_ABSOLUTE "${${var}}"))
+    set(${var} "${SYSROOT}/${${var}}")
+  endif()
+endforeach()
+
+# Add all targets to the build-tree export set
+export(TARGETS ${PROJECT_TARGETS}
+  FILE "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake")
+
+# Export the package for use from the build-tree
+# (this registers the build-tree with a global CMake-registry)
+export(PACKAGE ${PROJECT_NAME})
+
+# Create the ${PROJECT_NAME}Config.cmake and ${PROJECT_NAME}ConfigVersion files
+file(RELATIVE_PATH REL_INCLUDE_DIR "${INSTALL_CMAKE_DIR}"
+   "${INSTALL_INCLUDE_DIR}")
+# ... for the build tree
+set(CONF_INCLUDE_DIRS "${INSTALL_INCLUDE_DIR}")
+configure_file(${_selfdir_CMakeGen}/Config.cmake.in
+  "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" @ONLY)
+# ... for the install tree
+string(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPER)
+set(CONF_INCLUDE_DIRS "\${${PROJECT_NAME_UPPER}_CMAKE_DIR}/${REL_INCLUDE_DIR}")
+configure_file(${_selfdir_CMakeGen}/Config.cmake.in
+  "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${PROJECT_NAME}Config.cmake" @ONLY)
+
+# ... for both
+configure_file(${_selfdir_CMakeGen}/ConfigVersion.cmake.in
+  "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" @ONLY)
+  
+# Install the <PROJECT_NAME>.cmake and <PROJECT_NAME>.cmake
+install(FILES
+  "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${PROJECT_NAME}Config.cmake"
+  "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
+  DESTINATION "${INSTALL_CMAKE_DIR}" COMPONENT dev)
+
+# Install the export set for use with the install-tree
+install(EXPORT ${PROJECT_NAME}Targets DESTINATION
+  "${INSTALL_CMAKE_DIR}" COMPONENT dev)

+ 14 - 0
cmake/Config.cmake.in

@@ -0,0 +1,14 @@
+# - Config file for the @PROJECT_NAME@ package
+# It defines the following variables
+#  UBXPROTO_INCLUDE_DIR - include directories for FooBar
+#  UBXPROTO_LIBRARIES    - libraries to link against
+
+# Compute paths
+get_filename_component(UBXPROTO_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
+set(UBXPROTO_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@")
+
+# Our library dependencies (contains definitions for IMPORTED targets)
+include("${UBXPROTO_CMAKE_DIR}/@PROJECT_NAME@Targets.cmake")
+
+# These are IMPORTED targets created by FooBarTargets.cmake
+set(UBXPROTO_LIBRARIES @PROJECT_LIBS@)

+ 11 - 0
cmake/ConfigVersion.cmake.in

@@ -0,0 +1,11 @@
+set(PACKAGE_VERSION "@UBXPROTO_VERSION@")
+
+# Check whether the requested PACKAGE_FIND_VERSION is compatible
+if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
+  set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+  set(PACKAGE_VERSION_COMPATIBLE TRUE)
+  if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
+    set(PACKAGE_VERSION_EXACT TRUE)
+  endif()
+endif()

+ 1 - 0
ubx.c

@@ -24,6 +24,7 @@
  * File: ubx.c
  */
 
+#include "portable_endian.h"
 #include "ubxmessage.h"
 #include "ubx.h"
 #include "malloc.h"

+ 0 - 1
ubxmessage.h

@@ -29,7 +29,6 @@
 #define UBXMESSAGE_H
 
 #include <stdio.h>
-#include "portable_endian.h"
 
 #ifdef __linux__
 #include <sys/types.h>

+ 0 - 41
ubxproto.pro

@@ -1,41 +0,0 @@
-#-------------------------------------------------
-#
-# Project created by QtCreator 2014-02-26T14:20:56
-#
-#-------------------------------------------------
-CONFIG -= qt
-
-TARGET = ubxproto
-TEMPLATE = lib
-
-DEFINES += UBLOXPROTO_LIBRARY
-
-SOURCES += \
-    ubx.c
-
-HEADERS +=\
-    ubxmessage.h \
-    ubx.h \
-    portable_endian.h \
-    ubxaid.h \
-    ubxcfg.h \
-    ubxlog.h \
-    ubxmon.h \
-    ubxrxm.h \
-    ubxutils.h
-
-OBJECTS_DIR = .obj
-MOC_DIR = .moc
-
-linux|linux-g++ {
-    header_files.files = $$HEADERS
-    header_files.path = $$PREFIX/usr/include
-    target.path = $$PREFIX/usr/lib
-    DEPLOYMENT += header_files target
-    INSTALLS += header_files
-    INSTALLS += target
-}
-
-win32 {
-    LIBS += -lws2_32
-}