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 0)
9 set(PROJECT_VER_PATCH 1)
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 set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
20 set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
21 set(DOC_OUTPUT_PATH ${CMAKE_BINARY_DIR}/doc)
23 # Because cmake cannot deal sanely with multiline strings. SRSLY?
24 # See http://www.vtkedge.org/Bug/view.php?id=8362&nbn=8
26 string(REPLACE ";" " " _flags "${ARGN}")
27 set(${var} "${${var}} ${_flags}")
30 if (CMAKE_COMPILER_IS_GNUCC)
31 add_definitions(-Wall)
33 # let CFLAGS env override this
34 if(CMAKE_C_FLAGS STREQUAL "")
35 set(CMAKE_C_FLAGS "-std=c99 -pedantic -Wall -Wextra -O2")
38 # Don't make pedantic checks errors,
39 # as vanilla libusb-1.0.8 can't live with that
40 #add_flags(CMAKE_C_FLAGS -pedantic-errors)
43 #add_flags(CMAKE_C_FLAGS -Wunused-but-set-variable)
45 add_flags(CMAKE_C_FLAGS
53 -Wp,-D_FORTIFY_SOURCE=2
56 -Wmissing-declarations
57 -Wmissing-format-attribute
61 -Wold-style-definition
69 -Wunsafe-loop-optimizations
72 --param=ssp-buffer-size=4)
75 set(CMAKE_C_FLAGS_DEBUG "-g -DDEBUG=1 -Werror")
76 set(CMAKE_C_FLAGS_RELEASE "-O2")
77 set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")
79 # Use git for some maintainance tasks
82 set(ARCHIVE_PREFIX ${CMAKE_PROJECT_NAME}-${PROJECT_VER})
83 find_program(DATE_EXECUTABLE date DOC "date command line program")
85 message(STATUS "Found date: " ${DATE_EXECUTABLE})
86 message(STATUS "Generator is: " ${CMAKE_GENERATOR})
88 # XXX: using $(shell CMD) works only with Unix Makefile
89 if (CMAKE_GENERATOR STREQUAL "Unix Makefiles")
90 message(STATUS " - \"git archive\" will use the date too!")
91 set(ARCHIVE_PREFIX ${ARCHIVE_PREFIX}-$\(shell ${DATE_EXECUTABLE} +%Y%m%d%H%M\))
94 add_custom_target(archive
95 COMMAND ${GIT_EXECUTABLE} archive -o \"${ARCHIVE_PREFIX}.tar.gz\" --prefix=\"${ARCHIVE_PREFIX}/\" HEAD
96 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
98 add_custom_target(changelog
99 COMMAND ${GIT_EXECUTABLE} log --pretty=\"format:%ai %aN <%aE>%n%n%x09* %s%d%n\" > ChangeLog
100 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
103 # Add library project
104 add_subdirectory(src)
105 add_subdirectory(doc)