No Description

CMakeLists.txt 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. # Make a version file containing the current version from git.
  15. include (GetGitRevisionDescription)
  16. git_describe (VERSION "--tags")
  17. if ("x_${VERSION}" STREQUAL "x_GIT-NOTFOUND")
  18. message (WARNING " - Install git to compile a production libmraa!")
  19. set (VERSION "v0.1.8-dirty")
  20. endif ()
  21. message (INFO " - UPM Version ${VERSION}")
  22. #parse the version information into pieces.
  23. string (REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${VERSION}")
  24. string (REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${VERSION}")
  25. string (REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${VERSION}")
  26. string (REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+).*" "\\1" VERSION_COMMIT "${VERSION}")
  27. string (REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+-[0-9]+\\-(.*)" "\\1" VERSION_SHA1 "${VERSION}")
  28. if ("${VERSION_COMMIT}" MATCHES "^v.*")
  29. set (VERSION_COMMIT "")
  30. endif()
  31. set (upm_VERSION_MAJOR ${VERSION_MAJOR})
  32. set (upm_VERSION_MINOR ${VERSION_MINOR})
  33. set (upm_VERSION_PATCH ${VERSION_PATCH})
  34. set (upm_VERSION_STRING ${upm_VERSION_MAJOR}.${upm_VERSION_MINOR}.${upm_VERSION_PATCH})
  35. set (CMAKE_SWIG_FLAGS "")
  36. option (IPK "Generate IPK using CPack" OFF)
  37. option (BUILDDOC "Build all doc." OFF)
  38. option (BUILDSWIG "Build swig modules." ON)
  39. option (BUILDSWIGPYTHON "Build swig python modules." ON)
  40. option (BUILDSWIGNODE "Build swig node modules." ON)
  41. if (BUILDDOC)
  42. # add a target to generate API documentation with Doxygen
  43. find_package (Doxygen)
  44. if (DOXYGEN_FOUND)
  45. configure_file (${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
  46. add_custom_target (doc
  47. ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
  48. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  49. COMMENT "Generating API documentation with Doxygen" VERBATIM
  50. )
  51. endif (DOXYGEN_FOUND)
  52. endif()
  53. if (IPK)
  54. include (TargetArch)
  55. target_architecture (DETECTED_ARCH)
  56. message( INFO " - Target arch is ${DETECTED_ARCH}")
  57. set(CPACK_GENERATOR "DEB" "TGZ")
  58. set(OPKG_ARCH ${DETECTED_ARCH})
  59. set(CPACK_BINARY_DIR ${CMAKE_BINARY_DIR})
  60. set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Intel IoT-Devkit") #required
  61. set(upm_PACKAGE_ON_TAG ".")
  62. if ("${VERSION_COMMIT}" STREQUAL "")
  63. set(upm_PACKAGE_ON_TAG "")
  64. endif()
  65. set(CPACK_PACKAGE_VERSION
  66. "${upm_VERSION_MAJOR}.${upm_VERSION_MINOR}.${upm_VERSION_PATCH}${upm_PACKAGE_ON_TAG}${VERSION_COMMIT}")
  67. set(CPACK_PACKAGE_NAME "upm")
  68. set(CPACK_DEBIAN_PACKAGE_SECTION "libs")
  69. set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${DETECTED_ARCH})
  70. set(CPACK_SYSTEM_NAME ${DETECTED_ARCH})
  71. set(CPACK_DEBIAN_PACKAGE_DEPENDS "libmraa0 (>= ${MRAA_VERSION})")
  72. set(CPACK_DEBIAN_PACKAGE_PROVIDES "upm-dev, upm-dbg, upm-doc")
  73. set(CPACK_DEBIAN_PACKAGE_REPLACES ${CPACK_DEBIAN_PACKAGE_PROVIDES})
  74. set(CPACK_DEBIAN_PACKAGE_CONFLICTS ${CPACK_DEBIAN_PACKAGE_PROVIDES})
  75. set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}")
  76. include (CPack)
  77. endif()
  78. add_subdirectory (src)
  79. add_subdirectory (examples)