swig: add BUILDSWIG macros to disable building of swig modules
[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.6-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]+(.*)" "\\1" VERSION_SHA1 "${VERSION}")
27 set (VERSION_SHORT "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
28
29 configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/version.c.in
30                 ${CMAKE_CURRENT_BINARY_DIR}/src/version.c)
31
32 # this is the library version, independant of git revision
33 set (maa_VERSION_MAJOR ${VERSION_MAJOR})
34 set (maa_VERSION_MINOR ${VERSION_MINOR})
35 set (maa_VERSION_PATCH ${VERSION_PATCH})
36 set (maa_VERSION_STRING ${maa_VERSION_MAJOR}.${maa_VERSION_MINOR}.${maa_VERSION_PATCH})
37
38 set (CMAKE_SWIG_FLAGS "")
39
40 option (GTEST "Build all gtests." OFF)
41 option (BUILDDOC "Build all doc." OFF)
42 option (BUILDSWIG "Build swig modules." ON)
43 option (BUILDSWIGPYTHON "Build swig python modules." ON)
44 option (BUILDSWIGNODE "Build swig node modules." ON)
45
46 if (GTEST)
47   enable_testing ()
48   add_subdirectory (tests)
49 endif ()
50
51 if (BUILDDOC)
52   # add a target to generate API documentation with Doxygen
53   find_package (Doxygen)
54   if (DOXYGEN_FOUND)
55     configure_file (${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
56     add_custom_target (doc
57       ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
58       WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
59       COMMENT "Generating API documentation with Doxygen" VERBATIM
60     )
61   endif (DOXYGEN_FOUND)
62 endif ()
63
64 add_subdirectory (src)
65 add_subdirectory (examples)