1 cmake_minimum_required (VERSION 2.8)
6 set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -fno-omit-frame-pointer")
7 set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall")
9 # Appends the cmake/modules path to MAKE_MODULE_PATH variable.
10 set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
12 # Make a version file containing the current version from git.
13 include (GetGitRevisionDescription)
14 git_describe (VERSION "--tags")
15 if ("x_${VERSION}" STREQUAL "x_GIT-NOTFOUND")
16 message (WARNING " - Install git to compile a production libmraa!")
17 set (VERSION "v0.4.5-dirty")
20 message (INFO " - MRAA 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 set (VERSION_SHORT "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
30 if ("${VERSION_COMMIT}" MATCHES "^v.*")
31 set (VERSION_COMMIT "")
34 configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/version.c.in
35 ${CMAKE_CURRENT_BINARY_DIR}/src/version.c)
37 # this is the library version, independant of git revision
38 set (mraa_VERSION_MAJOR ${VERSION_MAJOR})
39 set (mraa_VERSION_MINOR ${VERSION_MINOR})
40 set (mraa_VERSION_PATCH ${VERSION_PATCH})
41 set (mraa_VERSION_STRING ${mraa_VERSION_MAJOR}.${mraa_VERSION_MINOR}.${mraa_VERSION_PATCH})
43 set (CMAKE_SWIG_FLAGS "")
45 find_path (SYSTEM_USR_DIR "stdlib.h")
46 include_directories (${SYSTEM_USR_DIR})
48 option (GTEST "Build all gtests." OFF)
49 option (BUILDDOC "Build all doc." OFF)
50 option (BUILDSWIG "Build swig modules." ON)
51 option (BUILDSWIGPYTHON "Build swig python modules." ON)
52 option (BUILDSWIGNODE "Build swig node modules." ON)
53 option (IPK "Generate IPK using CPack" OFF)
57 add_subdirectory (tests)
61 # add a target to generate API documentation with Doxygen
62 find_package (Doxygen)
64 configure_file (${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
65 add_custom_target (doc
66 ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
67 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
68 COMMENT "Generating API documentation with Doxygen" VERBATIM
75 target_architecture (DETECTED_ARCH)
76 message( INFO " - Target arch is ${DETECTED_ARCH}")
78 set(CPACK_GENERATOR "DEB")
79 set(OPKG_ARCH ${DETECTED_ARCH})
80 set(CPACK_BINARY_DIR ${CMAKE_BINARY_DIR})
81 set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Intel IoT-Devkit") #required
82 set(mraa_PACKAGE_ON_TAG ".")
83 if ("${VERSION_COMMIT}" STREQUAL "")
84 set(mraa_PACKAGE_ON_TAG "")
86 set(CPACK_PACKAGE_VERSION
87 "${mraa_VERSION_MAJOR}.${mraa_VERSION_MINOR}.${mraa_VERSION_PATCH}${mraa_PACKAGE_ON_TAG}${VERSION_COMMIT}")
88 set(CPACK_PACKAGE_NAME "libmraa${mraa_VERSION_MAJOR}")
89 set(CPACK_DEBIAN_PACKAGE_SECTION "libs")
90 set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${DETECTED_ARCH})
91 set(CPACK_SYSTEM_NAME ${DETECTED_ARCH})
92 set(CPACK_DEBIAN_PACKAGE_PROVIDES "libmraa-dev, libmraa-dbg, libmraa-doc, libmaa-dev, libmaa-dbg, libmaa-doc, libmaa0")
93 set(CPACK_DEBIAN_PACKAGE_REPLACES ${CPACK_DEBIAN_PACKAGE_PROVIDES})
94 set(CPACK_DEBIAN_PACKAGE_CONFLICTS ${CPACK_DEBIAN_PACKAGE_PROVIDES})
95 set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}")
99 add_subdirectory (src)
100 add_subdirectory (examples)