Skip to content

Commit 8e553e9

Browse files
Connor BakerSomeoneSerge
andcommitted
cmake: make pre-built library discoverable via CMake configuration files
Co-Authored-By: Someone Serge <sergei.kozlukov@aalto.fi>
1 parent dfd55bf commit 8e553e9

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/.clangd
22
/compile_commands.json
33
*.cmake
4+
!nanothreadConfig.cmake
45
CMakeCache.txt
56
CMakeFiles
67
Makefile

CMakeLists.txt

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,41 @@ endif()
6565
target_include_directories(nanothread
6666
PUBLIC
6767
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
68-
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
68+
$<INSTALL_INTERFACE:include>)
6969

7070
target_compile_definitions(nanothread PRIVATE -DNANOTHREAD_BUILD=1)
7171
set_target_properties(nanothread PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE)
7272

7373
if (NANOTHREAD_ENABLE_TESTS)
7474
add_subdirectory(tests)
7575
endif()
76+
77+
configure_file(nanothreadConfig.cmake "${CMAKE_CURRENT_BINARY_DIR}/nanothread/nanothreadConfig.cmake" COPYONLY)
78+
install(
79+
FILES
80+
nanothreadConfig.cmake
81+
DESTINATION
82+
lib/cmake/nanothread
83+
)
84+
install(
85+
TARGETS
86+
nanothread
87+
EXPORT
88+
nanothreadTargets
89+
INCLUDES DESTINATION
90+
include
91+
)
92+
install(
93+
DIRECTORY
94+
include/nanothread
95+
DESTINATION
96+
include
97+
)
98+
install(
99+
EXPORT
100+
nanothreadTargets
101+
FILE
102+
nanothreadTargets.cmake
103+
DESTINATION
104+
lib/cmake/nanothread
105+
)

nanothreadConfig.cmake

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

0 commit comments

Comments
 (0)