swig: use C++ generated class doc and include directly from maa.i
[contrib/mraa.git] / src / CMakeLists.txt
1 include_directories(
2   ${PROJECT_SOURCE_DIR}/api
3   ${PROJECT_SOURCE_DIR}/include
4 )
5
6 set (maa_LIB_SRCS
7   ${PROJECT_SOURCE_DIR}/src/maa.c
8   ${PROJECT_SOURCE_DIR}/src/gpio/gpio.c
9   ${PROJECT_SOURCE_DIR}/src/i2c/i2c.c
10   ${PROJECT_SOURCE_DIR}/src/i2c/smbus.c
11   ${PROJECT_SOURCE_DIR}/src/pwm/pwm.c
12   ${PROJECT_SOURCE_DIR}/src/spi/spi.c
13   ${PROJECT_SOURCE_DIR}/src/aio/aio.c
14   ${PROJECT_SOURCE_DIR}/src/intel_galileo_rev_d.c
15 # autogenerated version file
16   ${CMAKE_CURRENT_BINARY_DIR}/version.c
17 )
18
19 add_library (maa SHARED ${maa_LIB_SRCS})
20 target_link_libraries (maa ${CMAKE_THREAD_LIBS_INIT})
21
22 set_target_properties(
23    maa
24    PROPERTIES
25    SOVERSION ${maa_VERSION_MAJOR}
26    VERSION ${maa_VERSION_STRING}
27 )
28 install (DIRECTORY ${PROJECT_SOURCE_DIR}/api/ DESTINATION include/maa)
29
30 macro (maa_CREATE_INSTALL_PKGCONFIG generated_file install_location)
31   configure_file (${generated_file}.cmake ${CMAKE_CURRENT_BINARY_DIR}/${generated_file} @ONLY)
32   install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${generated_file} DESTINATION ${install_location})
33 endmacro (maa_CREATE_INSTALL_PKGCONFIG)
34 maa_create_install_pkgconfig (maa.pc lib${LIB_SUFFIX}/pkgconfig)
35
36 install (TARGETS maa DESTINATION lib)
37
38 if (DOXYGEN_FOUND)
39   set (CMAKE_SWIG_FLAGS -DDOXYGEN=${DOXYGEN_FOUND})
40   set (DOCCLASSES aio gpio i2c pwm spi)
41   foreach (_file ${DOCCLASSES})
42     add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}_class_doc.i
43       COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doxy2swig.py -n
44         ${CMAKE_BINARY_DIR}/xml/classmaa_1_1_${_file}.xml
45         ${CMAKE_CURRENT_BINARY_DIR}/${_file}_class_doc.i
46       DEPENDS ${CMAKE_BINARY_DIR}/xml/classmaa_1_1_${_file}.xml
47     )
48     add_custom_target (${_file}class_doc_i DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_file}_class_doc.i)
49     add_dependencies (${_file}class_doc_i doc)
50   endforeach ()
51   set (DOCFILES maa ${DOCCLASSES})
52   foreach (_file ${DOCFILES})
53     add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}_doc.i
54       COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doxy2swig.py -n
55         ${CMAKE_BINARY_DIR}/xml/${_file}_8h.xml
56         ${CMAKE_CURRENT_BINARY_DIR}/${_file}_doc.i
57       DEPENDS ${CMAKE_BINARY_DIR}/xml/${_file}_8h.xml
58     )
59     add_custom_target (${_file}doc_i DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_file}_doc.i)
60     add_dependencies (${_file}doc_i doc)
61   endforeach ()
62 endif ()
63
64 if (BUILDSWIG)
65   find_package (SWIG)
66   if (SWIG_FOUND)
67     include (${SWIG_USE_FILE})
68     set_source_files_properties (maa.i PROPERTIES SWIG_FLAGS "-I${CMAKE_BINARY_DIR}/src")
69
70     if (BUILDSWIGPYTHON)
71       add_subdirectory (python)
72     endif ()
73     if (BUILDSWIGNODE)
74       add_subdirectory (javascript)
75     endif ()
76   endif ()
77 endif ()