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")
8 set (LIB_INSTALL_DIR "lib${LIB_SUFFIX}" CACHE PATH "Installation path for libraries")
10 # Set CMAKE_LIB_INSTALL_DIR if not defined
11 include(GNUInstallDirs)
13 # Appends the cmake/modules path to MAKE_MODULE_PATH variable.
14 set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
16 # Make a version file containing the current version from git.
17 include (GetGitRevisionDescription)
18 git_describe (VERSION "--tags")
19 if ("x_${VERSION}" STREQUAL "x_GIT-NOTFOUND")
20 message (WARNING " - Install git to compile a production libmraa!")
21 set (VERSION "v0.6.1-dirty")
24 message (INFO " - libmraa Version ${VERSION}")
26 #parse the version information into pieces.
27 string (REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${VERSION}")
28 string (REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${VERSION}")
29 string (REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${VERSION}")
30 string (REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+).*" "\\1" VERSION_COMMIT "${VERSION}")
31 string (REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+-[0-9]+\\-(.*)" "\\1" VERSION_SHA1 "${VERSION}")
32 set (VERSION_SHORT "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
34 if ("${VERSION_COMMIT}" MATCHES "^v.*")
35 set (VERSION_COMMIT "")
38 configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/version.c.in
39 ${CMAKE_CURRENT_BINARY_DIR}/src/version.c)
41 # this is the library version, independant of git revision
42 set (mraa_VERSION_MAJOR ${VERSION_MAJOR})
43 set (mraa_VERSION_MINOR ${VERSION_MINOR})
44 set (mraa_VERSION_PATCH ${VERSION_PATCH})
45 set (mraa_VERSION_STRING ${mraa_VERSION_MAJOR}.${mraa_VERSION_MINOR}.${mraa_VERSION_PATCH})
47 set (CMAKE_SWIG_FLAGS "")
49 find_path (SYSTEM_USR_DIR "stdlib.h")
50 include_directories (${SYSTEM_USR_DIR})
52 option (GTEST "Build all gtests." OFF)
53 option (BUILDDOC "Build all doc." OFF)
54 option (BUILDSWIG "Build swig modules." ON)
55 option (BUILDSWIGPYTHON "Build swig python modules." ON)
56 option (BUILDSWIGNODE "Build swig node modules." ON)
57 option (IPK "Generate IPK using CPack" OFF)
60 target_architecture (DETECTED_ARCH)
61 message( INFO " - Target arch is ${DETECTED_ARCH}")
63 if (DETECTED_ARCH STREQUAL "i586" OR DETECTED_ARCH STREQUAL "x86_64"
64 OR DETECTED_ARCH STREQUAL "i386")
66 elseif (DETECTED_ARCH MATCHES "arm.*")
69 message(FATAL_ERROR "Only x86 and arm platforms currently supported")
74 add_subdirectory (tests)
78 # add a target to generate API documentation with Doxygen
79 find_package (Doxygen)
81 configure_file (${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
82 add_custom_target (doc
83 ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
84 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
85 COMMENT "Generating API documentation with Doxygen" VERBATIM
91 set(CPACK_GENERATOR "DEB" "TGZ")
92 set(OPKG_ARCH ${DETECTED_ARCH})
93 set(CPACK_BINARY_DIR ${CMAKE_BINARY_DIR})
94 set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Intel IoT-Devkit") #required
95 set(mraa_PACKAGE_ON_TAG ".")
96 if ("${VERSION_COMMIT}" STREQUAL "")
97 set(mraa_PACKAGE_ON_TAG "")
99 set(CPACK_PACKAGE_VERSION
100 "${mraa_VERSION_MAJOR}.${mraa_VERSION_MINOR}.${mraa_VERSION_PATCH}${mraa_PACKAGE_ON_TAG}${VERSION_COMMIT}")
101 set(CPACK_PACKAGE_NAME "libmraa${mraa_VERSION_MAJOR}")
102 set(CPACK_DEBIAN_PACKAGE_SECTION "libs")
103 set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${DETECTED_ARCH})
104 set(CPACK_SYSTEM_NAME ${DETECTED_ARCH})
105 set(CPACK_DEBIAN_PACKAGE_PROVIDES "libmraa-dev, libmraa-dbg, libmraa-doc, libmaa-dev, libmaa-dbg, libmaa-doc, libmaa0")
106 set(CPACK_DEBIAN_PACKAGE_REPLACES ${CPACK_DEBIAN_PACKAGE_PROVIDES})
107 set(CPACK_DEBIAN_PACKAGE_CONFLICTS ${CPACK_DEBIAN_PACKAGE_PROVIDES})
108 set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}")
112 add_subdirectory (src)
113 add_subdirectory (examples)