spi: add spi to CMakeLists.txt to build spi doc.i file
[contrib/mraa.git] / CMakeLists.txt
index cd442a4..33c622d 100644 (file)
@@ -1,18 +1,57 @@
 cmake_minimum_required (VERSION 2.8)
 project (maa)
 
-set(SWIG_EXECUTABLE /usr/bin/swig)
-FIND_PACKAGE(SWIG REQUIRED)
-INCLUDE(${SWIG_USE_FILE})
+set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
+set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall")
 
-SET(CMAKE_SWIG_FLAGS "")
+# Appends the cmake/modules path to MAKE_MODULE_PATH variable.
+set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
 
-option(test "Build all tests." OFF)
+# Make a version file containing the current version from git.
+include (GetGitRevisionDescription)
+git_describe (VERSION "--tags")
+if ("x_${VERSION}" STREQUAL "x_GIT-NOTFOUND")
+  message (WARNING " - Install git to compile a production libmaa!")
+  set (VERSION "v0.2.0-dirty")
+endif ()
 
-add_subdirectory (src)
-add_subdirectory (examples)
+message (INFO " - MAA Version ${VERSION}")
+
+#parse the version information into pieces.
+string (REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${VERSION}")
+string (REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${VERSION}")
+string (REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${VERSION}")
+string (REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+(.*)" "\\1" VERSION_SHA1 "${VERSION}")
+set (VERSION_SHORT "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
+
+configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/version.c.in
+                ${CMAKE_CURRENT_BINARY_DIR}/src/version.c)
+
+# this is the library version, independant of git revision
+set (maa_VERSION_MAJOR ${VERSION_MAJOR})
+set (maa_VERSION_MINOR ${VERSION_MINOR})
+set (maa_VERSION_PATCH ${VERSION_PATCH})
+set (maa_VERSION_STRING ${maa_VERSION_MAJOR}.${maa_VERSION_MINOR}.${maa_VERSION_PATCH})
+
+set (CMAKE_SWIG_FLAGS "")
+
+option (test "Build all tests." OFF)
 
 if (test)
   enable_testing ()
   add_subdirectory (tests)
-endif()
+endif ()
+
+# add a target to generate API documentation with Doxygen
+find_package (Doxygen)
+if (DOXYGEN_FOUND)
+  configure_file (${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
+  add_custom_target (doc
+    ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
+    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+    COMMENT "Generating API documentation with Doxygen" VERBATIM
+  )
+endif (DOXYGEN_FOUND)
+
+add_subdirectory (src)
+add_subdirectory (examples)