CMakeLists.txt 2.0 KB
Newer Older
忠阳 已提交
1 2
cmake_minimum_required(VERSION 3.14)
project(oblogmsg)
3

忠阳 已提交
4 5
option(TEST "build tests" OFF)
option(BENCHMARK "build benchmarks" OFF)
6
option(USE_CXX11_ABI "Build with C++11 ABI" OFF)
忠阳 已提交
7 8

set(CMAKE_VERBOSE_MAKEFILE OFF)
忠阳 已提交
9
set(CMAKE_INSTALL_PREFIX /home/ds)
忠阳 已提交
10 11 12 13 14

if (NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE "RelWithDebInfo")
endif ()

15 16 17 18
if (NOT USE_CXX11_ABI)
    add_compile_definitions($<$<COMPILE_LANGUAGE:CXX>:_GLIBCXX_USE_CXX11_ABI=0>)
endif ()

忠阳 已提交
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
add_library(oblogmsg_base INTERFACE)
set(INNER_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include)
set_property(GLOBAL PROPERTY OBLOGMSG_INCLUDE_DIRS ${INNER_INCLUDE_DIRS})
target_include_directories(oblogmsg_base INTERFACE ${INNER_INCLUDE_DIRS})
target_compile_features(oblogmsg_base INTERFACE cxx_std_11)

add_subdirectory(src)

if (TEST)
    execute_process(
            COMMAND git submodule init
            COMMAND git submodule update
            WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
    )
    add_subdirectory(third_party/googletest)
    add_subdirectory(unittest)
    enable_testing()
endif ()

if (BENCHMARK)
    add_subdirectory(benchmark)
endif ()

install(TARGETS oblogmsg oblogmsg_static
        LIBRARY DESTINATION lib64
        ARCHIVE DESTINATION lib64
)

install(
        DIRECTORY include/ DESTINATION include/logmessage
)
忠阳 已提交
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69

set(CPACK_GENERATOR "RPM")
set(CPACK_PACKAGE_NAME "oblogmsg")
set(CPACK_COMPONENTS_IGNORE_GROUPS 1)
set(CPACK_RPM_COMPONENT_INSTALL ON)
set(CPACK_RPM_RELOCATION_PATHS /usr /home/ds)
set(CPACK_PACKAGING_INSTALL_PREFIX /home/ds)
set(CPACK_PACKAGE_VERSION 3.2)
set(CPACK_RPM_PACKAGE_GROUP "Applications/Databases")
set(CPACK_RPM_PACKAGE_LICENSE "Mulan PubL v2.")
set(CPACK_RPM_DEFAULT_USER "admin")
set(CPACK_RPM_DEFAULT_GROUP "admin")
set(CPACK_RPM_SPEC_MORE_DEFINE
  "%global _missing_build_ids_terminate_build 0
%global _find_debuginfo_opts -g
%define __debug_install_post %{_rpmconfigdir}/find-debuginfo.sh %{?_find_debuginfo_opts} %{_builddir}/%{?buildsubdir};%{nil}
%define debug_package %{nil}")
include(CPack)

add_custom_target(rpm COMMAND +make package)