explicit fs tests, no c++ separate test
This commit is contained in:
parent
538c91ebcf
commit
f0fa70d51c
@ -32,6 +32,7 @@ project(nana VERSION 1.7.2
|
||||
add_library(nana)
|
||||
add_library(nana::nana ALIAS nana)
|
||||
target_compile_features(nana PUBLIC cxx_std_17)
|
||||
# set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
# need after cxx_std_14 or cxx_std_17 ??
|
||||
target_compile_features(nana
|
||||
|
@ -55,8 +55,6 @@ else()
|
||||
endif()
|
||||
|
||||
check_include_file_cxx (filesystem NANA_HAVE_FILESYSTEM)
|
||||
check_include_file_cxx (experimental/filesystem NANA_HAVE_EXP_FILESYSTEM)
|
||||
|
||||
if (NANA_HAVE_FILESYSTEM)
|
||||
message (STATUS "C++ Filesystem header: <filesystem>")
|
||||
set (TEST_FS_LIB ON)
|
||||
@ -67,21 +65,24 @@ else()
|
||||
std::filesystem::path p{\"\tmp/\"};
|
||||
throw std::filesystem::filesystem_error(\"Empty file name!\", std::make_error_code(std::errc::invalid_argument));
|
||||
}")
|
||||
elseif (NANA_HAVE_EXP_FILESYSTEM)
|
||||
message (STATUS "C++ Filesystem header: <experimental/filesystem>")
|
||||
set (TEST_FS_LIB ON)
|
||||
set (CXXSTD_FS_TEST_SOURCE
|
||||
"#include <experimental/filesystem>
|
||||
int main()
|
||||
{
|
||||
std::experimental::filesystem::path p{\"/tmp/\"};
|
||||
throw std::experimental::filesystem::filesystem_error(\"Empty file name!\", std::make_error_code(std::errc::invalid_argument));
|
||||
}")
|
||||
else ()
|
||||
message (WARNING "No std::filesystem include file found: nana::filesystem will be used.
|
||||
Set NANA_CMAKE_NANA_FILESYSTEM_FORCE to ON to avoid this warning.")
|
||||
target_compile_definitions(nana PUBLIC STD_FILESYSTEM_NOT_SUPPORTED)
|
||||
set (TEST_FS_LIB OFF)
|
||||
else()
|
||||
check_include_file_cxx (experimental/filesystem NANA_HAVE_EXP_FILESYSTEM)
|
||||
if (NANA_HAVE_EXP_FILESYSTEM)
|
||||
message (STATUS "C++ Filesystem header: <experimental/filesystem>")
|
||||
set (TEST_FS_LIB ON)
|
||||
set (CXXSTD_FS_TEST_SOURCE
|
||||
"#include <experimental/filesystem>
|
||||
int main()
|
||||
{
|
||||
std::experimental::filesystem::path p{\"/tmp/\"};
|
||||
throw std::experimental::filesystem::filesystem_error(\"Empty file name!\", std::make_error_code(std::errc::invalid_argument));
|
||||
}")
|
||||
else ()
|
||||
message (WARNING "No std::filesystem include file found: nana::filesystem will be used.
|
||||
Set NANA_CMAKE_NANA_FILESYSTEM_FORCE to ON to avoid this warning.")
|
||||
target_compile_definitions(nana PUBLIC STD_FILESYSTEM_NOT_SUPPORTED)
|
||||
set (TEST_FS_LIB OFF)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (TEST_FS_LIB)
|
||||
@ -94,56 +95,84 @@ else()
|
||||
set (CMAKE_REQUIRED_INCLUDES ${CMAKE_INCLUDE_PATH})
|
||||
set (CMAKE_REQUIRED_FLAGS ${CMAKE_CXX_FLAGS})
|
||||
set (CMAKE_REQUIRED_FLAGS_ORIGINAL ${CMAKE_REQUIRED_FLAGS})
|
||||
|
||||
set (CXXSTD_TEST_SOURCE
|
||||
"#if !defined (__cplusplus) || (__cplusplus < 201703L)
|
||||
#error NOCXX17
|
||||
#endif
|
||||
int main() {}")
|
||||
|
||||
check_cxx_source_compiles ("${CXXSTD_TEST_SOURCE}" CXX17_BUILTIN)
|
||||
|
||||
if (CXX17_BUILTIN)
|
||||
message (STATUS "C++ Standard-17 support: builtin")
|
||||
else ()
|
||||
set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS_ORIGINAL} -std=c++17")
|
||||
check_cxx_source_compiles ("${CXXSTD_TEST_SOURCE}" CXX17_FLAG)
|
||||
if (CXX17_FLAG)
|
||||
message (STATUS "C++ Standard-17 support: via -std=c++17")
|
||||
else ()
|
||||
message (WARNING "nana requires C++17??, but your compiler does not support it.")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
set (CMAKE_REQUIRED_LIBRARIES_ORIGINAL ${CMAKE_REQUIRED_LIBRARIES})
|
||||
check_cxx_source_compiles ("${CXXSTD_TEST_SOURCE}" C++17FS_FLAG)
|
||||
|
||||
if (C++17FS_FLAG)
|
||||
# c++: builtin
|
||||
set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS_ORIGINAL}")
|
||||
set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_ORIGINAL})
|
||||
check_cxx_source_compiles ("${CXXSTD_FS_TEST_SOURCE}" CXXBuiltIn_FS_BuiltIn)
|
||||
if (CXXBuiltIn_FS_BuiltIn)
|
||||
message (STATUS "C++ Filesystem library: builtin")
|
||||
else ()
|
||||
set (C++17FS_LIB "")
|
||||
foreach (_LIB stdc++fs)
|
||||
set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_ORIGINAL} ${_LIB})
|
||||
check_cxx_source_compiles ("${CXXSTD_FS_TEST_SOURCE}" C++17FS_LIB-l${_LIB})
|
||||
message (STATUS "C++ Filesystem library: testing -l${_LIB}")
|
||||
if (C++17FS_LIB-l${_LIB})
|
||||
target_link_libraries (nana PUBLIC ${_LIB})
|
||||
message (STATUS "C++ Filesystem library: via -l${_LIB}")
|
||||
set (C++17FS_LIB ${_LIB})
|
||||
break ()
|
||||
endif ()
|
||||
set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_ORIGINAL})
|
||||
endforeach ()
|
||||
else()
|
||||
set (CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES_ORIGINAL} stdc++fs")
|
||||
check_cxx_source_compiles ("${CXXSTD_FS_TEST_SOURCE}" CXXBuiltIn_FS_stdcppfs)
|
||||
if (CXXBuiltIn_FS_stdcppfs)
|
||||
message (STATUS "C++ Filesystem library: stdc++fs")
|
||||
target_link_libraries (nana PUBLIC stdc++fs)
|
||||
else()
|
||||
set (CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES_ORIGINAL} c++fs")
|
||||
check_cxx_source_compiles ("${CXXSTD_FS_TEST_SOURCE}" CXXBuiltIn_FS_cppfs)
|
||||
if (CXXBuiltIn_FS_cppfs)
|
||||
message (STATUS "C++ Filesystem library: c++fs")
|
||||
target_link_libraries (nana PUBLIC c++fs)
|
||||
else()
|
||||
|
||||
if (C++17FS_LIB)
|
||||
message (STATUS "C++ Filesystem library: via -l${C++17FS_LIB}")
|
||||
else ()
|
||||
message (WARNING "No std::filesystem library found: nana::filesystem will be used.
|
||||
Set NANA_CMAKE_NANA_FILESYSTEM_FORCE to ON to avoid this warning.")
|
||||
target_compile_definitions(nana PUBLIC STD_FILESYSTEM_NOT_SUPPORTED)
|
||||
endif ()
|
||||
# c++: -std=c++17
|
||||
set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS_ORIGINAL} -std=c++17")
|
||||
set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_ORIGINAL})
|
||||
check_cxx_source_compiles ("${CXXSTD_FS_TEST_SOURCE}" CXX_std__cpp17_FS_BuiltIn)
|
||||
if (CXX_std__cpp17_FS_BuiltIn)
|
||||
message (STATUS "C++: -std=c++17; Filesystem library: builtin")
|
||||
else()
|
||||
set (CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES_ORIGINAL} stdc++fs")
|
||||
check_cxx_source_compiles ("${CXXSTD_FS_TEST_SOURCE}" CXX_std__cpp17_FS_stdcppfs)
|
||||
if (CXX_std__cpp17_FS_stdcppfs)
|
||||
message (STATUS "C++: -std=c++17; Filesystem library: stdc++fs")
|
||||
target_link_libraries (nana PUBLIC stdc++fs)
|
||||
else()
|
||||
set (CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES_ORIGINAL} c++fs")
|
||||
check_cxx_source_compiles ("${CXXSTD_FS_TEST_SOURCE}" CXX_std__cpp17_FS_cppfs)
|
||||
if (CXX_std__cpp17_FS_cppfs)
|
||||
message (STATUS "C++: -std=c++17; Filesystem library: c++fs")
|
||||
target_link_libraries (nana PUBLIC c++fs)
|
||||
else()
|
||||
|
||||
# c++: /std:c++17
|
||||
set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS_ORIGINAL} /std:c++17")
|
||||
set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_ORIGINAL})
|
||||
check_cxx_source_compiles ("${CXXSTD_FS_TEST_SOURCE}" CXX_std_cpp17_FS_BuiltIn)
|
||||
if (CXX_std_cpp17_FS_BuiltIn)
|
||||
message (STATUS "C++: /std:c++17; Filesystem library: builtin")
|
||||
else()
|
||||
set (CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES_ORIGINAL} stdc++fs")
|
||||
check_cxx_source_compiles ("${CXXSTD_FS_TEST_SOURCE}" CXX_std_cpp17_FS_stdcppfs)
|
||||
if (CXX_std_cpp17_FS_stdcppfs)
|
||||
message (STATUS "C++: /std:c++17; Filesystem library: stdc++fs")
|
||||
target_link_libraries (nana PUBLIC stdc++fs)
|
||||
else()
|
||||
set (CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES_ORIGINAL} c++fs")
|
||||
check_cxx_source_compiles ("${CXXSTD_FS_TEST_SOURCE}" CXX_std_cpp17_FS_cppfs)
|
||||
if (CXX_std_cpp17_FS_cppfs)
|
||||
message (STATUS "C++: /std:c++17; Filesystem library: c++fs")
|
||||
target_link_libraries (nana PUBLIC c++fs)
|
||||
|
||||
else ()
|
||||
message (WARNING "No std::filesystem library found: nana::filesystem will be used.
|
||||
Set NANA_CMAKE_NANA_FILESYSTEM_FORCE to ON to avoid this warning.")
|
||||
target_compile_definitions(nana PUBLIC STD_FILESYSTEM_NOT_SUPPORTED)
|
||||
set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_ORIGINAL})
|
||||
endif ()
|
||||
endif ()
|
||||
endif()
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
endif (TEST_FS_LIB)
|
||||
endif ()
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user