2015-05-11 00:18:22 +02:00
|
|
|
cmake_minimum_required(VERSION 2.8)
|
|
|
|
project(doorlockd)
|
|
|
|
|
|
|
|
option(USE_COLORIZED_LOGS "Colorized logging" ON)
|
|
|
|
|
2015-09-23 15:47:52 +02:00
|
|
|
set(DOORLOCKD_VERSION_MAJOR 1)
|
|
|
|
set(DOORLOCKD_VERSION_MINOR 0)
|
|
|
|
set(DOORLOCKD_VERSION_PATCH 0)
|
|
|
|
|
2015-09-23 15:50:26 +02:00
|
|
|
set(DOORLOCKD_VERSION "${DOORLOCKD_VERSION_MAJOR}.${DOORLOCKD_VERSION_MINOR}-${DOORLOCKD_VERSION_PATCH}")
|
2015-09-23 15:47:52 +02:00
|
|
|
|
|
|
|
MESSAGE(STATUS "doorlockd version: ${DOORLOCKD_VERSION}")
|
|
|
|
|
|
|
|
# Get the current working branch
|
|
|
|
execute_process(
|
|
|
|
COMMAND git rev-parse --abbrev-ref HEAD
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
|
|
OUTPUT_VARIABLE GIT_BRANCH
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
)
|
|
|
|
set(GIT_BRANCH "\"${GIT_BRANCH}\"")
|
|
|
|
|
|
|
|
# Get the latest abbreviated commit hash of the working branch
|
|
|
|
execute_process(
|
|
|
|
COMMAND git log -1 --format=%h
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
|
|
OUTPUT_VARIABLE GIT_COMMIT_HASH
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
)
|
|
|
|
set(GIT_COMMIT_HASH "\"${GIT_COMMIT_HASH}\"")
|
|
|
|
|
2015-05-11 00:18:22 +02:00
|
|
|
add_definitions(-std=c++11)
|
|
|
|
|
|
|
|
configure_file (
|
|
|
|
"${PROJECT_SOURCE_DIR}/config.h.in"
|
|
|
|
"${PROJECT_BINARY_DIR}/config.h"
|
|
|
|
)
|
|
|
|
|
2015-05-12 17:35:57 +02:00
|
|
|
include_directories(${PROJECT_BINARY_DIR})
|
|
|
|
include_directories(${Boost_INCLUDE_DIRS})
|
2015-05-11 00:18:22 +02:00
|
|
|
|
2015-05-12 16:10:26 +02:00
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -ggdb -Wall -pedantic -Weffc++ -Wextra")
|
|
|
|
set(CMAKE_CXX_FLAGS "-O2 -Wall -pedantic -Wextra -Weffc++")
|
|
|
|
set(CMAKE_C_FLAGS_DEBUG "-O0 -ggdb -Wall -pedantic -Wextra")
|
|
|
|
set(CMAKE_C_FLAGS "-O2 -Wall -pedantic -Wextra")
|
|
|
|
|
2015-05-13 16:20:12 +02:00
|
|
|
find_package(Boost 1.55.0 COMPONENTS program_options system REQUIRED)
|
|
|
|
|
2015-09-13 23:45:58 +02:00
|
|
|
set(JSON_INCLUDE_DIR "/usr/include/jsoncpp" CACHE PATH "path to jsoncpp includes")
|
|
|
|
include_directories(${JSON_INCLUDE_DIR})
|
|
|
|
|
2015-05-13 16:20:12 +02:00
|
|
|
find_package (Threads)
|
2015-05-12 16:10:26 +02:00
|
|
|
|
2015-05-11 00:18:22 +02:00
|
|
|
set(SRCS
|
|
|
|
main.cpp
|
|
|
|
logger.cpp
|
|
|
|
door.cpp
|
|
|
|
logic.cpp
|
2015-09-22 21:22:48 +02:00
|
|
|
response.cpp
|
2015-05-11 00:18:22 +02:00
|
|
|
util.cpp
|
2015-05-14 15:33:40 +02:00
|
|
|
daemon.cpp
|
2015-05-11 00:18:22 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
add_executable(doorlockd ${SRCS})
|
2015-09-16 22:58:49 +02:00
|
|
|
target_link_libraries(doorlockd jsoncpp ldap ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
|
2015-05-11 21:18:30 +02:00
|
|
|
|
2015-05-14 15:33:40 +02:00
|
|
|
install(TARGETS doorlockd DESTINATION sbin/)
|
|
|
|
install(FILES img/template.png DESTINATION share/doorlockd/)
|
|
|
|
install(DIRECTORY scripts/ DESTINATION share/doorlockd/
|
2015-05-11 21:18:30 +02:00
|
|
|
FILES_MATCHING PATTERN "scripts/doorlockd-*"
|
|
|
|
PERMISSIONS WORLD_EXECUTE WORLD_READ OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE OWNER_WRITE)
|
2015-05-14 15:33:40 +02:00
|
|
|
install(FILES scripts/doorlockd.service DESTINATION /etc/systemd/system/)
|
2015-05-25 15:47:44 +02:00
|
|
|
|
|
|
|
install(DIRECTORY scripts/ DESTINATION etc/doorlockd/
|
|
|
|
FILES_MATCHING PATTERN "scripts/pre_*lock"
|
|
|
|
PERMISSIONS WORLD_EXECUTE WORLD_READ OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE OWNER_WRITE)
|
|
|
|
|
|
|
|
install(DIRECTORY scripts/ DESTINATION etc/doorlockd/
|
|
|
|
FILES_MATCHING PATTERN "scripts/post_*lock"
|
|
|
|
PERMISSIONS WORLD_EXECUTE WORLD_READ OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE OWNER_WRITE)
|
2015-09-17 15:14:27 +02:00
|
|
|
|
|
|
|
install(DIRECTORY scripts/ DESTINATION etc/doorlockd/
|
|
|
|
FILES_MATCHING PATTERN "scripts/emergency_unlock"
|
|
|
|
PERMISSIONS WORLD_EXECUTE WORLD_READ OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE OWNER_WRITE)
|