Skip to content

Commit 50bfa50

Browse files
authored
build: enable target export and installation (#71)
* build: add support to export targets * build: add package config file * ci: add install project step in the workflow * ci: add upload project step in the workflow
1 parent 02912eb commit 50bfa50

File tree

4 files changed

+39
-0
lines changed

4 files changed

+39
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ jobs:
1818
- name: Build project
1919
run: cmake --build build
2020

21+
- name: Install project
22+
run: cmake --install build --prefix install
23+
24+
- name: Upload project as artifact
25+
uses: actions/[email protected]
26+
with:
27+
path: install
28+
2129
build-testing:
2230
name: Build Testing
2331
runs-on: ubuntu-latest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
!.git*
44

55
build
6+
install

CMakeLists.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,32 @@ if(BUILD_TESTING)
7171

7272
catch_discover_tests(my_fibonacci_test)
7373
endif()
74+
75+
install(
76+
TARGETS my_fibonacci my_fibonacci_main
77+
EXPORT my_fibonacci_targets
78+
LIBRARY DESTINATION lib
79+
RUNTIME DESTINATION bin
80+
FILE_SET HEADERS
81+
)
82+
83+
install(
84+
EXPORT my_fibonacci_targets
85+
FILE MyFibonacciTargets.cmake
86+
NAMESPACE my_fibonacci::
87+
DESTINATION lib/cmake/MyFibonacci
88+
)
89+
90+
include(CMakePackageConfigHelpers)
91+
92+
write_basic_package_version_file(
93+
MyFibonacciConfigVersion.cmake
94+
COMPATIBILITY SameMajorVersion
95+
)
96+
97+
install(
98+
FILES
99+
cmake/MyFibonacciConfig.cmake
100+
${CMAKE_CURRENT_BINARY_DIR}/MyFibonacciConfigVersion.cmake
101+
DESTINATION lib/cmake/MyFibonacci
102+
)

cmake/MyFibonacciConfig.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include(${CMAKE_CURRENT_LIST_DIR}/MyFibonacciTargets.cmake)

0 commit comments

Comments
 (0)