From 92b3c2dcff3e85ad3d455f6ab845d9a97d3b525b Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Mon, 7 Dec 2020 12:22:15 +0200 Subject: Rewrite meson build scripts into cmakelists --- cmake/StandardProjectSettings.cmake | 44 +++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 cmake/StandardProjectSettings.cmake (limited to 'cmake/StandardProjectSettings.cmake') diff --git a/cmake/StandardProjectSettings.cmake b/cmake/StandardProjectSettings.cmake new file mode 100644 index 0000000..bd88a73 --- /dev/null +++ b/cmake/StandardProjectSettings.cmake @@ -0,0 +1,44 @@ +# from here: +# https://github.com/lefticus/cpp_starter_project/blob/master/cmake/StandardProjectSettings.cmake + +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +# Set a default build type if none was specified +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.") + set(CMAKE_BUILD_TYPE + RelWithDebInfo + CACHE STRING "Choose the type of build." FORCE) + # Set the possible values of build type for cmake-gui, ccmake + set_property( + CACHE CMAKE_BUILD_TYPE + PROPERTY STRINGS + "Debug" + "Release" + "MinSizeRel" + "RelWithDebInfo") +endif() + +# Generate compile_commands.json to make it easier to work with clang based tools +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +option(ENABLE_IPO "Enable Interprocedural Optimization, aka Link Time Optimization (LTO)" OFF) +if(ENABLE_IPO) + include(CheckIPOSupported) + check_ipo_supported(RESULT result OUTPUT output) + if(result) + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) + else() + message(SEND_ERROR "IPO is not supported: ${output}") + endif() +endif() + +option(VCS_TAG "Read version information from git" ON) +if(VCS_TAG) + find_program(VCS git) + execute_process(COMMAND git describe --abbrev=0 OUTPUT_VARIABLE CMAKE_PROJECT_SHORT_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND git describe --long --abbrev=40 OUTPUT_VARIABLE CMAKE_PROJECT_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) +else() + set(CMAKE_PROJECT_SHORT_VERSION ${CMAKE_PROJECT_VERSION}) +endif() \ No newline at end of file -- cgit v1.2.1