Skip to content

Commit

Permalink
Merge pull request #29 from davvid/cmake-build-type
Browse files Browse the repository at this point in the history
* davvid/cmake-build-type:
  Makefile: allow specifying a build type for cmake
  CMakeLists.txt: do not override user-specified CMAKE_BUILD_TYPE

Signed-off-by: David Aguilar <davvid@gmail.com>
  • Loading branch information
davvid committed Nov 17, 2017
2 parents 59eac37 + f40c890 commit 85622d3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
15 changes: 10 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@ include(FindThreads)

enable_testing()

# Detect the build type from the $FLAVOR environment variable
if ("$ENV{FLAVOR}" MATCHES "debug")
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "type of build" FORCE)
else ()
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "type of build" FORCE)
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
# Detect the build type from the $FLAVOR environment variable
# Default to optimized Release builds when unspecified.
if ("$ENV{FLAVOR}" MATCHES "debug")
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "type of build" FORCE)
elseif ("$ENV{FLAVOR}" MATCHES "profile")
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "type of build" FORCE)
else ()
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "type of build" FORCE)
endif ()
endif ()

if (NOT WIN32)
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ ifdef TOOLCHAIN
CMAKE_FLAGS += -DCMAKE_TOOLCHAIN_FILE=$(TOOLCHAIN)
endif

ifdef BUILD_TYPE
CMAKE_FLAGS += -DCMAKE_BUILD_TYPE=$(BUILD_TYPE)
endif

# make V=1 shortcut for VERBOSE=1
ifdef V
VERBOSE=1
Expand Down

0 comments on commit 85622d3

Please sign in to comment.