2019-02-12 16:31:17 +00:00
|
|
|
|
cmake_policy(SET CMP0057 NEW)
|
|
|
|
|
|
|
|
|
|
# Добавление конфигурации для профилирования
|
|
|
|
|
if(CMAKE_CONFIGURATION_TYPES)
|
|
|
|
|
if(NOT "Profile" IN_LIST CMAKE_CONFIGURATION_TYPES)
|
|
|
|
|
list(APPEND CMAKE_CONFIGURATION_TYPES Profile)
|
|
|
|
|
endif()
|
|
|
|
|
else()
|
2019-12-03 16:23:14 +00:00
|
|
|
|
set(_allowed_build_types None Debug Release Profile RelWithDebInfo MinSizeRel)
|
2019-02-12 16:31:17 +00:00
|
|
|
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${_allowed_build_types})
|
|
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
2019-12-03 16:23:14 +00:00
|
|
|
|
set(CMAKE_BUILD_TYPE
|
|
|
|
|
Debug
|
|
|
|
|
CACHE STRING "" FORCE)
|
2019-02-12 16:31:17 +00:00
|
|
|
|
elseif(NOT "${CMAKE_BUILD_TYPE}" IN_LIST _allowed_build_types)
|
|
|
|
|
message(FATAL_ERROR "Invalid build type: ${CMAKE_BUILD_TYPE}")
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(CMAKE_BUILD_TYPE STREQUAL Profile)
|
|
|
|
|
# Ключи компиляции для режима профилирования в зависимости от типа компилятора
|
2019-10-07 10:52:50 +00:00
|
|
|
|
if(CMAKE_CXX_COMPILER_IS_Clang OR CMAKE_CXX_COMPILER_IS_GCC)
|
2019-12-03 16:23:14 +00:00
|
|
|
|
set(CMAKE_C_FLAGS_PROFILE
|
|
|
|
|
"${CMAKE_C_FLAGS_RELEASE} -ggdb -pg"
|
|
|
|
|
CACHE STRING "")
|
|
|
|
|
set(CMAKE_CXX_FLAGS_PROFILE
|
|
|
|
|
"${CMAKE_CXX_FLAGS_RELEASE} -ggdb -pg"
|
|
|
|
|
CACHE STRING "")
|
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS_PROFILE
|
|
|
|
|
"${CMAKE_EXE_LINKER_FLAGS_RELEASE} -pg"
|
|
|
|
|
CACHE STRING "")
|
|
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS_PROFILE
|
|
|
|
|
"${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -pg"
|
|
|
|
|
CACHE STRING "")
|
|
|
|
|
set(CMAKE_STATIC_LINKER_FLAGS_PROFILE
|
|
|
|
|
"${CMAKE_STATIC_LINKER_FLAGS_RELEASE} -pg"
|
|
|
|
|
CACHE STRING "")
|
|
|
|
|
set(CMAKE_MODULE_LINKER_FLAGS_PROFILE
|
|
|
|
|
"${CMAKE_MODULE_LINKER_FLAGS_RELEASE} -pg"
|
|
|
|
|
CACHE STRING "")
|
2019-10-07 10:52:50 +00:00
|
|
|
|
elseif(CMAKE_CXX_COMPILER_IS_Intel)
|
2019-02-12 16:31:17 +00:00
|
|
|
|
message("Set options for profiling with Intel C++")
|
2019-10-07 10:52:50 +00:00
|
|
|
|
elseif(CMAKE_CXX_COMPILER_IS_MSVC)
|
2019-02-12 16:31:17 +00:00
|
|
|
|
message("Set options for profiling with Visual Studio C++")
|
|
|
|
|
endif()
|
|
|
|
|
set(PROFILE 1)
|
|
|
|
|
elseif(CMAKE_BUILD_TYPE STREQUAL Debug)
|
|
|
|
|
# В режиме отладки подробный вывод сообщений компилятора
|
2019-10-19 02:58:37 +00:00
|
|
|
|
if(CMAKE_CXX_COMPILER_IS_Clang OR CMAKE_CXX_COMPILER_IS_GCC)
|
2019-12-03 16:23:14 +00:00
|
|
|
|
string(APPEND CMAKE_C_FLAGS_DEBUG " -ggdb")
|
|
|
|
|
string(APPEND CMAKE_CXX_FLAGS_DEBUG " -ggdb")
|
2019-10-19 02:58:37 +00:00
|
|
|
|
endif()
|
2020-04-02 08:53:48 +00:00
|
|
|
|
set(CMAKE_VERBOSE_MAKEFILE
|
|
|
|
|
ON
|
|
|
|
|
CACHE BOOL "Enable verbose build file generation." FORCE)
|
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS
|
|
|
|
|
ON
|
|
|
|
|
CACHE BOOL "Enable output of compile commands during generation." FORCE)
|
2019-02-12 16:31:17 +00:00
|
|
|
|
set(DEBUG 1)
|
|
|
|
|
elseif(CMAKE_BUILD_TYPE STREQUAL Release)
|
|
|
|
|
set(RELEASE 1)
|
|
|
|
|
elseif(CMAKE_BUILD_TYPE STREQUAL None)
|
|
|
|
|
# Режим None используется для статического анализа кода
|
|
|
|
|
set(ANALYSIS 1)
|
2020-04-02 08:53:48 +00:00
|
|
|
|
set(CMAKE_VERBOSE_MAKEFILE
|
|
|
|
|
ON
|
|
|
|
|
CACHE BOOL "Enable verbose build file generation." FORCE)
|
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS
|
|
|
|
|
ON
|
|
|
|
|
CACHE BOOL "Enable output of compile commands during generation." FORCE)
|
2019-02-12 16:31:17 +00:00
|
|
|
|
# set(USE_CLANG_TIDY ON CACHE BOOL "Use clang-tidy")
|
|
|
|
|
# set(USE_CPPCHECK ON CACHE BOOL "Use cppcheck")
|
2019-12-03 16:23:14 +00:00
|
|
|
|
set(USE_PVS_STUDIO
|
|
|
|
|
ON
|
|
|
|
|
CACHE BOOL "Use PVS-Studio")
|
2019-02-12 16:31:17 +00:00
|
|
|
|
endif()
|