1 cmake_minimum_required(VERSION 2.6)
4 set(PROJECT_DESCRIPTION
5 "Communication library for Actions Micro AM7XXX based USB projectors and DPFs")
7 set(PROJECT_VER_MAJOR 0)
8 set(PROJECT_VER_MINOR 1)
9 set(PROJECT_VER_PATCH 4)
10 set(PROJECT_VER_EXTRA "")
12 "${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}.${PROJECT_VER_PATCH}${PROJECT_VER_EXTRA}")
14 "${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}")
17 ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/")
19 OPTION(STRICT_COMPILATION_CHECKS "Enable stricter compilation checks" OFF)
21 include (MaintenanceTools)
23 set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
24 set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
25 set(DOC_OUTPUT_PATH ${CMAKE_BINARY_DIR}/doc)
27 # Because cmake cannot deal sanely with multiline strings. SRSLY?
28 # See http://www.vtkedge.org/Bug/view.php?id=8362&nbn=8
30 string(REPLACE ";" " " _flags "${ARGN}")
31 set(${var} "${${var}} ${_flags}")
34 string(REGEX MATCH "clang" CMAKE_COMPILER_IS_CLANG "${CMAKE_C_COMPILER}")
36 if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
37 add_definitions(-Wall)
39 # let CFLAGS env override this
40 if(CMAKE_C_FLAGS STREQUAL "")
41 set(CMAKE_C_FLAGS "-std=c99 -pedantic -Wall -Wextra")
44 add_flags(CMAKE_C_FLAGS
55 -Wmissing-declarations
56 -Wmissing-format-attribute
60 -Wold-style-definition
75 add_flags(RELEASE_FLAGS
76 -Wp,-D_FORTIFY_SOURCE=2)
78 if (STRICT_COMPILATION_CHECKS)
79 add_flags(STRICT_FLAGS
81 # sign conversion warnings can be very noisy for a very little gain
83 # NOTE: Vanilla libusb-1.0.8 can't live with -pedantic-errors
89 if (CMAKE_COMPILER_IS_GNUCC)
90 add_flags(CMAKE_C_FLAGS
91 -Wunsafe-loop-optimizations
92 --param=ssp-buffer-size=4)
94 if (STRICT_COMPILATION_CHECKS)
95 add_flags(STRICT_FLAGS
96 # NOTE: GCC >= 4.6 is needed for -Wunused-but-set-variable
97 -Wunused-but-set-variable)
101 if (CMAKE_COMPILER_IS_CLANG)
102 if (STRICT_COMPILATION_CHECKS)
103 add_flags(STRICT_FLAGS
108 set(CMAKE_C_FLAGS_DEBUG "-O0 ${DEBUG_FLAGS} ${STRICT_FLAGS}")
109 set(CMAKE_C_FLAGS_RELEASE "-O2 ${RELEASE_FLAGS} ${STRICT_FLAGS}")
110 set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 ${RELEASE_FLAGS} ${DEBUG_FLAGS} ${STRICT_FLAGS}")
112 # Add library project
113 add_subdirectory(src)
114 add_subdirectory(examples)
115 add_subdirectory(doc)