Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
composable_kernel_ROCM
Commits
31f6a9a5
Commit
31f6a9a5
authored
Sep 12, 2024
by
Jun Liu
Browse files
CK has no boost dependency
parent
1cf82e4a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
49 deletions
+2
-49
CMakeLists.txt
CMakeLists.txt
+0
-3
include/ck/filesystem.hpp
include/ck/filesystem.hpp
+2
-46
No files found.
CMakeLists.txt
View file @
31f6a9a5
...
...
@@ -44,9 +44,6 @@ else()
find_package
(
Python3 3.8 COMPONENTS Interpreter REQUIRED
)
endif
()
option
(
CK_WORKAROUND_USE_BOOST_FILESYSTEM
"Workaround: Use boost::filesystem instead of std::filesystem"
OFF
)
message
(
STATUS
"CK_WORKAROUND_USE_BOOST_FILESYSTEM
${
CK_WORKAROUND_USE_BOOST_FILESYSTEM
}
"
)
list
(
APPEND CMAKE_MODULE_PATH
"
${
PROJECT_SOURCE_DIR
}
/cmake"
)
if
(
DTYPES
)
...
...
include/ck/filesystem.hpp
View file @
31f6a9a5
...
...
@@ -39,39 +39,10 @@
#endif
// clang-format on
#if CK_WORKAROUND_USE_BOOST_FILESYSTEM
#undef CK_HAS_FILESYSTEM
#undef CK_HAS_FILESYSTEM_TS
#define CK_HAS_FILESYSTEM 0
#define CK_HAS_FILESYSTEM_TS 0
#endif
#if CK_HAS_FILESYSTEM
#include <filesystem>
#elif CK_HAS_FILESYSTEM_TS
#include <experimental/filesystem>
#elif CK_WORKAROUND_USE_BOOST_FILESYSTEM
/// Explicit inclusion of <boost/container_hash/hash.hpp> is a workaround for the Boost 1.83 issue.
///
/// Boost doc is saying:
/// When writing template classes, you might not want to include the main hash.hpp header as it's
/// quite an expensive include that brings in a lot of other headers, so instead you can include
/// the <boost/container_hash/hash_fwd.hpp> header which forward declares boost::hash,
/// boost::hash_combine, boost::hash_range, and boost::hash_unordered_range. You'll need to
/// include the main header before instantiating boost::hash.
///
/// \ref https://www.boost.org/doc/libs/1_83_0/libs/container_hash/doc/html/hash.html#combine
///
/// It seems like boost::filesystem uses boost::hash_range but misses to include hash.hpp, so we
/// have to include it explicitly. Otherwise an error like this happens at runtime (!):
///
/// \code
/// ...symbol lookup error: .../libCK.so.1: undefined symbol:
/// _ZN5boost10hash_rangeIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEEEmT_SC_
/// \endcode
#include <boost/container_hash/hash.hpp>
#define BOOST_FILESYSTEM_NO_DEPRECATED 1
#include <boost/filesystem.hpp>
#else
#error "No filesystem include available"
#endif
...
...
@@ -82,36 +53,21 @@ namespace CK {
namespace
fs
=
::
std
::
filesystem
;
#elif CK_HAS_FILESYSTEM_TS
namespace
fs
=
::
std
::
experimental
::
filesystem
;
#elif CK_WORKAROUND_USE_BOOST_FILESYSTEM
namespace
fs
=
::
boost
::
filesystem
;
#endif
}
// namespace CK
inline
std
::
string
operator
+
(
const
std
::
string_view
s
,
const
CK
::
fs
::
path
&
path
)
{
#if CK_WORKAROUND_USE_BOOST_FILESYSTEM
return
std
::
string
(
path
.
native
()).
insert
(
0
,
s
);
#else
return
path
.
string
().
insert
(
0
,
s
);
#endif
}
inline
std
::
string
operator
+
(
const
CK
::
fs
::
path
&
path
,
const
std
::
string_view
s
)
{
#if CK_WORKAROUND_USE_BOOST_FILESYSTEM
return
std
::
string
(
path
.
native
()).
append
(
s
);
#else
return
path
.
string
().
append
(
s
);
#endif
}
// Hack to minimize changes for boost fs.
#if CK_WORKAROUND_USE_BOOST_FILESYSTEM
#define FS_ENUM_PERMS_ALL fs::perms::all_all
#else
#define FS_ENUM_PERMS_ALL fs::perms::all
#endif
#if CK_HAS_FILESYSTEM_TS
#ifdef __linux__
...
...
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