diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-12-07 12:22:15 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-12-07 12:22:15 +0200 |
commit | 92b3c2dcff3e85ad3d455f6ab845d9a97d3b525b (patch) | |
tree | a850643f7b86e6cebfddbeec98d7c372478d379c /cmake/StandardProjectSettings.cmake | |
parent | Hostlist filter plugin can rewrite hostnames (diff) | |
download | smolbote-92b3c2dcff3e85ad3d455f6ab845d9a97d3b525b.tar.xz |
Rewrite meson build scripts into cmakelists
Diffstat (limited to 'cmake/StandardProjectSettings.cmake')
-rw-r--r-- | cmake/StandardProjectSettings.cmake | 44 |
1 files changed, 44 insertions, 0 deletions
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 |