No Description

CMakeLists.txt 3.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. cmake_minimum_required (VERSION 2.8.11)
  2. project (upm)
  3. find_package (SWIG)
  4. if (SWIG_FOUND)
  5. include (${SWIG_USE_FILE})
  6. endif ()
  7. find_package (Threads REQUIRED)
  8. find_package (PkgConfig REQUIRED)
  9. # force the libmraa version to be the required version
  10. pkg_check_modules (MRAA REQUIRED mraa>=0.5.2)
  11. message (INFO " found libmraa version: ${MRAA_VERSION}")
  12. # Appends the cmake/modules path to MAKE_MODULE_PATH variable.
  13. set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
  14. set (LIB_INSTALL_DIR "lib${LIB_SUFFIX}" CACHE PATH "Installation path for libraries")
  15. # Set CMAKE_LIB_INSTALL_DIR if not defined
  16. include(GNUInstallDirs)
  17. # Make a version file containing the current version from git.
  18. include (GetGitRevisionDescription)
  19. git_describe (VERSION "--tags")
  20. if ("x_${VERSION}" STREQUAL "x_GIT-NOTFOUND")
  21. message (WARNING " - Install git to compile a production libmraa!")
  22. set (VERSION "v0.1.8-dirty")
  23. endif ()
  24. message (INFO " - UPM Version ${VERSION}")
  25. #parse the version information into pieces.
  26. string (REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${VERSION}")
  27. string (REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${VERSION}")
  28. string (REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${VERSION}")
  29. string (REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+).*" "\\1" VERSION_COMMIT "${VERSION}")
  30. string (REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+-[0-9]+\\-(.*)" "\\1" VERSION_SHA1 "${VERSION}")
  31. if ("${VERSION_COMMIT}" MATCHES "^v.*")
  32. set (VERSION_COMMIT "")
  33. endif()
  34. set (upm_VERSION_MAJOR ${VERSION_MAJOR})
  35. set (upm_VERSION_MINOR ${VERSION_MINOR})
  36. set (upm_VERSION_PATCH ${VERSION_PATCH})
  37. set (upm_VERSION_STRING ${upm_VERSION_MAJOR}.${upm_VERSION_MINOR}.${upm_VERSION_PATCH})
  38. set (CMAKE_SWIG_FLAGS "")
  39. option (IPK "Generate IPK using CPack" OFF)
  40. option (BUILDDOC "Build all doc." OFF)
  41. option (BUILDSWIG "Build swig modules." ON)
  42. option (BUILDSWIGPYTHON "Build swig python modules." ON)
  43. option (BUILDSWIGNODE "Build swig node modules." ON)
  44. if (BUILDDOC)
  45. # add a target to generate API documentation with Doxygen
  46. find_package (Doxygen)
  47. if (DOXYGEN_FOUND)
  48. configure_file (${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
  49. add_custom_target (doc
  50. ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
  51. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  52. COMMENT "Generating API documentation with Doxygen" VERBATIM
  53. )
  54. endif (DOXYGEN_FOUND)
  55. endif()
  56. if (IPK)
  57. include (TargetArch)
  58. target_architecture (DETECTED_ARCH)
  59. message( INFO " - Target arch is ${DETECTED_ARCH}")
  60. set(CPACK_GENERATOR "DEB" "TGZ")
  61. set(OPKG_ARCH ${DETECTED_ARCH})
  62. set(CPACK_BINARY_DIR ${CMAKE_BINARY_DIR})
  63. set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Intel IoT-Devkit") #required
  64. set(upm_PACKAGE_ON_TAG ".")
  65. if ("${VERSION_COMMIT}" STREQUAL "")
  66. set(upm_PACKAGE_ON_TAG "")
  67. endif()
  68. set(CPACK_PACKAGE_VERSION
  69. "${upm_VERSION_MAJOR}.${upm_VERSION_MINOR}.${upm_VERSION_PATCH}${upm_PACKAGE_ON_TAG}${VERSION_COMMIT}")
  70. set(CPACK_PACKAGE_NAME "upm")
  71. set(CPACK_DEBIAN_PACKAGE_SECTION "libs")
  72. set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${DETECTED_ARCH})
  73. set(CPACK_SYSTEM_NAME ${DETECTED_ARCH})
  74. set(CPACK_DEBIAN_PACKAGE_DEPENDS "libmraa0 (>= ${MRAA_VERSION})")
  75. set(CPACK_DEBIAN_PACKAGE_PROVIDES "upm-dev, upm-dbg, upm-doc")
  76. set(CPACK_DEBIAN_PACKAGE_REPLACES ${CPACK_DEBIAN_PACKAGE_PROVIDES})
  77. set(CPACK_DEBIAN_PACKAGE_CONFLICTS ${CPACK_DEBIAN_PACKAGE_PROVIDES})
  78. set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}")
  79. include (CPack)
  80. endif()
  81. add_subdirectory (src)
  82. add_subdirectory (examples)