2021-09-16 12:00:31 +08:00
|
|
|
cmake_minimum_required(VERSION 3.0)
|
2021-08-30 10:54:38 +08:00
|
|
|
|
|
|
|
|
project(linglong)
|
|
|
|
|
|
2023-02-15 23:12:10 +08:00
|
|
|
set(LINGLONG_USERNAME
|
|
|
|
|
"deepin-linglong"
|
|
|
|
|
CACHE STRING "the username for linglong package manager"
|
|
|
|
|
)
|
|
|
|
|
set(LINGLONG_LOG_DIR
|
|
|
|
|
"/var/log/linglong"
|
|
|
|
|
CACHE STRING "the location where linglong releated program write their log"
|
|
|
|
|
)
|
|
|
|
|
set(LINGLONG_ROOT
|
|
|
|
|
"/var/lib/linglong"
|
|
|
|
|
CACHE STRING "the location where linglong releated program puts their data"
|
|
|
|
|
)
|
|
|
|
|
|
2021-08-30 10:54:38 +08:00
|
|
|
# 保证项目兼容性
|
|
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
|
|
|
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|
|
|
|
|
2021-09-16 12:00:31 +08:00
|
|
|
set(CMAKE_EXPORT_NO_PACKAGE_REGISTRY ON)
|
|
|
|
|
set(VERSION "1.0")
|
|
|
|
|
|
2022-11-21 11:03:38 +08:00
|
|
|
# defalut set build type for release
|
2022-07-24 19:22:32 +08:00
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
|
|
|
set(CMAKE_BUILD_TYPE
|
2022-11-21 11:03:38 +08:00
|
|
|
"Release"
|
2022-11-21 11:34:45 +08:00
|
|
|
CACHE STRING
|
|
|
|
|
"Choose Release or Debug"
|
|
|
|
|
FORCE
|
2022-07-24 19:22:32 +08:00
|
|
|
)
|
|
|
|
|
endif()
|
2021-09-01 18:48:20 +08:00
|
|
|
|
2022-11-21 11:34:45 +08:00
|
|
|
# set sanitizer for debug that default disabled. thread --> tasn ; address -->
|
|
|
|
|
# asan ; default --> none
|
2022-07-24 19:22:32 +08:00
|
|
|
if(NOT CMAKE_DEBUG_SANIT)
|
|
|
|
|
set(CMAKE_DEBUG_SANIT
|
|
|
|
|
"none"
|
2022-11-21 11:34:45 +08:00
|
|
|
CACHE STRING
|
|
|
|
|
"Choose [none,thread,address]"
|
|
|
|
|
FORCE
|
2022-07-24 19:22:32 +08:00
|
|
|
)
|
2021-10-11 10:39:03 +08:00
|
|
|
endif()
|
2022-07-24 19:22:32 +08:00
|
|
|
|
2022-11-21 11:34:45 +08:00
|
|
|
if(CMAKE_BUILD_TYPE
|
|
|
|
|
STREQUAL
|
|
|
|
|
"Debug"
|
|
|
|
|
)
|
2022-11-21 11:03:38 +08:00
|
|
|
add_definitions(-DDEBUG) # debug mode
|
2022-11-21 11:34:45 +08:00
|
|
|
message(
|
|
|
|
|
"STATUS"
|
|
|
|
|
"Compiler Feature: "
|
|
|
|
|
${CMAKE_DEBUG_SANIT}
|
|
|
|
|
)
|
|
|
|
|
if(CMAKE_DEBUG_SANIT
|
|
|
|
|
STREQUAL
|
|
|
|
|
"thread"
|
|
|
|
|
)
|
2022-07-24 19:22:32 +08:00
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -fsanitize=thread -Wall -g -ggdb3")
|
2022-11-21 11:34:45 +08:00
|
|
|
elseif(
|
|
|
|
|
CMAKE_DEBUG_SANIT
|
|
|
|
|
STREQUAL
|
|
|
|
|
"address"
|
|
|
|
|
)
|
2022-07-24 19:22:32 +08:00
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG
|
|
|
|
|
"-O0 -fsanitize=undefined,address -Wall -g -ggdb3"
|
|
|
|
|
)
|
|
|
|
|
else()
|
2022-11-21 11:03:38 +08:00
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
|
2022-07-24 19:22:32 +08:00
|
|
|
endif()
|
2021-10-11 10:39:03 +08:00
|
|
|
endif()
|
|
|
|
|
|
2021-08-30 10:54:38 +08:00
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
include_directories(${linglong_SOURCE_DIR}/src)
|
2021-09-08 22:26:58 +08:00
|
|
|
|
2021-08-30 10:54:38 +08:00
|
|
|
add_subdirectory(src)
|
|
|
|
|
add_subdirectory(test)
|
2023-02-10 15:04:54 +08:00
|
|
|
add_subdirectory(misc)
|
2021-08-31 16:40:34 +08:00
|
|
|
|
2022-07-24 19:22:32 +08:00
|
|
|
message(STATUS "output " ${PROJECT_BINARY_DIR})
|
|
|
|
|
message(STATUS "source " ${PROJECT_SOURCE_DIR})
|
|
|
|
|
message(STATUS "install " ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
|