diff options
-rw-r--r-- | CMakeLists.txt | 39 | ||||
-rw-r--r-- | Makefile | 4 |
2 files changed, 39 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index e7d52b2f..3880bb92 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,10 +2,6 @@ cmake_minimum_required(VERSION 3.1) project(nheko CXX) -set(nheko_VERSION_MAJOR 0) -set(nheko_VERSION_MINOR 1) -set(nheko_VERSION_PATCH 0) - find_package(Qt5Widgets REQUIRED) find_package(Qt5Network REQUIRED) @@ -16,6 +12,41 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) +IF(NOT CMAKE_BUILD_TYPE) + SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING + "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." + FORCE) + MESSAGE("Setting build type to '${CMAKE_BUILD_TYPE}'") +ELSE(NOT CMAKE_BUILD_TYPE) + MESSAGE("Build type set to '${CMAKE_BUILD_TYPE}'") +ENDIF(NOT CMAKE_BUILD_TYPE) + +IF("${CMAKE_BUILD_TYPE}" STREQUAL "Release") + SET(PATCH_OUT "0") +ELSE("${CMAKE_BUILD_TYPE}" STREQUAL "Release") + FIND_PROGRAM(GIT git) + IF(GIT) + EXECUTE_PROCESS( + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMAND ${GIT} rev-parse --short HEAD + OUTPUT_VARIABLE GIT_OUT OUTPUT_STRIP_TRAILING_WHITESPACE + ) + SET(PATCH_OUT "0-git${GIT_OUT}") + ELSE(GIT) + SET(PATCH_OUT "0") + ENDIF(GIT) +ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "Release") + +SET(PROJECT_VERSION_PATCH ${PATCH_OUT}) +SET(CPACK_PACKAGE_VERSION_MAJOR "0") +SET(CPACK_PACKAGE_VERSION_MINOR "1") +SET(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH}) +SET(CPACK_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}) +SET(PROJECT_VERSION_MAJOR ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}) +SET(PROJECT_VERSION ${CPACK_PACKAGE_VERSION}) + +MESSAGE(STATUS "Version: ${PROJECT_VERSION}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \ -std=gnu++11 \ diff --git a/Makefile b/Makefile index d42d768b..fc3cb5cf 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,10 @@ build: @cmake -H. -Bbuild @make -C build +release: + @cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Release + @make -C build + clean: rm -rf build |