2015-05-11 00:18:22 +02:00
|
|
|
cmake_minimum_required(VERSION 2.8)
|
|
|
|
project(doorlockd)
|
|
|
|
|
|
|
|
option(USE_COLORIZED_LOGS "Colorized logging" ON)
|
2016-04-12 16:05:03 +02:00
|
|
|
option(DORLOCKD_CMAKE_DEBUG "Add some debug output" Off)
|
2015-05-11 00:18:22 +02:00
|
|
|
|
2015-09-24 22:05:23 +02:00
|
|
|
set(DOORLOCK_VERSION_MAJOR 1)
|
2016-04-24 22:16:18 +02:00
|
|
|
set(DOORLOCK_VERSION_MINOR 4)
|
2016-04-11 18:13:29 +02:00
|
|
|
set(DOORLOCK_VERSION_PATCH 0)
|
2015-09-23 15:47:52 +02:00
|
|
|
|
2016-04-24 21:32:33 +02:00
|
|
|
set(DOORLOCK_VERSION "${DOORLOCK_VERSION_MAJOR}.${DOORLOCK_VERSION_MINOR}.${DOORLOCK_VERSION_PATCH}")
|
2015-09-23 15:47:52 +02:00
|
|
|
|
2015-09-25 13:11:36 +02:00
|
|
|
# Instruct CMake to run moc automatically when needed.
|
|
|
|
set(CMAKE_AUTOMOC ON)
|
|
|
|
set(CMAKE_AUTOUIC ON)
|
|
|
|
|
2016-04-12 16:05:03 +02:00
|
|
|
if(DORLOCKD_CMAKE_DEBUG)
|
|
|
|
message(STATUS "[${CMAKE_CURRENT_LIST_DIR}:${CMAKE_CURRENT_LIST_LINE}] "
|
|
|
|
"doorlockd version: ${DOORLOCK_VERSION}")
|
|
|
|
endif()
|
2015-09-23 15:47:52 +02:00
|
|
|
|
|
|
|
# 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}\"")
|
|
|
|
|
2016-04-12 16:05:03 +02:00
|
|
|
if(DORLOCKD_CMAKE_DEBUG)
|
|
|
|
message(STATUS "[${CMAKE_CURRENT_LIST_DIR}:${CMAKE_CURRENT_LIST_LINE}] "
|
|
|
|
"git branch: ${GIT_BRANCH}")
|
|
|
|
endif()
|
|
|
|
|
2015-09-23 15:47:52 +02:00
|
|
|
# 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}\"")
|
|
|
|
|
2016-04-12 16:05:03 +02:00
|
|
|
if(DORLOCKD_CMAKE_DEBUG)
|
|
|
|
message(STATUS "[${CMAKE_CURRENT_LIST_DIR}:${CMAKE_CURRENT_LIST_LINE}] "
|
|
|
|
"git commit hash: ${GIT_COMMIT_HASH}")
|
|
|
|
endif()
|
|
|
|
|
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"
|
|
|
|
)
|
|
|
|
|
2016-07-17 22:18:17 +02:00
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -ggdb -Wall -pedantic -Weffc++ -Wextra -Wno-unused-result")
|
|
|
|
set(CMAKE_CXX_FLAGS "-O2 -Wall -pedantic -Wextra -Weffc++ -Wno-unused-result")
|
|
|
|
set(CMAKE_C_FLAGS_DEBUG "-O0 -ggdb -Wall -pedantic -Wextra -Wno-unused-result")
|
|
|
|
set(CMAKE_C_FLAGS "-O2 -Wall -pedantic -Wextra -Wno-unused-result")
|
2015-05-12 16:10:26 +02:00
|
|
|
|
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")
|
|
|
|
|
2015-05-13 16:20:12 +02:00
|
|
|
find_package (Threads)
|
2015-05-12 16:10:26 +02:00
|
|
|
|
2015-09-25 13:11:36 +02:00
|
|
|
find_package(Qt5Widgets)
|
|
|
|
|
2016-04-12 16:06:04 +02:00
|
|
|
include_directories(
|
|
|
|
${Boost_INCLUDE_DIRS}
|
|
|
|
${PROJECT_BINARY_DIR}
|
|
|
|
${JSON_INCLUDE_DIR})
|
|
|
|
|
|
|
|
set(_LIBDOORLOCK_SRCS
|
2015-09-29 14:33:53 +02:00
|
|
|
lib/clientmessage.cpp
|
|
|
|
lib/clientmessage.h
|
|
|
|
lib/door.cpp
|
|
|
|
lib/door.h
|
2015-10-05 23:30:25 +02:00
|
|
|
lib/doormessage.cpp
|
2015-09-29 14:33:53 +02:00
|
|
|
lib/doormessage.h
|
|
|
|
lib/logger.cpp
|
|
|
|
lib/logger.h
|
|
|
|
lib/logic.cpp
|
|
|
|
lib/logic.h
|
2015-10-01 22:09:55 +02:00
|
|
|
lib/request.cpp
|
|
|
|
lib/request.h
|
2015-09-29 14:33:53 +02:00
|
|
|
lib/response.cpp
|
|
|
|
lib/response.h
|
|
|
|
lib/util.cpp
|
|
|
|
lib/util.h)
|
2015-09-24 21:22:51 +02:00
|
|
|
|
2016-04-12 16:06:04 +02:00
|
|
|
set(_DOORLOCKD_SRCS
|
2015-09-29 14:33:53 +02:00
|
|
|
daemon/doorlockd.cpp)
|
2015-05-11 00:18:22 +02:00
|
|
|
|
2016-04-12 16:06:04 +02:00
|
|
|
set(_DOORLOCK_CLIENT_SRCS
|
2015-09-29 14:33:53 +02:00
|
|
|
client/qrwidget.cpp
|
|
|
|
client/qrwidget.h
|
|
|
|
client/doorlock-client.cpp
|
2015-09-30 15:26:28 +02:00
|
|
|
client/mainwindow.h
|
|
|
|
client/mainwindow.cpp
|
2015-10-11 19:07:03 +02:00
|
|
|
client/mainwindow.ui
|
|
|
|
client/wave.h
|
|
|
|
client/wave.cpp)
|
2015-09-25 01:31:39 +02:00
|
|
|
|
2016-04-12 16:06:04 +02:00
|
|
|
add_library(doorlock STATIC ${_LIBDOORLOCK_SRCS})
|
2015-09-25 16:53:17 +02:00
|
|
|
target_link_libraries(doorlock jsoncpp ldap ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
|
2015-09-24 21:22:51 +02:00
|
|
|
|
2016-04-12 16:06:04 +02:00
|
|
|
add_executable(doorlockd ${_DOORLOCKD_SRCS})
|
2015-09-25 16:53:17 +02:00
|
|
|
target_link_libraries(doorlockd doorlock)
|
2015-05-11 21:18:30 +02:00
|
|
|
|
2016-04-12 16:06:04 +02:00
|
|
|
add_executable(doorlock-client ${_DOORLOCK_CLIENT_SRCS})
|
2016-04-24 22:02:49 +02:00
|
|
|
target_link_libraries(doorlock-client doorlock qrencode Qt5::Widgets)
|
2015-09-30 15:26:28 +02:00
|
|
|
target_include_directories(doorlock-client PRIVATE ${CMAKE_SOURCE_DIR})
|
2015-09-24 21:22:51 +02:00
|
|
|
|
2016-04-12 16:06:04 +02:00
|
|
|
mark_as_advanced(
|
|
|
|
_LIBDOORLOCK_SRCS
|
|
|
|
_DOORLOCKD_SRCS
|
|
|
|
_DOORLOCK_CLIENT_SRCS)
|
|
|
|
|
2015-05-14 15:33:40 +02:00
|
|
|
install(TARGETS doorlockd DESTINATION sbin/)
|
2015-09-25 01:31:39 +02:00
|
|
|
install(TARGETS doorlock-client DESTINATION bin/)
|
|
|
|
|
2015-10-05 22:13:54 +02:00
|
|
|
install(DIRECTORY images/ DESTINATION share/doorlockd/images
|
|
|
|
FILES_MATCHING PATTERN "images/*.png"
|
|
|
|
PERMISSIONS WORLD_READ OWNER_READ GROUP_READ)
|
|
|
|
|
2015-10-07 17:42:52 +02:00
|
|
|
install(DIRECTORY sounds/ DESTINATION share/doorlockd/sounds
|
|
|
|
FILES_MATCHING PATTERN "sounds/*.wav"
|
|
|
|
PERMISSIONS WORLD_READ OWNER_READ GROUP_READ)
|
|
|
|
|
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)
|