diff --git a/config/openalpr.conf b/config/openalpr.conf.in similarity index 98% rename from config/openalpr.conf rename to config/openalpr.conf.in index bc374b7..51b0016 100644 --- a/config/openalpr.conf +++ b/config/openalpr.conf.in @@ -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 5ac8f82..205dd62 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -15,6 +15,19 @@ 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 WITH_DAEMON ) + SET(WITH_DAEMON ON) +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 +77,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 ) TARGET_LINK_LIBRARIES(alprd @@ -89,12 +102,18 @@ add_subdirectory(openalpr) add_subdirectory(video) -install (TARGETS alpr DESTINATION /usr/bin) -install (TARGETS alprd DESTINATION /usr/bin) -install (FILES ${CMAKE_SOURCE_DIR}/../doc/man/alpr.1 DESTINATION /usr/share/man/man1 COMPONENT doc) -install (DIRECTORY ${CMAKE_SOURCE_DIR}/../runtime_data DESTINATION /usr/share/openalpr/) -install (FILES ${CMAKE_SOURCE_DIR}/../config/openalpr.conf DESTINATION /etc/openalpr/ COMPONENT config) -install (FILES ${CMAKE_SOURCE_DIR}/../config/alprd.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.in ${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() SET(CPACK_PACKAGE_VERSION ${OPENALPR_VERSION}) @@ -119,3 +138,14 @@ SET (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${C SET (CPACK_COMPONENTS_ALL Libraries ApplicationData) INCLUDE(CPack) + +# ---------------------------------------------------------------------------- +# Uninstall target, for "make uninstall" +# http://www.cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F +# ---------------------------------------------------------------------------- +CONFIGURE_FILE( + "${CMAKE_MODULE_PATH}/templates/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" + @ONLY) + +ADD_CUSTOM_TARGET(uninstall COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") diff --git a/src/cmake_modules/templates/cmake_uninstall.cmake.in b/src/cmake_modules/templates/cmake_uninstall.cmake.in new file mode 100644 index 0000000..2037e36 --- /dev/null +++ b/src/cmake_modules/templates/cmake_uninstall.cmake.in @@ -0,0 +1,21 @@ +if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") +endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + +file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) +string(REGEX REPLACE "\n" ";" files "${files}") +foreach(file ${files}) + message(STATUS "Uninstalling $ENV{DESTDIR}${file}") + if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + exec_program( + "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" + OUTPUT_VARIABLE rm_out + RETURN_VALUE rm_retval + ) + if(NOT "${rm_retval}" STREQUAL 0) + message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") + endif(NOT "${rm_retval}" STREQUAL 0) + else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + message(STATUS "File $ENV{DESTDIR}${file} does not exist.") + endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") +endforeach(file) diff --git a/src/openalpr/CMakeLists.txt b/src/openalpr/CMakeLists.txt index d979f90..db7b88f 100644 --- a/src/openalpr/CMakeLists.txt +++ b/src/openalpr/CMakeLists.txt @@ -1,7 +1,6 @@ - set(lpr_source_files alpr.cpp alpr_impl.cpp @@ -39,15 +38,15 @@ add_library(openalpr SHARED ${lpr_source_files} ) set_target_properties(openalpr PROPERTIES SOVERSION ${OPENALPR_MAJOR_VERSION}) - TARGET_LINK_LIBRARIES(openalpr - support - ${OpenCV_LIBS} - ${Tesseract_LIBRARIES} - ) +TARGET_LINK_LIBRARIES(openalpr + support + ${OpenCV_LIBS} + ${Tesseract_LIBRARIES} +) -install (FILES alpr.h DESTINATION /usr/include) -install (TARGETS openalpr DESTINATION /usr/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")