File: SetDefaultBuildRelWithDebInfo.cmake

package info (click to toggle)
dials 3.25.0%2Bdfsg3-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 20,112 kB
  • sloc: python: 134,740; cpp: 34,526; makefile: 160; sh: 142
file content (30 lines) | stat: -rw-r--r-- 1,290 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# If unset, set the default build type to RelWithDebInfo
#
# This also adds a proper set of property strings to the
# CMAKE_BUILD_TYPE configuration variable.
#
# Nothing will be done if the including script is not the root script.
#
# From https://blog.kitware.com/cmake-and-the-default-build-type/

# Add a set of strings to the build_type metadata description, if not present
function(_add_build_types_to_cache_strings)
    get_property(_config_list CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS)
    foreach(build_type IN ITEMS "${ARGN}")
        if (NOT "${build_type}" IN_LIST _config_list)
            list(APPEND _config_list "${build_type}")
        endif()
    endforeach()
    set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "${_config_list}")
endfunction()

# Only do this if we're being called from the root CMakeLists - if the
# parent is added as a subdirectory then it shouldn't fiddle with global
# settings
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
    # Set the default build type to RelWithDebInfo
    if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
        set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build." FORCE)
        _add_build_types_to_cache_strings(Debug Release MinSizeRel RelWithDebInfo)
    endif()
endif()