|
| 1 | +project(git-hooks C) |
| 2 | + |
| 3 | +# default to Debug builds |
| 4 | +if(NOT CMAKE_BUILD_TYPE) |
| 5 | + set(CMAKE_BUILD_TYPE Debug) |
| 6 | +endif(NOT CMAKE_BUILD_TYPE) |
| 7 | + |
| 8 | +# disable assertions for non-debug builds |
| 9 | +if(NOT CMAKE_BUILD_TYPE MATCHES Debug) |
| 10 | + add_definitions(-DNDEBUG) |
| 11 | +endif(NOT CMAKE_BUILD_TYPE MATCHES Debug) |
| 12 | + |
| 13 | +# set minimum CMake version |
| 14 | +cmake_minimum_required(VERSION 2.4) |
| 15 | + |
| 16 | +# check for certain header files |
| 17 | +include(CheckIncludeFile) |
| 18 | +check_include_file(ctype.h HAVE_CTYPE_H) |
| 19 | +check_include_file(dirent.h HAVE_DIRENT_H) |
| 20 | +check_include_file(errno.h HAVE_ERRNO_H) |
| 21 | +check_include_file(signal.h HAVE_SIGNAL_H) |
| 22 | +check_include_file(stdarg.h HAVE_STDARG_H) |
| 23 | +check_include_file(stdio.h HAVE_STDIO_H) |
| 24 | +check_include_file(stdlib.h HAVE_STDLIB_H) |
| 25 | +check_include_file(string.h HAVE_STRING_H) |
| 26 | +check_include_file(sys/wait.h HAVE_SYS_WAIT_H) |
| 27 | +check_include_file(sys/types.h HAVE_SYS_TYPES_H) |
| 28 | +check_include_file(unistd.h HAVE_UNISTD_H) |
| 29 | + |
| 30 | +# generate config.h from config.h.in |
| 31 | +configure_file(config.h.in config.h) |
| 32 | + |
| 33 | +# force inclusion of config.h |
| 34 | +add_definitions(-DHAVE_CONFIG_H) |
| 35 | +include_directories("${CMAKE_CURRENT_BINARY_DIR}") |
| 36 | + |
| 37 | +# GNU C compiler flags |
| 38 | +if(CMAKE_COMPILER_IS_GNUCC) |
| 39 | + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -Wall -Werror -Wextra -Winit-self -Wredundant-decls -Wformat-nonliteral -Wformat-security -Wswitch-enum -Wundef") |
| 40 | +endif(CMAKE_COMPILER_IS_GNUCC) |
| 41 | + |
| 42 | +# build and install the git-run-hooks program |
| 43 | +add_executable(git-run-hooks git-run-hooks.c) |
| 44 | +install(TARGETS git-run-hooks |
| 45 | + DESTINATION bin) |
| 46 | + |
| 47 | +add_subdirectory(hooks) |
| 48 | +add_subdirectory(template) |
0 commit comments