From ff72eaad44ffddfa25b01815a7bb1730b3cb81e7 Mon Sep 17 00:00:00 2001 From: Lucas Colley Date: Mon, 16 Sep 2024 13:55:10 +0100 Subject: [PATCH] cmake: directly define project version (#1199) Co-authored-by: Peter Dimov --- CMakeLists.txt | 2 +- test/CMakeLists.txt | 2 ++ test/check_cmake_version.cpp | 27 +++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 test/check_cmake_version.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index d05c44a9e..4c4fc1ddc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.5...3.16) -project(boost_math VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) +project(boost_math VERSION 1.87.0 LANGUAGES CXX) add_library(boost_math INTERFACE) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index fef1189f1..95d7849f6 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -6,6 +6,8 @@ include(BoostTestJamfile OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST) if(HAVE_BOOST_TEST) + boost_test(SOURCES check_cmake_version.cpp ARGUMENTS ${PROJECT_VERSION} LINK_LIBRARIES Boost::core Boost::config) + if (BOOST_MATH_ENABLE_CUDA) message(STATUS "Building boost.math with CUDA") diff --git a/test/check_cmake_version.cpp b/test/check_cmake_version.cpp new file mode 100644 index 000000000..2fd464836 --- /dev/null +++ b/test/check_cmake_version.cpp @@ -0,0 +1,27 @@ +// Check whether the version in CMakeLists.txt is up to date +// +// Copyright 2018 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. +// +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt + +#include +#include +#include + +int main( int ac, char const* av[] ) +{ + BOOST_TEST_EQ( ac, 2 ); + + if( ac >= 2 ) + { + char version[ 64 ]; + std::sprintf( version, "%d.%d.%d", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100 ); + + BOOST_TEST_CSTR_EQ( av[1], version ); + } + + return boost::report_errors(); +}