Skip to content

Commit 082af2e

Browse files
committed
added static and dynamic builds
1 parent 712f193 commit 082af2e

2 files changed

Lines changed: 29 additions & 3 deletions

File tree

CMakeLists.txt

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,21 @@ file(GLOB NANOTS_SOURCES
1515
${CMAKE_CURRENT_SOURCE_DIR}/*.c
1616
)
1717

18+
# Build static library
1819
add_library(
19-
nanots STATIC
20+
nanots_static STATIC
21+
${NANOTS_HEADERS}
22+
${NANOTS_SOURCES}
23+
)
24+
25+
target_include_directories(
26+
nanots_static PUBLIC
27+
${CMAKE_CURRENT_SOURCE_DIR}
28+
)
29+
30+
# Build shared library
31+
add_library(
32+
nanots SHARED
2033
${NANOTS_HEADERS}
2134
${NANOTS_SOURCES}
2235
)
@@ -26,4 +39,17 @@ target_include_directories(
2639
${CMAKE_CURRENT_SOURCE_DIR}
2740
)
2841

42+
# Set output names to avoid conflicts
43+
set_target_properties(nanots_static PROPERTIES
44+
OUTPUT_NAME "nanots_static"
45+
)
46+
47+
set_target_properties(nanots PROPERTIES
48+
OUTPUT_NAME "nanots"
49+
)
50+
51+
# Link platform dependencies to both libraries
52+
target_link_libraries(nanots_static PUBLIC platform::platform)
53+
target_link_libraries(nanots PUBLIC platform::platform)
54+
2955
add_subdirectory(ut)

ut/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ target_include_directories(
1818
)
1919

2020
target_link_libraries(
21-
nanots_ut LINK_PUBLIC
22-
nanots
21+
nanots_ut LINK_PUBLIC
22+
nanots_static
2323
platform::platform
2424
)

0 commit comments

Comments
 (0)