1cmake_minimum_required(VERSION 3.12 FATAL_ERROR) 2 3set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/") 4include(CMakeToolsHelpers OPTIONAL) 5set(DEB_CHANGELOG_REQUIRED ON) 6set(DEB_CHANGELOG "${CMAKE_CURRENT_SOURCE_DIR}/Changelog") 7unset(CHANGELOG_LAST_VERSION) 8unset(CHANGELOG_LAST_MESSAGE) 9include(DebChangelog) 10 11set(PROJECT_NAME "iowow") 12project(${PROJECT_NAME} C) 13 14set(PROJECT_VENDOR "Softmotions (https://softmotions.com)") 15set(PROJECT_WEBSITE "https://github.com/Softmotions/iowow") 16set(PROJECT_MAINTAINER "Anton Adamansky <adamansky@gmail.com>") 17set(PROJECT_DESCRIPTION_SUMMARY "The skiplist based persistent key/value storage engine") 18set(PROJECT_DESCRIPTION "The skiplist based persistent key/value storage engine") 19set(CHANGELOG_MESSAGE ${CHANGELOG_LAST_MESSAGE}) 20set(PROJECT_PPA "ppa:adamansky/iowow") 21set(PROJECT_PPA_USER "adamansky") 22set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") 23set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") 24 25 26set(PROJECT_VERSION_MAJOR ${CHANGELOG_LAST_VERSION_MAJOR}) 27set(PROJECT_VERSION_MINOR ${CHANGELOG_LAST_VERSION_MINOR}) 28set(PROJECT_VERSION_PATCH ${CHANGELOG_LAST_VERSION_PATCH}) 29set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) 30set(${PROJECT_NAME}_VERSION ${PROJECT_VERSION}) 31set(${PROJECT_NAME}_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) 32set(${PROJECT_NAME}_VERSION_MINOR ${PROJECT_VERSION_MINOR}) 33set(${PROJECT_NAME}_VERSION_PATCH ${PROJECT_VERSION_PATCH}) 34 35option(BUILD_SHARED_LIBS "Build shared libraries" ON) 36option(BUILD_TESTS "Build test cases" OFF) 37option(ASAN "Turn on address sanitizer" OFF) 38option(UBSAN "Turn on UB sanitizer" OFF) 39option(BUILD_EXAMPLES "Build example projects" ON) 40option(BUILD_BENCHMARKS "Build benchmarks" OFF) 41option(PACKAGE_DEB "Build .deb instalation packages" OFF) 42option(PACKAGE_RPM "Build .rpm instalation packages" OFF) 43option(PACKAGE_TGZ "Build .tgz package archive" ON) 44option(PACKAGE_ZIP "Build .zip package archive" ON) 45option(ENABLE_PPA "Enable PPA package build" OFF) 46option(UPLOAD_PPA "Upload debian packages to the launchpad ppa repository" OFF) 47set(PPA_DEBIAN_VERSION "ppa1" CACHE STRING "PPA version suffix for debian packages") 48set(PROJECT_PPA_DISTRIB_TARGET "focal;bionic;xenial" CACHE STRING "Ubuntu PPA distrubutive names") 49 50if(POLICY CMP0042) 51 cmake_policy(SET CMP0042 NEW) 52endif(POLICY CMP0042) 53 54include(GNUInstallDirs) 55include(ProjectUtils) 56 57macro_ensure_out_of_source_build( 58 "${CMAKE_PROJECT_NAME} requires an out of source build." 59) 60 61if(BUILD_TESTS) 62 include(CTest) 63 find_package(CUnit REQUIRED) 64endif(BUILD_TESTS) 65 66if(UPLOAD_PPA) 67 set(ENABLE_PPA ON) 68endif(UPLOAD_PPA) 69 70# add a target to generate API documentation with Doxygen 71find_package(Doxygen) 72option(BUILD_DOCUMENTATION "Create and install the HTML based API documentation (requires Doxygen)" OFF) 73 74if(BUILD_DOCUMENTATION) 75 if(NOT DOXYGEN_FOUND) 76 message(FATAL_ERROR "Doxygen is needed to build the documentation.") 77 endif() 78 set(doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in) 79 set(doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) 80 configure_file(${doxyfile_in} ${doxyfile} @ONLY) 81 add_custom_target(docs 82 COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile} 83 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 84 COMMENT "Generating API documentation with Doxygen" 85 VERBATIM) 86 install(CODE "execute_process(COMMAND ${CMAKE_BUILD_TOOL} docs)") 87 install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION share/doc) 88endif() 89 90add_subdirectory(man) 91 92if(NOT ENABLE_PPA) 93 add_subdirectory(src) 94else() 95 set(PACKAGE_DEB ON) 96endif() 97 98set(CPACK_GENERATORS) 99if(PACKAGE_TGZ) 100 list(APPEND CPACK_GENERATORS "TGZ") 101endif() 102if(PACKAGE_ZIP) 103 list(APPEND CPACK_GENERATORS "ZIP") 104endif() 105if(PACKAGE_DEB) 106 list(APPEND CPACK_GENERATORS "DEB") 107endif() 108if(PACKAGE_RPM) 109 list(APPEND CPACK_GENERATORS "RPM") 110endif() 111 112if(CPACK_GENERATORS) 113 set(CPACK_GENERATOR "${CPACK_GENERATORS}") 114 set(CPACK_SOURCE_IGNORE_FILES 115 "/mxe/" 116 "/\\\\.vscode/" 117 "/\\\\.codelite/" 118 "/\\\\.idea/" 119 "/cmake-.*/" 120 "\\\\.sh$" 121 "\\\\.project$" 122 "\\\\.workspace$" 123 "\\\\.iml$" 124 "\\\\.mk$" 125 "\\\\.editorconfig$" 126 "\\\\.astylerc$" 127 "uncrustify\\\\.cfg$" 128 "/Makefile$" 129 ) 130 set(PROJECT_ARCH "${CMAKE_SYSTEM_PROCESSOR}") 131 add_subdirectory(installer) 132endif(CPACK_GENERATORS) 133 134message("${PROJECT_NAME} CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}") 135message("${PROJECT_NAME} CPACK_GENERATORS: ${CPACK_GENERATORS}") 136message("${PROJECT_NAME} CMAKE_GENERATOR: ${CMAKE_GENERATOR}") 137if (MXE_HOME) 138 message("${PROJECT_NAME} MXE_HOME: ${MXE_HOME}") 139endif() 140if(CMAKE_SYSTEM_NAME) 141 message("${PROJECT_NAME} CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}") 142endif() 143message("${PROJECT_NAME} CPU: ${CMAKE_SYSTEM_PROCESSOR}") 144if(CMAKE_SIZEOF_VOID_P) 145 message("${PROJECT_NAME} SIZEOF *VOID: ${CMAKE_SIZEOF_VOID_P}") 146endif() 147message("${PROJECT_NAME} PROJECT: ${CHANGELOG_LAST_LINE}") 148if(CHANGELOG_MESSAGE) 149 message("${PROJECT_NAME} CHANGELOG_MESSAGE:\n ${CHANGELOG_MESSAGE}") 150endif() 151