Skip to content
Snippets Groups Projects
Commit a83ad318 authored by Tomáš Pecka's avatar Tomáš Pecka
Browse files

CMake: Force CMAKE_BUILD_TYPE set

parent f52865b5
No related branches found
No related tags found
No related merge requests found
Pipeline #56938 passed with warnings
...@@ -9,7 +9,8 @@ include(CheckCXXCompilerFlag) ...@@ -9,7 +9,8 @@ include(CheckCXXCompilerFlag)
include(sanitizer) # sanitizer -DSANITIZE=<sanitizer> include(sanitizer) # sanitizer -DSANITIZE=<sanitizer>
find_package(Backtrace) find_package(Backtrace)
   
message("[Current compiler] ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}") message("[Build type]: ${BUILD_TYPE} (cmake: ${CMAKE_BUILD_TYPE})")
message("[Compiler] ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}")
   
if (NOT ${CMAKE_CXX_COMPILER_ID} MATCHES "(Clang|GNU)") if (NOT ${CMAKE_CXX_COMPILER_ID} MATCHES "(Clang|GNU)")
message(WARNING "Compiler ${CMAKE_CXX_COMPILER_ID} is not officially supported.") message(WARNING "Compiler ${CMAKE_CXX_COMPILER_ID} is not officially supported.")
......
...@@ -24,16 +24,19 @@ if (NOT BUILD_TYPE) ...@@ -24,16 +24,19 @@ if (NOT BUILD_TYPE)
set(BUILD_TYPE Debug) set(BUILD_TYPE Debug)
endif() endif()
string(TOLOWER ${{BUILD_TYPE}} BUILD_TYPE) string(TOLOWER ${{BUILD_TYPE}} BUILD_TYPE)
if(NOT BUILD_TYPE MATCHES "(release|snapshot|debug)")
message(FATAL_ERROR "Unsupported build type (${{BUILD_TYPE}}). Valid values: Release | Snapshot | Debug ") if(BUILD_TYPE MATCHES "release")
elseif(BUILD_TYPE MATCHES "release") set(CMAKE_BUILD_TYPE Release CACHE STRING "cmake internal build type" FORCE)
set(CMAKE_BUILD_TYPE Release)
elseif(BUILD_TYPE MATCHES "snapshot") elseif(BUILD_TYPE MATCHES "snapshot")
set(CMAKE_BUILD_TYPE Release) set(CMAKE_BUILD_TYPE Release CACHE STRING "cmake internal build type" FORCE)
elseif(BUILD_TYPE MATCHES "debug") elseif(BUILD_TYPE MATCHES "debug")
set(CMAKE_BUILD_TYPE Debug) set(CMAKE_BUILD_TYPE Debug CACHE STRING "cmake internal build type" FORCE)
else()
message(FATAL_ERROR "Unsupported build type (${{BUILD_TYPE}}). Valid values: Release | Snapshot | Debug ")
endif() endif()
   
message("[Build type] ${{BUILD_TYPE}} (cmake internal: ${{CMAKE_BUILD_TYPE}})")
if(DEFINED ENV{{CMAKE_BUILD_PARALLEL_LEVEL}}) if(DEFINED ENV{{CMAKE_BUILD_PARALLEL_LEVEL}})
message("[Parallel run] Build: $ENV{{CMAKE_BUILD_PARALLEL_LEVEL}} threads by default") message("[Parallel run] Build: $ENV{{CMAKE_BUILD_PARALLEL_LEVEL}} threads by default")
endif() endif()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment