Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
libcifpp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
libcifpp
Commits
5bd39b59
Unverified
Commit
5bd39b59
authored
Sep 24, 2021
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add filesystem check, with libstdc++fs test
parent
25a43abf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
6 deletions
+70
-6
CMakeLists.txt
+2
-6
cmake/FindFilesystem.cmake
+68
-0
No files found.
CMakeLists.txt
View file @
5bd39b59
...
@@ -34,7 +34,7 @@ enable_testing()
...
@@ -34,7 +34,7 @@ enable_testing()
include
(
GNUInstallDirs
)
include
(
GNUInstallDirs
)
include
(
CheckFunctionExists
)
include
(
CheckFunctionExists
)
include
(
CheckIncludeFiles
)
include
(
CheckIncludeFiles
)
include
(
CheckIncludeFileCXX
)
include
(
FindFilesystem
)
include
(
CheckLibraryExists
)
include
(
CheckLibraryExists
)
include
(
CMakePackageConfigHelpers
)
include
(
CMakePackageConfigHelpers
)
include
(
Dart
)
include
(
Dart
)
...
@@ -44,11 +44,7 @@ set(CXX_EXTENSIONS OFF)
...
@@ -44,11 +44,7 @@ set(CXX_EXTENSIONS OFF)
set
(
CMAKE_CXX_STANDARD 17
)
set
(
CMAKE_CXX_STANDARD 17
)
set
(
CMAKE_CXX_STANDARD_REQUIRED ON
)
set
(
CMAKE_CXX_STANDARD_REQUIRED ON
)
check_include_file_cxx
(
"filesystem"
_CXX_FILESYSTEM_HAVE_HEADER
)
find_package
(
Filesystem REQUIRED
)
mark_as_advanced
(
_CXX_FILESYSTEM_HAVE_HEADER
)
if
(
NOT _CXX_FILESYSTEM_HAVE_HEADER
)
message
(
FATAL_ERROR
"The standard c++ header file <filesystem> could not be found, please use a more recent compiler"
)
endif
()
if
(
CMAKE_COMPILER_IS_GNUCC
)
if
(
CMAKE_COMPILER_IS_GNUCC
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wall -Wextra -Wno-unused-parameter"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wall -Wextra -Wno-unused-parameter"
)
...
...
cmake/FindFilesystem.cmake
0 → 100644
View file @
5bd39b59
# Simplistic reimplementation of https://github.com/vector-of-bool/CMakeCM/blob/master/modules/FindFilesystem.cmake
if
(
TARGET std::filesystem
)
return
()
endif
()
cmake_minimum_required
(
VERSION 3.10
)
include
(
CMakePushCheckState
)
include
(
CheckIncludeFileCXX
)
include
(
CheckCXXSourceCompiles
)
cmake_push_check_state
()
set
(
CMAKE_CXX_STANDARD 17
)
check_include_file_cxx
(
"filesystem"
_CXX_FILESYSTEM_HAVE_HEADER
)
mark_as_advanced
(
_CXX_FILESYSTEM_HAVE_HEADER
)
set
(
code
[[
#include <cstdlib>
#include <filesystem>
int main() {
auto cwd = std::filesystem::current_path();
return EXIT_SUCCESS;
}
]]
)
# Check a simple filesystem program without any linker flags
check_cxx_source_compiles
(
"
${
code
}
"
CXX_FILESYSTEM_NO_LINK_NEEDED
)
set
(
_found
${
CXX_FILESYSTEM_NO_LINK_NEEDED
}
)
if
(
NOT CXX_FILESYSTEM_NO_LINK_NEEDED
)
set
(
prev_libraries
${
CMAKE_REQUIRED_LIBRARIES
}
)
# Add the libstdc++ flag
set
(
CMAKE_REQUIRED_LIBRARIES
${
prev_libraries
}
-lstdc++fs
)
check_cxx_source_compiles
(
"
${
code
}
"
CXX_FILESYSTEM_STDCPPFS_NEEDED
)
set
(
_found
${
CXX_FILESYSTEM_STDCPPFS_NEEDED
}
)
if
(
NOT CXX_FILESYSTEM_STDCPPFS_NEEDED
)
# Try the libc++ flag
set
(
CMAKE_REQUIRED_LIBRARIES
${
prev_libraries
}
-lc++fs
)
check_cxx_source_compiles
(
"
${
code
}
"
CXX_FILESYSTEM_CPPFS_NEEDED
)
set
(
_found
${
CXX_FILESYSTEM_CPPFS_NEEDED
}
)
endif
()
endif
()
if
(
_found
)
add_library
(
std::filesystem INTERFACE IMPORTED
)
set_property
(
TARGET std::filesystem APPEND PROPERTY INTERFACE_COMPILE_FEATURES cxx_std_17
)
if
(
CXX_FILESYSTEM_NO_LINK_NEEDED
)
# Nothing to add...
elseif
(
CXX_FILESYSTEM_STDCPPFS_NEEDED
)
set_property
(
TARGET std::filesystem APPEND PROPERTY INTERFACE_LINK_LIBRARIES -lstdc++fs
)
elseif
(
CXX_FILESYSTEM_CPPFS_NEEDED
)
set_property
(
TARGET std::filesystem APPEND PROPERTY INTERFACE_LINK_LIBRARIES -lc++fs
)
endif
()
endif
()
cmake_pop_check_state
()
set
(
Filesystem_FOUND
${
_found
}
CACHE BOOL
"TRUE if we can run a program using std::filesystem"
FORCE
)
if
(
Filesystem_FIND_REQUIRED AND NOT Filesystem_FOUND
)
message
(
FATAL_ERROR
"Cannot run simple program using std::filesystem"
)
endif
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment