Skip to content

Commit

Permalink
refactor: use Release build type by default
Browse files Browse the repository at this point in the history
  • Loading branch information
szhorvat committed Nov 16, 2024
1 parent 981d6bf commit d96c2ac
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ endif(POLICY CMP0086)
# Add etc/cmake to CMake's search path so we can put our private stuff there
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/etc/cmake)

# Set a default build type if none was specified
# This must precede the project() line, which would set the CMAKE_BUILD_TYPE
# to 'Debug' with single-config generators on Windows.
# Note that we must do this only if PROJECT_NAME is not set at this point. If
# it is set, it means that plfit is being used as a subproject of another
# project.
if(NOT PROJECT_NAME)
include(BuildType)
endif()

project(
plfit
VERSION 0.9.6
Expand Down
12 changes: 12 additions & 0 deletions etc/cmake/BuildType.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Taken from https://blog.kitware.com/cmake-and-the-default-build-type/

# Set the default build type to "Release"
set(default_build_type "Release")

get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(NOT isMultiConfig AND NOT CMAKE_BUILD_TYPE)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()

0 comments on commit d96c2ac

Please sign in to comment.