From a212a92190d4b85d9276af9ee70f66dd140fcdb0 Mon Sep 17 00:00:00 2001 From: David Faure Date: Tue, 23 Jul 2019 00:16:51 +0200 Subject: Make the default build type "Debug" when compiling a git checkout. Summary: The idea comes from https://blog.kitware.com/cmake-and-the-default-build-type/ but I adapted it to leave it empty for tarballs, to avoid messing up distribution packaging. The goal is to make this more sensible for [new] developers who just run cmake and end up with a "no debug symbols, no optimizations" build, i.e. the one and only completely useless combination of those two flags. Possible risk: distributions who compile from git checkouts... Test Plan: "mkdir build ; cd build ; cmake .." in kblog leads to CMAKE_BUILD_TYPE=Debug Reviewers: kde-buildsystem, cgiboudeaux Reviewed By: cgiboudeaux Subscribers: cgiboudeaux, apol, kde-frameworks-devel Tags: #frameworks, #build_system Differential Revision: https://phabricator.kde.org/D22667 --- kde-modules/KDECompilerSettings.cmake | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'kde-modules/KDECompilerSettings.cmake') diff --git a/kde-modules/KDECompilerSettings.cmake b/kde-modules/KDECompilerSettings.cmake index b60e4ea1..41a4a2e5 100644 --- a/kde-modules/KDECompilerSettings.cmake +++ b/kde-modules/KDECompilerSettings.cmake @@ -66,6 +66,23 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +############################################################ +# Default build type +# If no build type was specified, default to using a debug build if the +# source directory is a git clone. +# Otherwise, leave it empty, to let distro packagers choose the flags. +############################################################ +if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + if (EXISTS "${CMAKE_SOURCE_DIR}/.git") + set(default_build_type "Debug") + message(STATUS "Setting build type to '${default_build_type}' as none was specified.") + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "${default_build_type}") + # Set the possible values of build type for cmake-gui + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Release" "MinSizeRel" "RelWithDebInfo") + endif() +endif() + ############################################################ # Toolchain minimal requirements # -- cgit v1.2.1