Skip to content

Commit

Permalink
Merge pull request #1680 from lucbv/export_version_info
Browse files Browse the repository at this point in the history
CMake: export version and subversion to config file
  • Loading branch information
lucbv authored Feb 13, 2023
2 parents 304bcda + c9e631b commit c7765bc
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 3 deletions.
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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}")
Expand All @@ -238,7 +245,7 @@ ELSE()
ELSE()
MESSAGE(" (None)")
ENDIF()
MESSAGE("=======================")
MESSAGE("================================")
MESSAGE("")


Expand Down
6 changes: 5 additions & 1 deletion cmake/KokkosKernels_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions common/unit_test/Test_Common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
#include <Test_Common_Sorting.hpp>
#include <Test_Common_IOUtils.hpp>
#include <Test_Common_Error.hpp>
#include <Test_Common_Version.hpp>

#endif // TEST_COMMON_HPP
52 changes: 52 additions & 0 deletions common/unit_test/Test_Common_Version.hpp
Original file line number Diff line number Diff line change
@@ -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 <Kokkos_Core.hpp>
#include <KokkosKernels_config.h>

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

0 comments on commit c7765bc

Please sign in to comment.