Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Def version #386

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,23 @@ cmake_minimum_required(VERSION 3.20)
# ####################################################
# Kompute
# ####################################################
target_include_directories(kompute PUBLIC $<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)

# Configure the version header file
set(KOMPUTE_VERSION_MAJOR ${${PROJECT_NAME}_VERSION_MAJOR})
set(KOMPUTE_VERSION_MINOR ${${PROJECT_NAME}_VERSION_MINOR})
set(KOMPUTE_VERSION_PATCH ${${PROJECT_NAME}_VERSION_PATCH})
set(KOMPUTE_VERSION_STRING "${KOMPUTE_VERSION_MAJOR}.${KOMPUTE_VERSION_MINOR}.${KOMPUTE_VERSION_PATCH}")
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/kompute/Version.h.in
${CMAKE_CURRENT_BINARY_DIR}/kompute/Version.h
@ONLY
)

target_include_directories(kompute PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<INSTALL_INTERFACE:include>
)

target_sources(kompute PRIVATE

Expand All @@ -29,6 +44,9 @@ target_sources(kompute PRIVATE

if(KOMPUTE_OPT_INSTALL)
install(DIRECTORY kompute DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

# Install the generated version header
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kompute/Version.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/kompute)
endif()

# ####################################################
Expand All @@ -46,4 +64,4 @@ target_sources(kp_logger PRIVATE
# This installation requires non-existing dir logger,
# but previous installation at line 30 has already installed kompute/logger
# This will cause an error during installation
# install(DIRECTORY logger DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# install(DIRECTORY logger DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
1 change: 1 addition & 0 deletions src/include/kompute/Kompute.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
// Will be build by CMake and placed inside the build directory
#include "ShaderLogisticRegression.hpp"
#include "ShaderOpMult.hpp"
#include "kompute/Version.h"
6 changes: 6 additions & 0 deletions src/include/kompute/Version.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

#define KOMPUTE_VERSION_MAJOR @KOMPUTE_VERSION_MAJOR@
#define KOMPUTE_VERSION_MINOR @KOMPUTE_VERSION_MINOR@
#define KOMPUTE_VERSION_PATCH @KOMPUTE_VERSION_PATCH@
#define KOMPUTE_VERSION_STRING "@KOMPUTE_VERSION_STRING@"
10 changes: 7 additions & 3 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ add_subdirectory(shaders)
# ####################################################
# Tests
# ####################################################
add_executable(kompute_tests TestAsyncOperations.cpp
add_executable(kompute_tests
TestAsyncOperations.cpp
TestDestroy.cpp
TestLogisticRegression.cpp
TestManager.cpp
Expand All @@ -21,9 +22,12 @@ add_executable(kompute_tests TestAsyncOperations.cpp
TestPushConstant.cpp
TestSequence.cpp
TestSpecializationConstant.cpp
TestWorkgroup.cpp)
TestWorkgroup.cpp
TestVersionDefined.cpp
)

target_link_libraries(kompute_tests PRIVATE GTest::gtest_main
target_link_libraries(kompute_tests PRIVATE
GTest::gtest_main
kompute::kompute
kp_logger
test_shaders
Expand Down
35 changes: 35 additions & 0 deletions test/TestVersionDefined.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "gtest/gtest.h"

#include "kompute/Kompute.hpp"

#ifdef KOMPUTE_VERSION_MAJOR
#define KOMPUTE_VERSION_MAJOR_DEFINED 1
#else
#define KOMPUTE_VERSION_MAJOR_DEFINED 0
#endif

#ifdef KOMPUTE_VERSION_MINOR
#define KOMPUTE_VERSION_MINOR_DEFINED 1
#else
#define KOMPUTE_VERSION_MINOR_DEFINED 0
#endif

#ifdef KOMPUTE_VERSION_PATCH
#define KOMPUTE_VERSION_PATCH_DEFINED 1
#else
#define KOMPUTE_VERSION_PATCH_DEFINED 0
#endif

#ifdef KOMPUTE_VERSION_STRING
#define KOMPUTE_VERSION_STRING_DEFINED 1
#else
#define KOMPUTE_VERSION_STRING_DEFINED 0
#endif

TEST(TestVersionDefined, MacrosDefined)
{
EXPECT_EQ(KOMPUTE_VERSION_MAJOR_DEFINED, 1);
EXPECT_EQ(KOMPUTE_VERSION_MINOR_DEFINED, 1);
EXPECT_EQ(KOMPUTE_VERSION_PATCH_DEFINED, 1);
EXPECT_EQ(KOMPUTE_VERSION_STRING_DEFINED, 1);
}
Loading