Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/llfio.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2019-10-04 20:34:02 +0300
committerNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2019-10-04 20:34:02 +0300
commitdbf76606c10d325eee673b82173ec0897e0db3ff (patch)
tree1a22996563a4929707d4e468a7c70a20bfc6945d /CMakeLists.txt
parent1849f4e63413ea6f79ad50f18fba4c91bf7b28dd (diff)
A watershed: LLFIO finally works with clang coroutines! All unit tests pass.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt71
1 files changed, 68 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2757afd5..8f36ac09 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -51,6 +51,8 @@ if(WIN32)
add_subdirectory("include/llfio/ntkernel-error-category" EXCLUDE_FROM_ALL)
endif()
+set(UNIT_TESTS_CXX_VERSION "latest" CACHE STRING "The version of C++ to use in the header-only unit tests")
+
# Make the standard static and shared libraries, and if supported by this compiler, C++ modules
# for both static and shared libraries as well. For the non-C++ module variants, makes the
# interface headers into precompiled headers. Only builds all of them if this is the topmost
@@ -148,12 +150,32 @@ endif()
# Set the library dependencies this library has
all_link_libraries(PUBLIC quickcpplib::hl outcome::hl Threads::Threads)
# Set the system dependencies this library has
+set(USING_LIBCXX_ON_LINUX 0)
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
find_library(libstdcxx_stdcxxfs stdc++fs)
if(libstdcxx_stdcxxfs MATCHES "NOTFOUND")
set(libstdcxx_stdcxxfs -lstdc++fs)
endif()
- all_link_libraries(PUBLIC ${libstdcxx_stdcxxfs} rt)
+ get_target_property(val llfio_dl USING_LIBCXX_ON_LINUX)
+ if(val MATCHES "NOTFOUND")
+ all_link_libraries(PUBLIC ${libstdcxx_stdcxxfs} rt)
+ else()
+ set(USING_LIBCXX_ON_LINUX 1)
+ # We had to use libc++ to get coroutines on Linux, so don't link the filesystem TS
+ target_link_libraries(${PROJECT_NAME}_hl INTERFACE ${libstdcxx_stdcxxfs} rt)
+ target_link_libraries(${PROJECT_NAME}_sl PUBLIC ${libstdcxx_stdcxxfs} rt)
+ foreach(special ${SPECIAL_BUILDS})
+ target_link_libraries(${PROJECT_NAME}_sl-${special} PUBLIC ${libstdcxx_stdcxxfs} rt)
+ endforeach()
+ # Do make libc++ a requirement
+ target_compile_definitions(${PROJECT_NAME}_dl PUBLIC _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM=1)
+ target_compile_options(${PROJECT_NAME}_dl PUBLIC -stdlib=libc++)
+ target_link_libraries(${PROJECT_NAME}_dl PUBLIC -stdlib=libc++ -lc++abi)
+ foreach(special ${SPECIAL_BUILDS})
+ target_compile_options(${PROJECT_NAME}_dl-${special} PUBLIC -stdlib=libc++)
+ target_link_libraries(${PROJECT_NAME}_dl-${special} PUBLIC -stdlib=libc++ -lc++abi)
+ endforeach()
+ endif()
endif()
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR APPLE)
find_library(libcxx_cxxexperimental c++experimental)
@@ -207,8 +229,14 @@ if(NOT PROJECT_IS_DEPENDENCY)
)
foreach(test_target ${llfio_TEST_TARGETS})
target_link_libraries(${test_target} PRIVATE kerneltest::hl)
- if(test_target MATCHES "coroutines")
- apply_cxx_coroutines_to(PRIVATE ${test_target})
+ if(test_target MATCHES coroutines)
+ if(USING_LIBCXX_ON_LINUX)
+ if(NOT test_target MATCHES _sl)
+ apply_cxx_coroutines_to(PRIVATE ${test_target})
+ endif()
+ else()
+ apply_cxx_coroutines_to(PRIVATE ${test_target})
+ endif()
endif()
endforeach()
if(MSVC)
@@ -219,6 +247,43 @@ if(NOT PROJECT_IS_DEPENDENCY)
endif()
endforeach()
endif()
+
+ # Turn on latest C++ where possible for the test suite
+ if(UNIT_TESTS_CXX_VERSION STREQUAL "latest")
+ set(LATEST_CXX_FEATURE)
+ foreach(feature ${CMAKE_CXX_COMPILE_FEATURES})
+ if(feature STREQUAL "cxx_std_23")
+ set(LATEST_CXX_FEATURE "cxx_std_23")
+ indented_message(STATUS "NOTE: This compiler claims to support C++ 23, enabling for header-only unit test suite")
+ endif()
+ endforeach()
+ if(NOT LATEST_CXX_FEATURE)
+ foreach(feature ${CMAKE_CXX_COMPILE_FEATURES})
+ if(feature STREQUAL "cxx_std_20")
+ set(LATEST_CXX_FEATURE "cxx_std_20")
+ indented_message(STATUS "NOTE: This compiler claims to support C++ 20, enabling for header-only unit test suite")
+ endif()
+ endforeach()
+ endif()
+ if(NOT LATEST_CXX_FEATURE)
+ foreach(feature ${CMAKE_CXX_COMPILE_FEATURES})
+ if(feature STREQUAL "cxx_std_17")
+ set(LATEST_CXX_FEATURE "cxx_std_17")
+ indented_message(STATUS "NOTE: This compiler claims to support C++ 17, enabling for header-only unit test suite")
+ endif()
+ endforeach()
+ endif()
+ elseif(UNIT_TESTS_CXX_VERSION)
+ set(LATEST_CXX_FEATURE "cxx_std_${UNIT_TESTS_CXX_VERSION}")
+ endif()
+ if(LATEST_CXX_FEATURE)
+ # Turn on latest C++ where possible for the header only test suite
+ foreach(test_target ${llfio_TEST_TARGETS} ${llfio_EXAMPLE_TARGETS})
+ if(test_target MATCHES _hl)
+ target_compile_features(${test_target} PUBLIC ${LATEST_CXX_FEATURE})
+ endif()
+ endforeach()
+ endif()
endif()
# Cache this library's auto scanned sources for later reuse