diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d685e648e..d75a45499c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,12 @@ IF(NOT KOKKOSKERNELS_HAS_TRILINOS) SET(KokkosKernels_VERSION_MINOR 0) SET(KokkosKernels_VERSION_PATCH 99) SET(KokkosKernels_VERSION "${KokkosKernels_VERSION_MAJOR}.${KokkosKernels_VERSION_MINOR}.${KokkosKernels_VERSION_PATCH}") + + #Set variables for config file MATH(EXPR KOKKOSKERNELS_VERSION "${KokkosKernels_VERSION_MAJOR} * 10000 + ${KokkosKernels_VERSION_MINOR} * 100 + ${KokkosKernels_VERSION_PATCH}") + MATH(EXPR KOKKOSKERNELS_VERSION_MAJOR "${KOKKOSKERNELS_VERSION} / 10000") + MATH(EXPR KOKKOSKERNELS_VERSION_MINOR "${KOKKOSKERNELS_VERSION} / 100 % 100") + MATH(EXPR KOKKOSKERNELS_VERSION_PATCH "${KOKKOSKERNELS_VERSION} % 100") ENDIF() INCLUDE(GNUInstallDirs) @@ -214,7 +219,9 @@ ELSE() # CMake Summary # ================================================================== MESSAGE("") - MESSAGE("=======================") + MESSAGE("================================") + MESSAGE("Kokkos Kernels version: ${KokkosKernels_VERSION_MAJOR}.${KokkosKernels_VERSION_MINOR}.${KokkosKernels_VERSION_PATCH}") + MESSAGE("================================") MESSAGE("Kokkos Kernels ETI Types") MESSAGE(" Devices: ${DEVICE_LIST}") MESSAGE(" Scalars: ${SCALAR_LIST}") @@ -238,7 +245,7 @@ ELSE() ELSE() MESSAGE(" (None)") ENDIF() - MESSAGE("=======================") + MESSAGE("================================") MESSAGE("") diff --git a/cmake/KokkosKernels_config.h.in b/cmake/KokkosKernels_config.h.in index 1fb6a31544..22a6cd9416 100644 --- a/cmake/KokkosKernels_config.h.in +++ b/cmake/KokkosKernels_config.h.in @@ -9,7 +9,11 @@ // clang-format on /* Define the current version of Kokkos Kernels */ -#cmakedefine KOKKOSKERNELS_VERSION @KOKKOSKERNELS_VERSION@ +#define KOKKOSKERNELS_VERSION @KOKKOSKERNELS_VERSION@ +#define KOKKOSKERNELS_VERSION_MAJOR @KOKKOSKERNELS_VERSION_MAJOR@ +#define KOKKOSKERNELS_VERSION_MINOR @KOKKOSKERNELS_VERSION_MINOR@ +#define KOKKOSKERNELS_VERSION_PATCH @KOKKOSKERNELS_VERSION_PATCH@ + /* Define if fortran blas 1 function can return complex type */ #cmakedefine KOKKOSKERNELS_TPL_BLAS_RETURN_COMPLEX diff --git a/common/unit_test/Test_Common.hpp b/common/unit_test/Test_Common.hpp index 9cf686f513..dd368f009b 100644 --- a/common/unit_test/Test_Common.hpp +++ b/common/unit_test/Test_Common.hpp @@ -22,5 +22,6 @@ #include #include #include +#include #endif // TEST_COMMON_HPP diff --git a/common/unit_test/Test_Common_Version.hpp b/common/unit_test/Test_Common_Version.hpp new file mode 100644 index 0000000000..cb5265cfef --- /dev/null +++ b/common/unit_test/Test_Common_Version.hpp @@ -0,0 +1,52 @@ +//@HEADER +// ************************************************************************ +// +// Kokkos v. 4.0 +// Copyright (2022) National Technology & Engineering +// Solutions of Sandia, LLC (NTESS). +// +// Under the terms of Contract DE-NA0003525 with NTESS, +// the U.S. Government retains certain rights in this software. +// +// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions. +// See https://kokkos.org/LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//@HEADER + +/// \file Test_Common_Version.hpp +/// \brief Tests that the version information that Kokkos Kernels +/// makes available in KokkosKernels_config.h is properly +/// accessible and correct. + +#ifndef TEST_COMMON_VERSION_HPP +#define TEST_COMMON_VERSION_HPP + +#include +#include + +void test_version_info() { +#ifndef KOKKOSKERNELS_VERSION + static_assert(false, "KOKKOSKERNELS_VERSION macro is not defined!"); +#endif + +#ifndef KOKKOSKERNELS_VERSION_MAJOR + static_assert(false, "KOKKOSKERNELS_VERSION_MAJOR macro is not defined!"); +#endif + +#ifndef KOKKOSKERNELS_VERSION_MINOR + static_assert(false, "KOKKOSKERNELS_VERSION_MINOR macro is not defined!"); +#endif + +#ifndef KOKKOSKERNELS_VERSION_PATCH + static_assert(false, "KOKKOSKERNELS_VERSION_PATCH macro is not defined!"); +#endif + + static_assert(KOKKOSKERNELS_VERSION == (KOKKOSKERNELS_VERSION_MAJOR * 10000 + + KOKKOSKERNELS_VERSION_MINOR * 100 + + KOKKOSKERNELS_VERSION_PATCH)); +} + +TEST_F(TestCategory, common_version) { test_version_info(); } + +#endif // TEST_COMMON_VERSION_HPP