Skip to content
This repository was archived by the owner on Mar 22, 2023. It is now read-only.

Commit 937d6db

Browse files
cmake: update handling CMAKE_BUILD_TYPE param
- make use of STRINGS keyword to display better hint for the CMake param (in cmake gui), - warn if unusual build type chosen.
1 parent e3a46cb commit 937d6db

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

CMakeLists.txt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,23 @@ set(CMAKE_NO_SYSTEM_FROM_IMPORTED 1)
4040
set(TEST_DIR ${CMAKE_CURRENT_BINARY_DIR}/test CACHE STRING "working directory for tests")
4141
message(STATUS "TEST_DIR set to: \"${TEST_DIR}\"")
4242

43+
# Specify and print the build type
44+
set(DEFAULT_BUILD_TYPE "RelWithDebInfo")
45+
set(predefined_build_types
46+
Debug
47+
Release
48+
RelWithDebInfo
49+
MinSizeRel)
4350
if(NOT CMAKE_BUILD_TYPE)
44-
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
51+
message(STATUS "CMAKE_BUILD_TYPE not set, setting the default one: ${DEFAULT_BUILD_TYPE}")
52+
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}"
53+
CACHE STRING "choose the type of build (${predefined_build_types})" FORCE STRINGS)
54+
else()
55+
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
56+
if(NOT CMAKE_BUILD_TYPE IN_LIST predefined_build_types)
57+
message(WARNING "Unusual build type was set, please make sure it's proper one. "
58+
"By default supported are only following: ${predefined_build_types}.")
59+
endif()
4560
endif()
4661

4762
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${LIBPMEMOBJCPP_ROOT_DIR}/cmake)

0 commit comments

Comments
 (0)