Skip to content

Commit d0071f2

Browse files
committed
Fix shared build
1 parent 1dba02e commit d0071f2

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

CMakeLists.txt

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,18 @@ option(BUILD_SHARED_LIBRARY "Build shared library for FFI bindings (Python, etc.
188188
add_library(headsetcontrol_lib STATIC ${LIBRARY_SOURCES} ${LIBRARY_HEADERS})
189189

190190
# Set library properties
191-
set_target_properties(headsetcontrol_lib PROPERTIES
192-
OUTPUT_NAME "headsetcontrol"
193-
POSITION_INDEPENDENT_CODE ON
194-
)
191+
# On MSVC, use different name to avoid conflict with DLL import library
192+
if(MSVC)
193+
set_target_properties(headsetcontrol_lib PROPERTIES
194+
OUTPUT_NAME "headsetcontrol_static"
195+
POSITION_INDEPENDENT_CODE ON
196+
)
197+
else()
198+
set_target_properties(headsetcontrol_lib PROPERTIES
199+
OUTPUT_NAME "headsetcontrol"
200+
POSITION_INDEPENDENT_CODE ON
201+
)
202+
endif()
195203

196204
# Library include directories
197205
target_include_directories(headsetcontrol_lib PUBLIC
@@ -223,7 +231,12 @@ if(BUILD_SHARED_LIBRARY)
223231
${HIDAPI_INCLUDE_DIRS}
224232
)
225233

226-
target_link_libraries(headsetcontrol_shared PUBLIC m ${HIDAPI_LIBRARIES})
234+
# Library dependencies (same conditional as static library)
235+
if(MSVC)
236+
target_link_libraries(headsetcontrol_shared PUBLIC ${HIDAPI_LIBRARIES})
237+
else()
238+
target_link_libraries(headsetcontrol_shared PUBLIC m ${HIDAPI_LIBRARIES})
239+
endif()
227240

228241
# Export symbols for the C API on Windows
229242
if(WIN32)

0 commit comments

Comments
 (0)