From 52800006a02f1dc341d1cf080d8643af8bb836f7 Mon Sep 17 00:00:00 2001 From: Martin Chang Date: Tue, 21 Dec 2021 22:22:57 +0800 Subject: [PATCH] Avoid attempt linking to std::fs when target does not exist (#1131) --- CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 85e8ee74..c78dfc5a 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -192,9 +192,11 @@ if(NEED_BOOST_FS) else() option(HAS_STD_FILESYSTEM_PATH "use std::filesystem" ON) # HACK: Needed to be compiled on Yocto Linux - get_property(CAN_LINK_FS TARGET std::filesystem PROPERTY INTERFACE_LINK_LIBRARIES SET) - if ( CAN_LINK_FS ) - target_link_libraries(${PROJECT_NAME} PUBLIC std::filesystem) + if(TARGET std::filesystem) + get_property(CAN_LINK_FS TARGET std::filesystem PROPERTY INTERFACE_LINK_LIBRARIES SET) + if ( CAN_LINK_FS ) + target_link_libraries(${PROJECT_NAME} PUBLIC std::filesystem) + endif() endif() endif()