2016-03-17 08:11:13 +00:00
|
|
|
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
|
2015-12-04 16:30:41 +00:00
|
|
|
set(bare_name "dindexer")
|
2016-04-30 17:43:28 +00:00
|
|
|
project("${bare_name}-if" VERSION 0.1.5 LANGUAGES CXX C)
|
2015-11-11 17:08:17 +00:00
|
|
|
list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
|
2015-12-12 20:27:31 +00:00
|
|
|
|
2016-02-12 20:10:40 +00:00
|
|
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A file indexing program to help you keep track of your backed up files")
|
|
|
|
set(CPACK_PACKAGE_VENDOR "King_DuckZ")
|
|
|
|
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
|
|
|
|
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
|
|
|
|
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
|
|
|
|
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
|
|
|
|
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
|
|
|
|
set(CPACK_GENERATOR "DEB;RPM;TGZ")
|
|
|
|
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "King_DuckZ")
|
|
|
|
set(CPACK_PACKAGE_NAME "${bare_name}")
|
|
|
|
set(CPACK_STRIP_FILES ON)
|
|
|
|
|
2016-07-15 19:02:42 +00:00
|
|
|
#Make sure this is either Debug or Release
|
|
|
|
set(DINDEXER_SUPPORTED_BUILD_TYPES "Debug;Release")
|
|
|
|
list(FIND DINDEXER_SUPPORTED_BUILD_TYPES "${CMAKE_BUILD_TYPE}" build_type_index)
|
|
|
|
if (${build_type_index} LESS 0)
|
|
|
|
message(STATUS "Forcing build type to Release")
|
|
|
|
set(CMAKE_BUILD_TYPE "Release")
|
|
|
|
endif()
|
|
|
|
unset(build_type_index)
|
|
|
|
|
2015-12-12 20:27:31 +00:00
|
|
|
include(GetGitRevisionDescription)
|
2015-12-27 03:09:08 +00:00
|
|
|
include(Buildlibpqtypes)
|
2016-02-10 19:55:52 +00:00
|
|
|
include(gccversion)
|
2016-02-12 20:10:40 +00:00
|
|
|
include(CPack)
|
2016-04-26 18:45:49 +00:00
|
|
|
include(CTest)
|
2016-04-21 23:35:57 +00:00
|
|
|
include(timestamp)
|
2016-07-14 13:05:19 +00:00
|
|
|
include(shared_git_project)
|
2016-08-09 23:30:28 +00:00
|
|
|
include(TargetArch)
|
|
|
|
include(CMakeDependentOption)
|
2016-10-12 21:08:29 +00:00
|
|
|
include(set_switchable)
|
2015-12-12 20:27:31 +00:00
|
|
|
|
2016-08-09 23:40:09 +00:00
|
|
|
find_package(Boost 1.53.0 REQUIRED COMPONENTS program_options filesystem system)
|
|
|
|
find_package(PostgreSQL 8.3 REQUIRED)
|
|
|
|
find_package(YamlCpp 0.5.1 REQUIRED)
|
|
|
|
find_package(Qt5Qml 5.1 REQUIRED)
|
|
|
|
|
2016-08-09 23:30:28 +00:00
|
|
|
target_architecture(DINDEXER_ARCH)
|
|
|
|
if (DINDEXER_ARCH MATCHES "arm.*")
|
|
|
|
set(is_arm ON)
|
2016-02-10 19:55:52 +00:00
|
|
|
endif()
|
2016-08-09 23:40:09 +00:00
|
|
|
|
2016-08-09 23:30:28 +00:00
|
|
|
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION_MAJOR EQUAL "5")
|
|
|
|
set(compiler_is_gnuxx_5plus ON)
|
|
|
|
endif()
|
|
|
|
|
2016-08-09 23:40:09 +00:00
|
|
|
cmake_dependent_option(DINDEXER_NATIVE_RELEASE "Pass the -march=native flag to the compiler for release builds" OFF "NOT is_arm" OFF)
|
2016-08-09 23:30:28 +00:00
|
|
|
option(DINDEXER_WITH_MEDIA_AUTODETECT "Enable code that tries to autodetect the media type and sets --type automatically" ON)
|
|
|
|
cmake_dependent_option(DINDEXER_WITH_DESKTOP_QT5_GUI "Enable the Qt5 GUI for desktop" ON "Qt5Qml_FOUND" OFF)
|
|
|
|
cmake_dependent_option(DINDEXER_CXX11_ABI "Controls if _GLIBCXX_USE_CXX11_ABI gets set to 0 or not" ON "compiler_is_gnuxx_5plus" OFF)
|
2016-10-12 21:08:29 +00:00
|
|
|
option(DINDEXER_INST_MODE "Set some paths to the value that is expected for the layout of the installed version of ${bare_name} (make install)" OFF)
|
2016-08-09 23:30:28 +00:00
|
|
|
|
2016-08-09 23:40:09 +00:00
|
|
|
if(DINDEXER_NATIVE_RELEASE)
|
|
|
|
set(march_flag "-march=native")
|
|
|
|
else()
|
|
|
|
set(march_flag "")
|
|
|
|
endif()
|
|
|
|
|
2016-05-04 17:39:46 +00:00
|
|
|
set(DINDEXER_COPYRIGHT_YEARS "2015,2016")
|
2016-10-12 21:08:29 +00:00
|
|
|
set_switchable(PREFIX DINDEXER INFIX INST NAME CONFIG_FILE
|
|
|
|
ONVALUE "$HOME/.config/${bare_name}.yml" CACHE STRING "Path to the config file"
|
|
|
|
OFFVALUE "${PROJECT_BINARY_DIR}/${bare_name}.yml" CACHE STRING "Path to the config file for debug runs (non-install mode)"
|
|
|
|
)
|
|
|
|
set_switchable(PREFIX DINDEXER INFIX INST NAME ACTIONS_PATH
|
|
|
|
ONVALUE "share/${bare_name}/actions" CACHE STRING "Actions search path"
|
|
|
|
OFFVALUE "${CMAKE_CURRENT_BINARY_DIR}/src" CACHE STRING "Actions search path for debug runs (non-install mode)"
|
|
|
|
)
|
|
|
|
string(REGEX MATCH "[^/].*" ACTIONS_INST_PATH_INSTALL "${DINDEXER_INST_ACTIONS_PATH}")
|
2016-02-11 08:07:36 +00:00
|
|
|
string(REGEX MATCH "[^/].*" ACTIONS_PATH_INSTALL "${DINDEXER_ACTIONS_PATH}")
|
2016-10-12 21:08:29 +00:00
|
|
|
if (DINDEXER_INST_MODE)
|
|
|
|
message(STATUS "Install mode enabled")
|
|
|
|
else()
|
|
|
|
message(STATUS "Install mode disabled")
|
|
|
|
endif()
|
2016-06-17 08:28:38 +00:00
|
|
|
set(DINDEXER_DB_OWNER_NAME "$ENV{USER}" CACHE STRING "Name that will be used as the DB owner name")
|
2015-11-11 19:24:10 +00:00
|
|
|
set(PROJECT_VERSION_BETA "1")
|
2016-05-14 14:10:47 +00:00
|
|
|
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra -Wno-missing-field-initializers -fno-omit-frame-pointer -O0")
|
2016-04-26 17:53:19 +00:00
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall -Wextra -fomit-frame-pointer -Wno-missing-field-initializers ${march_flag}")
|
2016-05-14 14:10:47 +00:00
|
|
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -Wextra -fno-omit-frame-pointer -O0")
|
|
|
|
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wall -Wextra -fomit-frame-pointer ${march_flag}")
|
|
|
|
|
2015-12-10 15:33:38 +00:00
|
|
|
set(DINDEXER_PUB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
2016-04-18 22:34:02 +00:00
|
|
|
set(PBL_WITH_TESTS OFF)
|
2015-12-12 20:27:31 +00:00
|
|
|
get_git_head_revision(GIT_REFSPEC PROJECT_VERSION_GIT)
|
2015-11-05 14:32:31 +00:00
|
|
|
|
2016-10-12 21:08:29 +00:00
|
|
|
message(STATUS "Config file set to \"${DINDEXER_CURR_CONFIG_FILE}\"")
|
|
|
|
message(STATUS "Actions search path set to: \"${DINDEXER_CURR_ACTIONS_PATH}\"")
|
2015-11-13 19:25:32 +00:00
|
|
|
|
2015-12-04 12:58:13 +00:00
|
|
|
add_library(${PROJECT_NAME} INTERFACE)
|
2015-12-04 16:30:41 +00:00
|
|
|
add_library(${bare_name}-inc INTERFACE)
|
2015-12-04 12:58:13 +00:00
|
|
|
|
2015-11-11 19:24:10 +00:00
|
|
|
configure_file(
|
2015-12-04 16:30:41 +00:00
|
|
|
"${PROJECT_SOURCE_DIR}/src/${bare_name}Config.h.in"
|
|
|
|
"${PROJECT_BINARY_DIR}/${bare_name}Config.h"
|
2015-11-11 19:24:10 +00:00
|
|
|
)
|
2016-05-13 08:21:45 +00:00
|
|
|
configure_file(
|
|
|
|
"${PROJECT_SOURCE_DIR}/src/gitinfo.h.in"
|
|
|
|
"${PROJECT_BINARY_DIR}/gitinfo.h"
|
|
|
|
)
|
2016-01-05 14:12:36 +00:00
|
|
|
configure_file(
|
|
|
|
"${PROJECT_SOURCE_DIR}/dindexer.sql.in"
|
|
|
|
"${PROJECT_BINARY_DIR}/dindexer.sql"
|
|
|
|
)
|
2016-03-15 23:01:29 +00:00
|
|
|
configure_file(
|
|
|
|
"${PROJECT_SOURCE_DIR}/dindexer_cmd_complete.sh.in"
|
|
|
|
"${PROJECT_BINARY_DIR}/dindexer_cmd_complete.sh"
|
|
|
|
@ONLY
|
|
|
|
)
|
2015-11-05 16:22:34 +00:00
|
|
|
|
|
|
|
target_include_directories(${PROJECT_NAME} SYSTEM
|
2015-11-11 19:24:10 +00:00
|
|
|
INTERFACE ${Boost_INCLUDE_DIRS}
|
2015-11-11 02:01:37 +00:00
|
|
|
)
|
|
|
|
|
2016-05-11 18:13:59 +00:00
|
|
|
target_compile_features(${PROJECT_NAME}
|
2016-04-26 17:53:19 +00:00
|
|
|
INTERFACE cxx_nullptr
|
|
|
|
INTERFACE cxx_range_for
|
|
|
|
INTERFACE cxx_lambdas
|
|
|
|
INTERFACE cxx_decltype_auto
|
|
|
|
INTERFACE cxx_defaulted_functions
|
|
|
|
INTERFACE cxx_deleted_functions
|
|
|
|
INTERFACE cxx_auto_type
|
|
|
|
INTERFACE cxx_decltype_incomplete_return_types
|
|
|
|
INTERFACE cxx_defaulted_move_initializers
|
|
|
|
INTERFACE cxx_noexcept
|
|
|
|
INTERFACE cxx_rvalue_references
|
|
|
|
)
|
|
|
|
|
2015-12-04 16:30:41 +00:00
|
|
|
target_include_directories(${bare_name}-inc
|
2015-12-04 12:58:13 +00:00
|
|
|
INTERFACE ${PROJECT_BINARY_DIR}
|
|
|
|
INTERFACE ${CMAKE_SOURCE_DIR}/include
|
2015-11-11 02:01:37 +00:00
|
|
|
)
|
|
|
|
|
2016-08-09 23:30:28 +00:00
|
|
|
if (NOT DINDEXER_CXX11_ABI)
|
2016-02-10 19:55:52 +00:00
|
|
|
message(STATUS "CXX11 ABI disabled (_GLIBCXX_USE_CXX11_ABI=0)")
|
|
|
|
add_definitions(
|
|
|
|
#workaround for a bug in gcc 5.3 that is causing exceptions to slip
|
|
|
|
#through try/catch blocks.
|
|
|
|
#WARNING: this will likely cause linking erros with boost and
|
|
|
|
#yaml-cpp unless they are also built with this option or with an
|
|
|
|
#older version of gcc.
|
|
|
|
-D_GLIBCXX_USE_CXX11_ABI=0
|
|
|
|
)
|
|
|
|
endif()
|
2016-02-10 19:14:46 +00:00
|
|
|
|
2016-07-15 17:47:57 +00:00
|
|
|
string(REPLACE "," ";" backend_list "${DINDEXER_ENABLED_BACKENDS}")
|
|
|
|
list(FIND backend_list "redis" redis_found_index)
|
2016-07-15 16:12:40 +00:00
|
|
|
if (${redis_found_index} GREATER -1)
|
|
|
|
set(DINDEXER_WITH_REDIS ON)
|
|
|
|
endif()
|
|
|
|
unset(redis_found_index)
|
2016-07-15 17:47:57 +00:00
|
|
|
unset(backend_list)
|
2016-07-15 16:12:40 +00:00
|
|
|
|
2016-01-05 11:24:23 +00:00
|
|
|
#Libraries
|
2016-08-09 23:40:09 +00:00
|
|
|
import_libpqtypes_project("${PostgreSQL_INCLUDE_DIRS}" "-O3 ${march_flag}")
|
2015-12-04 12:58:13 +00:00
|
|
|
add_subdirectory(src/pq)
|
2015-12-10 15:33:38 +00:00
|
|
|
add_subdirectory(src/common)
|
2016-01-05 12:35:46 +00:00
|
|
|
add_subdirectory(src/machinery)
|
2016-04-18 20:52:35 +00:00
|
|
|
add_subdirectory(lib/pbl)
|
2016-05-11 18:36:23 +00:00
|
|
|
add_subdirectory(lib/glob2regex)
|
2016-05-27 18:28:26 +00:00
|
|
|
add_subdirectory(src/backends)
|
2016-07-08 13:49:40 +00:00
|
|
|
add_subdirectory(src/core)
|
2016-07-14 14:52:03 +00:00
|
|
|
add_shared_git_project(lib/duckhandy)
|
2016-07-15 16:12:40 +00:00
|
|
|
if (DINDEXER_WITH_REDIS)
|
|
|
|
add_shared_git_project(lib/incredis EXCLUDE_FROM_ALL)
|
|
|
|
endif()
|
2016-01-05 11:24:23 +00:00
|
|
|
|
|
|
|
#Actions
|
|
|
|
add_subdirectory(src/main)
|
|
|
|
add_subdirectory(src/scan)
|
2015-12-12 16:53:09 +00:00
|
|
|
add_subdirectory(src/delete)
|
2016-05-27 19:50:09 +00:00
|
|
|
#add_subdirectory(src/query)
|
2015-12-14 13:00:10 +00:00
|
|
|
add_subdirectory(src/locate)
|
2016-01-22 15:55:19 +00:00
|
|
|
add_subdirectory(src/navigate)
|
2016-05-04 07:43:54 +00:00
|
|
|
add_subdirectory(src/tag)
|
2016-08-09 23:30:28 +00:00
|
|
|
if (DINDEXER_WITH_DESKTOP_QT5_GUI)
|
|
|
|
message(STATUS "Building Qt5 desktop GUI for ${bare_name}")
|
|
|
|
add_subdirectory(src/gui)
|
|
|
|
endif()
|
2016-03-17 08:11:13 +00:00
|
|
|
|
|
|
|
#Tests
|
2016-04-20 22:25:52 +00:00
|
|
|
if (BUILD_TESTING)
|
2016-08-09 23:30:59 +00:00
|
|
|
set(TMP_PROJECT_VERSION "${PROJECT_VERSION}")
|
|
|
|
set(TMP_PROJECT_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
|
|
|
|
set(TMP_PROJECT_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
|
|
|
|
set(TMP_PROJECT_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
|
|
|
|
unset(PROJECT_VERSION)
|
|
|
|
unset(PROJECT_VERSION_MAJOR)
|
|
|
|
unset(PROJECT_VERSION_MINOR)
|
|
|
|
unset(PROJECT_VERSION_PATCH)
|
2016-07-14 13:05:19 +00:00
|
|
|
add_shared_git_project(test/gtest)
|
2016-08-09 23:30:59 +00:00
|
|
|
set(PROJECT_VERSION "${TMP_PROJECT_VERSION}")
|
|
|
|
set(PROJECT_VERSION_MAJOR "${TMP_PROJECT_VERSION_MAJOR}")
|
|
|
|
set(PROJECT_VERSION_MINOR "${TMP_PROJECT_VERSION_MINOR}")
|
|
|
|
set(PROJECT_VERSION_PATCH "${TMP_PROJECT_VERSION_PATCH}")
|
2016-04-20 22:25:52 +00:00
|
|
|
add_subdirectory(test/unit)
|
|
|
|
add_subdirectory(test/unit_cli)
|
|
|
|
endif()
|
2015-12-04 12:58:13 +00:00
|
|
|
|
2015-11-11 02:01:37 +00:00
|
|
|
target_link_libraries(${PROJECT_NAME}
|
2015-12-04 12:58:13 +00:00
|
|
|
INTERFACE ${Boost_LIBRARIES}
|
2015-12-04 16:30:41 +00:00
|
|
|
INTERFACE ${bare_name}-pq
|
|
|
|
INTERFACE ${bare_name}-inc
|
2015-11-05 16:22:34 +00:00
|
|
|
)
|
2016-07-14 15:02:15 +00:00
|
|
|
target_link_libraries(${bare_name}-inc
|
2016-07-14 14:52:03 +00:00
|
|
|
INTERFACE duckhandy
|
2015-11-05 16:22:34 +00:00
|
|
|
)
|
2015-11-12 14:07:26 +00:00
|
|
|
|
|
|
|
target_compile_definitions(${PROJECT_NAME}
|
2015-12-04 12:58:13 +00:00
|
|
|
INTERFACE WITH_PROGRESS_FEEDBACK
|
2015-12-29 19:12:15 +00:00
|
|
|
INTERFACE BOOST_SPIRIT_USE_PHOENIX_V3=1
|
2015-11-12 14:07:26 +00:00
|
|
|
)
|