Skip to content

Commit

Permalink
Merge pull request #228 from mikkoi/fix-forced-build-type
Browse files Browse the repository at this point in the history
Remove the forcing of the CMake build type
  • Loading branch information
brarcher authored Oct 21, 2019
2 parents ca33ec0 + 67c53e2 commit 2b18886
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
15 changes: 9 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,19 @@ project(check
DESCRIPTION "Unit Testing Framework for C"
LANGUAGES C)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")

###############################################################################
# Set build features

# Set CMAKE_BUILD_TYPE to Debug if source directory is a Git repository
# or user does not override on the command line
include(BuildType)

###############################################################################
# Configure a project for testing with CTest/CDash
include(CTest)

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

macro(extract_version file setting_name)
file(STRINGS ${file} VERSION_NUMBER REGEX "^${setting_name}")
string(REPLACE "=" ";" VERSION_NUMBER_LIST ${VERSION_NUMBER})
Expand All @@ -49,10 +56,6 @@ set(PROJECT_VERSION_MINOR ${CHECK_MINOR_VERSION})
set(PROJECT_VERSION_PATCH ${CHECK_MICRO_VERSION})
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")

###############################################################################
# Set build features
set(CMAKE_BUILD_TYPE Debug)

###############################################################################
# Provides install directory variables as defined by the GNU Coding Standards.
include(GNUInstallDirs)
Expand Down
15 changes: 15 additions & 0 deletions cmake/BuildType.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Set a default build type if none was specified
set(default_build_type "Release")
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
set(default_build_type "Debug")
endif()

if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
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 2b18886

Please sign in to comment.