Fix doxygen doc generation if C++ wrapper is not built
[libftdi] / CMakeLists.txt
CommitLineData
0b2d00fc 1# Project
42ece760 2project(libftdi1)
c9a460e3
AL
3set(MAJOR_VERSION 1)
4set(MINOR_VERSION 0)
42ece760 5set(PACKAGE libftdi1)
4e79ea5f 6set(VERSION_STRING ${MAJOR_VERSION}.${MINOR_VERSION})
e18b7007 7set(VERSION ${VERSION_STRING})
89a3169e 8SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}")
0b2d00fc
MV
9
10# CMake
11if("${CMAKE_BUILD_TYPE}" STREQUAL "")
12 set(CMAKE_BUILD_TYPE Debug)
13endif("${CMAKE_BUILD_TYPE}" STREQUAL "")
14set(CMAKE_COLOR_MAKEFILE ON)
15cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
16
5b1e6a0a
UB
17add_definitions(-Wall)
18
0b2d00fc
MV
19# Debug build
20message("-- Build type: ${CMAKE_BUILD_TYPE}")
21if(${CMAKE_BUILD_TYPE} STREQUAL Debug)
22 add_definitions(-DDEBUG)
23endif(${CMAKE_BUILD_TYPE} STREQUAL Debug)
24
5478cd59 25FIND_PACKAGE(USB1 REQUIRED)
89a3169e
MK
26INCLUDE_DIRECTORIES(${LIBUSB_INCLUDE_DIR})
27
998266bf
EB
28# Find Boost (optional package)
29find_package(Boost)
30
0b2d00fc
MV
31# Set components
32set(CPACK_COMPONENTS_ALL sharedlibs staticlibs headers)
33set(CPACK_COMPONENT_SHAREDLIBS_DISPLAY_NAME "Shared libraries")
34set(CPACK_COMPONENT_STATICLIBS_DISPLAY_NAME "Static libraries")
35set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ Headers")
36
37set(CPACK_COMPONENT_SHAREDLIBS_DESCRIPTION
38"Shared library for general use.")
39set(CPACK_COMPONENT_STATICLIBS_DESCRIPTION
42ece760 40"Static library, good if you want to embed libftdi1 in your application.")
0b2d00fc
MV
41set(CPACK_COMPONENT_HEADERS_DESCRIPTION
42"C/C++ header files.")
43
44set(CPACK_COMPONENT_SHAREDLIBS_GROUP "Development")
45set(CPACK_COMPONENT_STATICLIBS_GROUP "Development")
e5c0c219 46set(CPACK_COMPONENT_HEADERS_GROUP "Development")
0b2d00fc 47
08dc0034
MZ
48# automatically set lib suffix
49if ( UNIX AND NOT APPLE AND NOT CMAKE_CROSSCOMPILING AND NOT EXISTS "/etc/debian_version" )
50 if ( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT LIB_SUFFIX )
51 set ( LIB_SUFFIX 64 )
52 endif ()
53endif ()
b3f439b1 54
998266bf 55if(NOT APPLE)
998266bf 56 if(CMAKE_SIZEOF_VOID_P EQUAL 4)
998266bf
EB
57 SET(PACK_ARCH "")
58 else(CMAKE_SIZEOF_VOID_P EQUAL 8)
998266bf
EB
59 SET(PACK_ARCH .x86_64)
60 endif(CMAKE_SIZEOF_VOID_P EQUAL 4)
61else(NOT APPLE)
998266bf
EB
62 SET(PACK_ARCH "")
63endif(NOT APPLE)
20a28968 64
0b2d00fc
MV
65# Package information
66set(CPACK_PACKAGE_VERSION ${VERSION_STRING})
d6979c8f 67set(CPACK_PACKAGE_CONTACT "Intra2net AG <libftdi@developer.intra2net.com>")
42ece760 68set(CPACK_PACKAGE_DESCRIPTION "libftdi1 library.")
0b2d00fc
MV
69set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${CPACK_PACKAGE_DESCRIPTION}
70 )
71# Package settings
72if(${UNIX})
73 set(CPACK_GENERATOR "DEB;RPM")
74 set(CPACK_CMAKE_GENERATOR "Unix Makefiles")
75 set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
20a28968 76 set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}${PACK_ARCH})
0b2d00fc
MV
77endif(${UNIX})
78
79if(${WIN32})
80 set(CPACK_GENERATOR "NSIS")
81 set(CPACK_CMAKE_GENERATOR "MinGW Makefiles")
82 set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
83 set(CPACK_PACKAGE_VENDOR "")
42ece760 84 set(CPACK_PACKAGE_INSTALL_DIRECTORY "libftdi1")
0b2d00fc 85 set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-win32")
42ece760 86 set(CPACK_NSIS_DISPLAY_NAME "libftdi1")
0b2d00fc
MV
87 set(CPACK_NSIS_MODIFY_PATH "ON")
88endif(${WIN32})
89
3ab8f642 90set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE)
0b2d00fc 91
4e79ea5f
TJ
92set(CPACK_SOURCE_GENERATOR TGZ)
93set(CPACK_SOURCE_IGNORE_FILES "\\\\.git")
94set(CPACK_SOURCE_PACKAGE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME})
95
0b2d00fc
MV
96# Subdirectories
97if(${UNIX})
98 set(CPACK_SET_DESTDIR "ON")
99endif(${UNIX})
100
101add_subdirectory(src)
102add_subdirectory(ftdipp)
fdfee603 103add_subdirectory(bindings)
a9dddb4d 104add_subdirectory(ftdi_eeprom)
0b2d00fc
MV
105add_subdirectory(examples)
106add_subdirectory(packages)
a87a0712 107add_subdirectory(test)
0b2d00fc 108
5c561052
TJ
109# "make dist" target
110set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${VERSION_STRING})
111add_custom_target(dist
112 COMMAND git archive --prefix=${ARCHIVE_NAME}/ HEAD
113 | bzip2 > ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2
114 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
a9345150
TJ
115
116
117# Documentation
a03fea79
GE
118
119option(DOCUMENTATION "Generate API documentation with Doxygen" ON)
120
e18b7007 121
a9345150 122find_package(Doxygen)
a03fea79 123if(DOCUMENTATION AND DOXYGEN_FOUND)
a9345150 124
a9345150
TJ
125 # Find doxy config
126 message(STATUS "Doxygen found.")
a9345150
TJ
127
128 # Copy doxy.config.in
5f70b4c1
MZ
129 set(top_srcdir ${CMAKE_SOURCE_DIR})
130 configure_file(${CMAKE_SOURCE_DIR}/doc/Doxyfile.in ${CMAKE_BINARY_DIR}/Doxyfile )
a9345150
TJ
131
132 # Run doxygen
133 add_custom_command(
5f70b4c1
MZ
134 OUTPUT ${CMAKE_BINARY_DIR}/doc/html/index.html
135 COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/doc
136 COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile
137 DEPENDS ${c_headers};${c_sources};${cpp_sources};${cpp_headers}
a9345150
TJ
138 )
139
140 add_custom_target(docs ALL DEPENDS ${CMAKE_BINARY_DIR}/doc/html/index.html)
141
a03fea79
GE
142 message(STATUS "Generating API documentation with Doxygen")
143else(DOCUMENTATION AND DOXYGEN_FOUND)
144 message(STATUS "Not generating API documentation")
145endif(DOCUMENTATION AND DOXYGEN_FOUND)
a9345150 146
e5c0c219
MV
147# PkgConfig
148set(prefix ${CMAKE_INSTALL_PREFIX})
149set(exec_prefix ${CMAKE_INSTALL_PREFIX}/bin)
150set(includedir ${CMAKE_INSTALL_PREFIX}/include/${PROJECT_NAME})
151
152if(${UNIX})
20a28968 153 set(libdir ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
e5c0c219
MV
154endif(${UNIX})
155if(${WIN32})
156 set(libdir ${CMAKE_INSTALL_PREFIX}/bin)
157endif(${WIN32})
158
d954c1e4 159configure_file(${CMAKE_SOURCE_DIR}/libftdi1.spec.in ${CMAKE_BINARY_DIR}/libftdi1.spec @ONLY)
1199c9b5
TJ
160configure_file(${CMAKE_SOURCE_DIR}/libftdi1.pc.in ${CMAKE_BINARY_DIR}/libftdi1.pc @ONLY)
161configure_file(${CMAKE_SOURCE_DIR}/libftdipp1.pc.in ${CMAKE_BINARY_DIR}/libftdipp1.pc @ONLY)
162install(FILES ${CMAKE_BINARY_DIR}/libftdi1.pc ${CMAKE_BINARY_DIR}/libftdipp1.pc
20a28968 163 DESTINATION lib${LIB_SUFFIX}/pkgconfig)
e5c0c219 164
603b0de5 165if(${UNIX})
7a07197c
TJ
166 configure_file(${CMAKE_SOURCE_DIR}/libftdi1-config.in ${CMAKE_BINARY_DIR}/libftdi1-config @ONLY)
167 install(PROGRAMS ${CMAKE_BINARY_DIR}/libftdi1-config DESTINATION bin)
603b0de5
TJ
168endif(${UNIX})
169
0b2d00fc 170include(CPack)