7db3067e2de39e032e5fb35aaa36f9177eea5798
[libam7xxx.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.6)
2 project(libam7xxx C)
3
4 set(PROJECT_DESCRIPTION
5   "Communication library for Actions Micro AM7XXX based USB projectors and DPFs")
6
7 set(PROJECT_VER_MAJOR 0)
8 set(PROJECT_VER_MINOR 0)
9 set(PROJECT_VER_PATCH 1)
10 set(PROJECT_VER_EXTRA "")
11 set(PROJECT_VER
12   "${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}.${PROJECT_VER_PATCH}${PROJECT_VER_EXTRA}")
13 set(PROJECT_APIVER
14   "${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}")
15
16 set(CMAKE_MODULE_PATH 
17   ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/")
18
19 include (MaintenanceTools)
20
21 set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
22 set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
23 set(DOC_OUTPUT_PATH ${CMAKE_BINARY_DIR}/doc)
24
25 # Because cmake cannot deal sanely with multiline strings. SRSLY?
26 # See http://www.vtkedge.org/Bug/view.php?id=8362&nbn=8
27 macro(add_flags var)
28   string(REPLACE ";" " " _flags "${ARGN}")
29   set(${var} "${${var}} ${_flags}")
30 endmacro(add_flags)
31
32 if (CMAKE_COMPILER_IS_GNUCC)
33   add_definitions(-Wall)
34
35   # let CFLAGS env override this
36   if(CMAKE_C_FLAGS STREQUAL "")
37     set(CMAKE_C_FLAGS "-std=c99 -pedantic -Wall -Wextra -O2")
38   endif()
39
40   # Don't make pedantic checks errors,
41   # as vanilla libusb-1.0.8 can't live with that
42   #add_flags(CMAKE_C_FLAGS -pedantic-errors)
43
44   # GCC >= 4.6
45   #add_flags(CMAKE_C_FLAGS -Wunused-but-set-variable)
46
47   add_flags(CMAKE_C_FLAGS
48     -fno-common
49     -Wall
50     -Wextra
51     -Wformat=2
52     -Winit-self
53     -Winline
54     -Wpacked
55     -Wp,-D_FORTIFY_SOURCE=2
56     -Wpointer-arith
57     -Wlarger-than-65500
58     -Wmissing-declarations
59     -Wmissing-format-attribute
60     -Wmissing-noreturn
61     -Wmissing-prototypes
62     -Wnested-externs
63     -Wold-style-definition
64     -Wredundant-decls
65     -Wsign-compare
66     -Wstrict-aliasing=2
67     -Wstrict-prototypes
68     -Wswitch-enum
69     -Wundef
70     -Wunreachable-code
71     -Wunsafe-loop-optimizations
72     -Wwrite-strings
73     -fstack-protector
74     --param=ssp-buffer-size=4)
75 endif()
76
77 set(CMAKE_C_FLAGS_DEBUG "-g -DDEBUG=1 -Werror")
78 set(CMAKE_C_FLAGS_RELEASE "-O2")
79 set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")
80
81 # Add library project
82 add_subdirectory(src)
83 add_subdirectory(doc)