Skip to content

Commit 3afe719

Browse files
Merge pull request #67 from chaorunrun/compile-for-c++17
Fix errors on compilation with c++17
2 parents 3dca9d8 + e5da05d commit 3afe719

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

CMakeLists.txt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,9 @@ endif()
4545
# Using span from std
4646
if (NOT UUID_USING_CXX20_SPAN)
4747
target_include_directories(${PROJECT_NAME} INTERFACE
48-
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/gsl>
49-
$<INSTALL_INTERFACE:include/gsl>)
50-
if(UUID_ENABLE_INSTALL)
51-
install(DIRECTORY gsl DESTINATION include)
52-
endif()
48+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
49+
$<INSTALL_INTERFACE:include>)
50+
install(DIRECTORY gsl DESTINATION include)
5351
endif ()
5452

5553
if(UUID_ENABLE_INSTALL)
@@ -81,4 +79,4 @@ endif()
8179
if (UUID_BUILD_TESTS)
8280
enable_testing()
8381
add_subdirectory(test)
84-
endif ()
82+
endif ()

include/uuid.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,21 @@
1616
#include <chrono>
1717
#include <numeric>
1818
#include <atomic>
19+
20+
#ifdef __cplusplus
21+
22+
# if (__cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
23+
# define LIBUUID_CPP20_OR_GREATER
24+
# endif
25+
26+
#endif
27+
28+
29+
#ifdef LIBUUID_CPP20_OR_GREATER
1930
#include <span>
31+
#else
32+
#include <gsl/span>
33+
#endif
2034

2135
#ifdef _WIN32
2236

@@ -950,4 +964,4 @@ namespace std
950964
};
951965
}
952966

953-
#endif /* STDUUID_H */
967+
#endif /* STDUUID_H */

0 commit comments

Comments
 (0)