From 4e6a233df9da0de1c5f17dd8d7953c681a595952 Mon Sep 17 00:00:00 2001 From: Mark Horvath Date: Fri, 30 May 2025 13:36:49 +0000 Subject: [PATCH] Fix C example build on platforms other than Linux --- examples/C/CMakeLists.txt | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/examples/C/CMakeLists.txt b/examples/C/CMakeLists.txt index 1e18c0c6c..f77188f63 100644 --- a/examples/C/CMakeLists.txt +++ b/examples/C/CMakeLists.txt @@ -18,18 +18,25 @@ target_include_directories( ${CMAKE_CURRENT_BINARY_DIR}/../../kleidicv/include ) -# Trying to link without the C++ runtime. Should work in case of gcc and clang. -list(REMOVE_ITEM CMAKE_CXX_IMPLICIT_LINK_LIBRARIES stdc++ c++) -set_target_properties( - kleidicv-c-example - PROPERTIES - LINKER_LANGUAGE "C" -) +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + # Trying to link without the C++ runtime. Should work in case of gcc and clang. + list(REMOVE_ITEM CMAKE_CXX_IMPLICIT_LINK_LIBRARIES stdc++ c++) + set_target_properties( + kleidicv-c-example + PROPERTIES + LINKER_LANGUAGE "C" + ) -# Linking the whole KleidiCV library to check whether any cpp runtime feature is used. -target_link_libraries( - kleidicv-c-example - -Wl,--whole-archive - kleidicv - -Wl,--no-whole-archive -) + # Linking the whole KleidiCV library to check whether any cpp runtime feature is used. + target_link_libraries( + kleidicv-c-example + -Wl,--whole-archive + kleidicv + -Wl,--no-whole-archive + ) +else() + target_link_libraries( + kleidicv-c-example + kleidicv + ) +endif() -- GitLab