diff --git a/CMakeLists.txt b/CMakeLists.txt index ecfb539..70de467 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,8 +10,18 @@ ################################################################################### cmake_minimum_required(VERSION 3.12) + +# Read root meson.build file and get project version from it +set(ROOT_MESON_BUILD_FILE "meson.build") +file(READ "${ROOT_MESON_BUILD_FILE}" ROOT_MESON_BUILD_CONTENT) +string(REGEX MATCH " *version: '[.0-9]+'" UNITY_VERSION "${ROOT_MESON_BUILD_CONTENT}") +if(NOT UNITY_VERSION) + message(FATAL_ERROR "Cannot define version from meson build file") +endif() +string(REGEX REPLACE " *version: '([.0-9]+)'" "\\1" UNITY_VERSION "${UNITY_VERSION}") + project(unity - VERSION 2.5.0 + VERSION ${UNITY_VERSION} LANGUAGES C DESCRIPTION "C Unit testing framework." ) @@ -58,32 +68,32 @@ set_target_properties(${PROJECT_NAME} target_compile_options(${PROJECT_NAME} PRIVATE - $<$:-Wcast-align> - $<$:-Wcast-qual> - $<$:-Wconversion> - $<$:-Wexit-time-destructors> - $<$:-Wglobal-constructors> - $<$:-Wmissing-noreturn> - $<$:-Wmissing-prototypes> - $<$:-Wno-missing-braces> - $<$:-Wold-style-cast> - $<$:-Wshadow> - $<$:-Wweak-vtables> - $<$:-Waddress> - $<$:-Waggregate-return> - $<$:-Wformat-nonliteral> - $<$:-Wformat-security> - $<$:-Wformat> - $<$:-Winit-self> - $<$:-Wmissing-declarations> - $<$:-Wmissing-include-dirs> - $<$:-Wno-multichar> - $<$:-Wno-parentheses> - $<$:-Wno-type-limits> - $<$:-Wno-unused-parameter> - $<$:-Wunreachable-code> - $<$:-Wwrite-strings> - -Wpointer-arith + $<$:-Wcast-align + -Wcast-qual + -Wconversion + -Wexit-time-destructors + -Wglobal-constructors + -Wmissing-noreturn + -Wmissing-prototypes + -Wno-missing-braces + -Wold-style-cast + -Wshadow + -Wweak-vtables> + $<$:-Waddress + -Waggregate-return + -Wformat-nonliteral + -Wformat-security + -Wformat + -Winit-self + -Wmissing-declarations + -Wmissing-include-dirs + -Wno-multichar + -Wno-parentheses + -Wno-type-limits + -Wno-unused-parameter + -Wunreachable-code + -Wwrite-strings + -Wpointer-arith> -Wall -Werror )