maa: update to version 0.2.9
[contrib/mraa.git] / CMakeLists.txt
1 cmake_minimum_required (VERSION 2.8)
2 project (maa)
3
4 FIND_PACKAGE (Threads)
5
6 set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
7 set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall")
8
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})
11
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 libmaa!")
17   set (VERSION "v0.2.9-dirty")
18 endif ()
19
20 message (INFO " - MAA Version ${VERSION}")
21
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}")
29
30 if ("${VERSION_COMMIT}" MATCHES "^v.*")
31   set (VERSION_COMMIT "")
32 endif()
33
34 configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/version.c.in
35                 ${CMAKE_CURRENT_BINARY_DIR}/src/version.c)
36
37 # this is the library version, independant of git revision
38 set (maa_VERSION_MAJOR ${VERSION_MAJOR})
39 set (maa_VERSION_MINOR ${VERSION_MINOR})
40 set (maa_VERSION_PATCH ${VERSION_PATCH})
41 set (maa_VERSION_STRING ${maa_VERSION_MAJOR}.${maa_VERSION_MINOR}.${maa_VERSION_PATCH})
42
43 set (CMAKE_SWIG_FLAGS "")
44
45 option (GTEST "Build all gtests." OFF)
46 option (BUILDDOC "Build all doc." OFF)
47 option (BUILDSWIG "Build swig modules." ON)
48 option (BUILDSWIGPYTHON "Build swig python modules." ON)
49 option (BUILDSWIGNODE "Build swig node modules." ON)
50 option (IPK "Generate IPK using CPack" OFF)
51
52 if (GTEST)
53   enable_testing ()
54   add_subdirectory (tests)
55 endif ()
56
57 if (BUILDDOC)
58   # add a target to generate API documentation with Doxygen
59   find_package (Doxygen)
60   if (DOXYGEN_FOUND)
61     configure_file (${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
62     add_custom_target (doc
63       ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
64       WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
65       COMMENT "Generating API documentation with Doxygen" VERBATIM
66     )
67   endif (DOXYGEN_FOUND)
68 endif ()
69
70 if (IPK)
71   include (TargetArch)
72   target_architecture (DETECTED_ARCH)
73   message( INFO " - Target arch is ${DETECTED_ARCH}")
74
75   set(CPACK_GENERATOR "DEB")
76   set(OPKG_ARCH ${DETECTED_ARCH})
77   set(CPACK_BINARY_DIR ${CMAKE_BINARY_DIR})
78   set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Intel IoT-Devkit") #required
79   set(maa_PACKAGE_ON_TAG ".")
80   if ("${VERSION_COMMIT}" STREQUAL "")
81     set(maa_PACKAGE_ON_TAG "")
82   endif()
83   set(CPACK_PACKAGE_VERSION 
84       "${maa_VERSION_MAJOR}.${maa_VERSION_MINOR}.${maa_VERSION_PATCH}${maa_PACKAGE_ON_TAG}${VERSION_COMMIT}")
85   set(CPACK_PACKAGE_NAME "libmaa${maa_VERSION_MAJOR}")
86   set(CPACK_DEBIAN_PACKAGE_SECTION "libs")
87   set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${DETECTED_ARCH})
88   set(CPACK_SYSTEM_NAME ${DETECTED_ARCH})
89   set(CPACK_DEBIAN_PACKAGE_PROVIDES "libmaa-dev, libmaa-dbg, libmaa-doc")
90   set(CPACK_DEBIAN_PACKAGE_REPLACES ${CPACK_DEBIAN_PACKAGE_PROVIDES})
91   set(CPACK_DEBIAN_PACKAGE_CONFLICTS ${CPACK_DEBIAN_PACKAGE_PROVIDES})
92   set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}")
93   include (CPack)
94 endif()
95
96 add_subdirectory (src)
97 add_subdirectory (examples)