From f47137c782772dd9207363a177092f83e8a5169b Mon Sep 17 00:00:00 2001 From: Tao He Date: Wed, 24 Feb 2021 14:17:57 +0800 Subject: [PATCH] Add a CMake build profile to CMakeLists.txt. Signed-off-by: Tao He --- CMakeLists.txt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ad16e8..7fc1969 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,8 +12,19 @@ include(CheckLibraryExists) include(GNUInstallDirs) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -option(BUILD_ETCD_TESTS "Build test cases" OFF) +set(DEFAULT_BUILD_TYPE "Release") +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_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Release" "MinSizeRel" "RelWithDebInfo" + ) +endif() + option(BUILD_SHARED_LIBS "Build shared libraries" ON) +option(BUILD_ETCD_TESTS "Build test cases" OFF) # reference: https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling#always-full-rpath set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)