Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,43 @@ endif ()
if (NOT BUILD_LEGACY_API)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

#
# Ensure compiler support for std::filesystem
#

set(FILESYSTEM_CODE "
#include <filesystem>
int main() {
std::filesystem::path p(\"/\");
return std::filesystem::exists(p) ? 0 : 1;
}
")

check_cxx_source_compiles("${FILESYSTEM_CODE}" HAVE_STD_FILESYSTEM)

if (NOT HAVE_STD_FILESYSTEM)
# Try linking with stdc++fs (GCC < 9, Clang < 9)
set(CMAKE_REQUIRED_LIBRARIES stdc++fs)
check_cxx_source_compiles("${FILESYSTEM_CODE}" HAVE_STD_FILESYSTEM_STDCXXFS)
if (HAVE_STD_FILESYSTEM_STDCXXFS)
set(FILESYSTEM_LIBRARY stdc++fs)
set(HAVE_STD_FILESYSTEM TRUE)
else()
# Try linking with c++fs (older Clang/libc++)
set(CMAKE_REQUIRED_LIBRARIES c++fs)
check_cxx_source_compiles("${FILESYSTEM_CODE}" HAVE_STD_FILESYSTEM_CXXFS)
if (HAVE_STD_FILESYSTEM_CXXFS)
set(FILESYSTEM_LIBRARY c++fs)
set(HAVE_STD_FILESYSTEM TRUE)
endif()
endif()
unset(CMAKE_REQUIRED_LIBRARIES)
endif()

if (NOT HAVE_STD_FILESYSTEM)
message(FATAL_ERROR "The new MultiSense API requires a compiler with std::filesystem support (C++17).")
endif()
endif()

#
Expand Down
3 changes: 2 additions & 1 deletion python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ pybind11_add_module(_libmultisense MODULE bindings.cc)
target_link_libraries(
_libmultisense
PRIVATE
MultiSense)
MultiSense
${FILESYSTEM_LIBRARY})

if (BUILD_JSON_SERIALIZATION)
message("Building python bindings with json print support")
Expand Down
2 changes: 1 addition & 1 deletion source/LibMultiSense/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ else()

endif()

target_link_libraries(MultiSense MultiSenseWire)
target_link_libraries(MultiSense MultiSenseWire ${FILESYSTEM_LIBRARY})
target_include_directories(MultiSense
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PUBLIC $<INSTALL_INTERFACE:include>)
Expand Down
1 change: 1 addition & 0 deletions source/Utilities/LibMultiSense/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ find_package(Threads REQUIRED)
list(APPEND MULTISENSE_UTILITY_LIBS
MultiSense
Threads::Threads
${FILESYSTEM_LIBRARY}
)

if(CMAKE_SYSTEM_NAME STREQUAL "Windows" OR CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
Expand Down
Loading