File tree Expand file tree Collapse file tree 5 files changed +64
-18
lines changed Expand file tree Collapse file tree 5 files changed +64
-18
lines changed Original file line number Diff line number Diff line change 4
4
REGISTRY : ghcr.io
5
5
6
6
jobs :
7
+ test-install :
8
+ strategy :
9
+ matrix :
10
+ os : [ubuntu-22.04, ubuntu-22.04-arm, macos-latest]
11
+ runs-on : ${{ matrix.os }}
12
+ steps :
13
+ - uses : actions/checkout@v4
14
+ with :
15
+ fetch-depth : 0
16
+ - name : Configure vatomic
17
+ run : cmake -S. -Bbuild -DCMAKE_INSTALL_PREFIX=/tmp/target
18
+ - name : Install library
19
+ run : cmake --install build
20
+
21
+ - name : Configure test project
22
+ run : cmake -Stest/project -Bbuild2 -DCMAKE_PREFIX_PATH=/tmp/target
23
+ - name : Build test project
24
+ run : cmake --build build2
25
+
7
26
test-native :
8
27
strategy :
9
28
matrix :
14
33
with :
15
34
fetch-depth : 0
16
35
- name : Configure Testing
17
- run : cmake -S. -Bbuild ${{ matrix.config }}
36
+ run : cmake -S. -Bbuild
18
37
- name : Build Tests
19
38
run : cmake --build build
20
39
- name : Run Tests
@@ -26,17 +45,22 @@ jobs:
26
45
- uses : actions/checkout@v4
27
46
with :
28
47
fetch-depth : 0
29
- - name : Configure and Build
48
+ - name : Configure, Build, Install
30
49
id : test
31
50
uses : vmactions/netbsd-vm@v1
32
51
with :
33
52
release : " 10.1"
34
53
usesh : true
35
54
prepare : /usr/sbin/pkg_add curl cmake
36
55
run : |
56
+ rm -rf /tmp/target
37
57
cmake -S. -Bbuild
38
- cmake --build build
58
+ cmake --build build -DCMAKE_INSTALL_PREFIX=/tmp/target
39
59
ctest --test-dir build --output-on-failure
60
+ cmake --install build
61
+ cmake -Stest/project -Bbuild2 -DCMAKE_PREFIX_PATH=/tmp/target
62
+ cmake --build build2
63
+
40
64
41
65
check-expectations :
42
66
runs-on : ubuntu-22.04
Original file line number Diff line number Diff line change @@ -20,14 +20,9 @@ target_include_directories(
20
20
21
21
# Prepare install targets
22
22
install (DIRECTORY include /vsync DESTINATION include )
23
- install (DIRECTORY shared/vsync DESTINATION share )
23
+ install (FILES vmm.cat DESTINATION share/vsync/ )
24
24
install (TARGETS vatomic EXPORT ${PROJECT_TARGETS} )
25
25
26
- # If this is not the top level project, do not enable testing and other targets.
27
- if (NOT CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME )
28
- return ()
29
- endif ()
30
-
31
26
# Atomic templating
32
27
add_subdirectory (template )
33
28
add_subdirectory (tmplr )
@@ -57,11 +52,12 @@ add_dependencies(clang-format-apply sanitize-vatomic)
57
52
# General diff check for pipeline
58
53
add_custom_target (diff-check COMMAND git --no-pager diff --exit-code )
59
54
60
- # Configure testing
61
- include (CTest )
62
- include (ProcessorCount )
63
- include (cmake/v_add_test.cmake )
64
-
65
- enable_testing ()
66
- add_subdirectory (test )
67
- add_subdirectory (verify )
55
+ # Enable testing and verification only if this is the top level project
56
+ if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME )
57
+ include (CTest )
58
+ include (ProcessorCount )
59
+ include (cmake/v_add_test.cmake )
60
+ enable_testing ()
61
+ add_subdirectory (test )
62
+ add_subdirectory (verify )
63
+ endif ()
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ if(NOT DEFINED PROJECT_TARGETS)
6
6
set (PROJECT_TARGETS "${PROJECT_NAME} Targets" )
7
7
endif ()
8
8
9
- set (PROJECT_CMAKE_DIR "${CMAKE_INSTALL_DATAROOTDIR} / ${PROJECT_NAME} /cmake " )
9
+ set (PROJECT_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR} /cmake/ ${PROJECT_NAME} " )
10
10
set (PROJECT_CONFIG_FILE "${PROJECT_BINARY_DIR} /${PROJECT_NAME} Config.cmake" )
11
11
set (PROJECT_VERSION_FILE
12
12
"${PROJECT_BINARY_DIR} /${PROJECT_NAME} ConfigVersion.cmake" )
Original file line number Diff line number Diff line change
1
+ # Copyright (C) Huawei Technologies Co., Ltd. 2025. All rights reserved.
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ # set CMAKE_PREFIX_PATH with the CMAKE_INSTALL_PATH used to install vatomic
5
+
6
+ cmake_minimum_required (VERSION 3.16 )
7
+ project (test LANGUAGES C )
8
+ find_package (vatomic CONFIG REQUIRED )
9
+ add_executable (test test .c )
10
+ target_link_libraries (test PRIVATE vatomic::vatomic )
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (C) Huawei Technologies Co., Ltd. 2025. All rights reserved.
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+ #include <vsync/atomic.h>
6
+ #include <stdio.h>
7
+
8
+ vatomic32_t count ;
9
+
10
+ int
11
+ main ()
12
+ {
13
+ vatomic_inc (& count );
14
+ printf ("count: %u\n" , vatomic_read (& count ));
15
+ return 0 ;
16
+ }
You can’t perform that action at this time.
0 commit comments