File: StdFilesystem.cmake

package info (click to toggle)
ccache 4.12.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,188 kB
  • sloc: cpp: 47,282; asm: 28,570; sh: 8,674; ansic: 5,357; python: 685; perl: 68; makefile: 23
file content (26 lines) | stat: -rw-r--r-- 773 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Check if std::filesystem needs -lstdc++fs

include(CheckCXXSourceCompiles)

set(
  check_std_filesystem_source_code
  [=[
    #include <filesystem>
    int main(void)
    {
      return std::filesystem::is_regular_file(\"/\") ? 0 : 1;
    }
  ]=])

check_cxx_source_compiles("${check_std_filesystem_source_code}" std_filesystem_without_libfs)

if(NOT std_filesystem_without_libfs)
  set(CMAKE_REQUIRED_LIBRARIES stdc++fs)
  check_cxx_source_compiles("${check_std_filesystem_source_code}" std_filesystem_with_libfs)
  set(CMAKE_REQUIRED_LIBRARIES)
  if(NOT std_filesystem_with_libfs)
    message(FATAL_ERROR "Toolchain doesn't support std::filesystem with nor without -lstdc++fs")
  else()
    target_link_libraries(standard_settings INTERFACE stdc++fs)
  endif()
endif()