Skip to content

Instantly share code, notes, and snippets.

@twelve17
Last active August 29, 2015 14:07
Show Gist options
  • Save twelve17/460c57fbe732fd59dc6c to your computer and use it in GitHub Desktop.
Save twelve17/460c57fbe732fd59dc6c to your computer and use it in GitHub Desktop.
diff --git a/config/openalpr.conf b/config/openalpr.conf
index 17b6af9..8f36e4e 100644
--- a/config/openalpr.conf
+++ b/config/openalpr.conf
@@ -1,7 +1,7 @@
[common]
; Specify the path to the runtime data directory
-runtime_dir = /usr/share/openalpr/runtime_data
+runtime_dir = ${CMAKE_INSTALL_PREFIX}/share/openalpr/runtime_data
ocr_img_size_percent = 1.33333333
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 39d1fc0..6220ab5 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -15,6 +15,21 @@ add_definitions( -DOPENALPR_PATCH_VERSION=${OPENALPR_PATCH_VERSION})
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules/")
+# TODO: switch to http://www.cmake.org/cmake/help/v2.8.5/cmake.html#module:GNUInstallDirs ?
+IF (NOT CMAKE_INSTALL_SYSCONFDIR)
+ SET(CMAKE_INSTALL_SYSCONFDIR "${CMAKE_INSTALL_PREFIX}/etc")
+ENDIF()
+
+IF (NOT DEFINED WITHOUT_DAEMON)
+ SET(WITH_DAEMON ON)
+ELSEIF (WITHOUT_DAEMON)
+ SET(WITH_DAEMON OFF)
+ENDIF()
+
+IF (WIN32 AND WITH_DAEMON)
+ MESSAGE(WARNING "Skipping alprd daemon installation, as it is not supported in Windows.")
+ SET(WITH_DAEMON OFF)
+ENDIF()
FIND_PACKAGE( Tesseract REQUIRED )
@@ -64,7 +79,7 @@ TARGET_LINK_LIBRARIES(alpr
)
# Compile the alprd library on Unix-based OS
-IF (NOT WIN32)
+IF (WITH_DAEMON)
ADD_EXECUTABLE( alprd daemon.cpp daemon/beanstalk.c daemon/beanstalk.cc daemon/uuid.cpp )
TARGET_LINK_LIBRARIES(alprd
@@ -90,11 +105,17 @@ add_subdirectory(openalpr)
add_subdirectory(video)
-install (TARGETS alpr DESTINATION bin)
-install (FILES ${CMAKE_SOURCE_DIR}/../doc/man/alpr.1 DESTINATION share/man/man1 COMPONENT doc)
-install (DIRECTORY ${CMAKE_SOURCE_DIR}/../runtime_data DESTINATION share/openalpr/)
-install (FILES ${CMAKE_SOURCE_DIR}/../config/openalpr.conf DESTINATION /etc/openalpr/ COMPONENT config)
+install (TARGETS alpr DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
+install (FILES ${CMAKE_SOURCE_DIR}/../doc/man/alpr.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1 COMPONENT doc)
+install (DIRECTORY ${CMAKE_SOURCE_DIR}/../runtime_data DESTINATION ${CMAKE_INSTALL_PREFIX}/share/openalpr)
+# set runtime_data to reflect the current CMAKE_INSTALL_PREFIX
+CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/../config/openalpr.conf ${CMAKE_CURRENT_BINARY_DIR}/config/openalpr.conf)
+install (FILES ${CMAKE_CURRENT_BINARY_DIR}/config/openalpr.conf DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/openalpr/ COMPONENT config)
+IF (WITH_DAEMON)
+ install (TARGETS alprd DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
+ install (FILES ${CMAKE_SOURCE_DIR}/../config/alprd.conf DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/openalpr/ COMPONENT config)
+ENDIF()
INCLUDE(CPack)
diff --git a/src/cmake_modules/FindTesseract.cmake b/src/cmake_modules/FindTesseract.cmake
index 3bc697a..12a2a11 100644
--- a/src/cmake_modules/FindTesseract.cmake
+++ b/src/cmake_modules/FindTesseract.cmake
@@ -13,29 +13,37 @@ include(LibFindMacros)
# Include dir
find_path(Tesseract_INCLUDE_BASEAPI_DIR
NAMES tesseract/baseapi.h
- HINTS "/usr/include"
+ HINTS "/usr/include"
+ "/usr/include/tesseract"
"/usr/local/include"
+ "/usr/local/include/tesseract"
${Tesseract_PKGCONF_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/../libraries/tesseract-ocr/api/
)
find_path(Tesseract_INCLUDE_CCSTRUCT_DIR
NAMES publictypes.h
HINTS "/usr/include"
+ "/usr/include/tesseract"
"/usr/local/include"
+ "/usr/local/include/tesseract"
${Tesseract_PKGCONF_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/../libraries/tesseract-ocr/ccstruct/
)
find_path(Tesseract_INCLUDE_CCMAIN_DIR
NAMES thresholder.h
HINTS "/usr/include"
+ "/usr/include/tesseract"
"/usr/local/include"
+ "/usr/local/include/tesseract"
${Tesseract_PKGCONF_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/../libraries/tesseract-ocr/ccmain/
)
find_path(Tesseract_INCLUDE_CCUTIL_DIR
NAMES platform.h
HINTS "/usr/include"
+ "/usr/include/tesseract"
"/usr/local/include"
+ "/usr/local/include/tesseract"
${Tesseract_PKGCONF_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/../libraries/tesseract-ocr/ccutil/
)
@@ -69,4 +77,4 @@ set(Tesseract_PROCESS_INCLUDES
Tesseract_INCLUDE_CCUTIL_DIR
Tesseract_INCLUDE_DIRS)
set(Tesseract_PROCESS_LIBS Tesseract_LIB Leptonica_LIB Tesseract_LIBRARIES)
-libfind_process(Tesseract)
\ No newline at end of file
+libfind_process(Tesseract)
diff --git a/src/openalpr/CMakeLists.txt b/src/openalpr/CMakeLists.txt
index 288c4a6..2c945fe 100644
--- a/src/openalpr/CMakeLists.txt
+++ b/src/openalpr/CMakeLists.txt
@@ -44,8 +44,8 @@ set_target_properties(openalpr PROPERTIES SOVERSION ${OPENALPR_MAJOR_VERSION})
)
-install (FILES alpr.h DESTINATION include)
-install (TARGETS openalpr DESTINATION lib)
+ install (FILES alpr.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
+ install (TARGETS openalpr DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
# Add definition for default config file
-add_definitions(-DDEFAULT_CONFIG_FILE="/etc/openalpr/openalpr.conf")
+add_definitions(-DDEFAULT_CONFIG_FILE="${CMAKE_INSTALL_SYSCONFDIR}/openalpr/openalpr.conf")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment