Нема описа

CMakeLists.txt 3.7KB

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