mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 13:40:05 +00:00 
			
		
		
		
	Merge pull request #274 from AdenKoperczak/use-__cpp_lib_chrono
Use __cpp_lib_chrono to determine if chrono or date library should be used.
This commit is contained in:
		
						commit
						a357489a55
					
				
					 16 changed files with 44 additions and 38 deletions
				
			
		|  | @ -10,7 +10,7 @@ | ||||||
| 
 | 
 | ||||||
| #include <boost/json.hpp> | #include <boost/json.hpp> | ||||||
| 
 | 
 | ||||||
| #if !(defined(_MSC_VER) || defined(__clang__)) | #if (__cpp_lib_chrono < 201907L) | ||||||
| #   include <date/date.h> | #   include <date/date.h> | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  | @ -271,7 +271,7 @@ size_t RadarSite::ReadConfig(const std::string& path) | ||||||
| 
 | 
 | ||||||
|             try |             try | ||||||
|             { |             { | ||||||
| #if (defined(_MSC_VER) || defined(__clang__)) | #if (__cpp_lib_chrono >= 201907L) | ||||||
|                using namespace std::chrono; |                using namespace std::chrono; | ||||||
| #else | #else | ||||||
|                using namespace date; |                using namespace date; | ||||||
|  |  | ||||||
|  | @ -52,10 +52,6 @@ | ||||||
| #include <QTimer> | #include <QTimer> | ||||||
| #include <QToolButton> | #include <QToolButton> | ||||||
| 
 | 
 | ||||||
| #if !(defined(_MSC_VER) || defined(__clang__)) |  | ||||||
| #   include <date/date.h> |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| namespace scwx | namespace scwx | ||||||
| { | { | ||||||
| namespace qt | namespace qt | ||||||
|  |  | ||||||
|  | @ -413,7 +413,7 @@ const scwx::util::time_zone* RadarProductManager::default_time_zone() const | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    case types::DefaultTimeZone::Local: |    case types::DefaultTimeZone::Local: | ||||||
| #if (defined(_MSC_VER) || defined(__clang__)) | #if (__cpp_lib_chrono >= 201907L) | ||||||
|       return std::chrono::current_zone(); |       return std::chrono::current_zone(); | ||||||
| #else | #else | ||||||
|       return date::current_zone(); |       return date::current_zone(); | ||||||
|  |  | ||||||
|  | @ -11,8 +11,6 @@ | ||||||
| #include <scwx/util/logger.hpp> | #include <scwx/util/logger.hpp> | ||||||
| #include <scwx/util/time.hpp> | #include <scwx/util/time.hpp> | ||||||
| 
 | 
 | ||||||
| #include <chrono> |  | ||||||
| 
 |  | ||||||
| #if defined(_MSC_VER) | #if defined(_MSC_VER) | ||||||
| #   pragma warning(push, 0) | #   pragma warning(push, 0) | ||||||
| #endif | #endif | ||||||
|  | @ -22,10 +20,6 @@ | ||||||
| #include <QGuiApplication> | #include <QGuiApplication> | ||||||
| #include <QMouseEvent> | #include <QMouseEvent> | ||||||
| 
 | 
 | ||||||
| #if !(defined(_MSC_VER) || defined(__clang__)) |  | ||||||
| #   include <date/date.h> |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| #if defined(_MSC_VER) | #if defined(_MSC_VER) | ||||||
| #   pragma warning(pop) | #   pragma warning(pop) | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | @ -17,10 +17,6 @@ | ||||||
| #include <boost/timer/timer.hpp> | #include <boost/timer/timer.hpp> | ||||||
| #include <fmt/format.h> | #include <fmt/format.h> | ||||||
| 
 | 
 | ||||||
| #if !(defined(_MSC_VER) || defined(__clang__)) |  | ||||||
| #   include <date/date.h> |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| namespace scwx | namespace scwx | ||||||
| { | { | ||||||
| namespace qt | namespace qt | ||||||
|  |  | ||||||
							
								
								
									
										8
									
								
								wxdata/cpp-feature-tests/chrono_feature_test.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								wxdata/cpp-feature-tests/chrono_feature_test.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,8 @@ | ||||||
|  | #include <chrono> | ||||||
|  | 
 | ||||||
|  | int main() | ||||||
|  | { | ||||||
|  | #if (__cpp_lib_chrono < 201907L) | ||||||
|  | #   error("Old chrono version") | ||||||
|  | #endif | ||||||
|  | } | ||||||
|  | @ -6,7 +6,7 @@ | ||||||
| #include <optional> | #include <optional> | ||||||
| #include <string> | #include <string> | ||||||
| 
 | 
 | ||||||
| #if !defined(_MSC_VER) | #if (__cpp_lib_chrono < 201907L) | ||||||
| #   include <date/tz.h> | #   include <date/tz.h> | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  | @ -15,7 +15,7 @@ namespace scwx | ||||||
| namespace util | namespace util | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| #if (defined(_MSC_VER) || defined(__clang__)) | #if (__cpp_lib_chrono >= 201907L) | ||||||
| typedef std::chrono::time_zone time_zone; | typedef std::chrono::time_zone time_zone; | ||||||
| #else | #else | ||||||
| typedef date::time_zone time_zone; | typedef date::time_zone time_zone; | ||||||
|  |  | ||||||
|  | @ -13,7 +13,7 @@ | ||||||
| 
 | 
 | ||||||
| #include <sstream> | #include <sstream> | ||||||
| 
 | 
 | ||||||
| #if !(defined(_MSC_VER) || defined(__clang__)) | #if (__cpp_lib_chrono < 201907L) | ||||||
| #   include <date/date.h> | #   include <date/date.h> | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  | @ -107,7 +107,7 @@ bool CodedTimeMotionLocation::Parse(const StringRange& lines, | ||||||
|       { |       { | ||||||
|          using namespace std::chrono; |          using namespace std::chrono; | ||||||
| 
 | 
 | ||||||
| #if !(defined(_MSC_VER) || defined(__clang__)) | #if (__cpp_lib_chrono < 201907L) | ||||||
|          using namespace date; |          using namespace date; | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -17,7 +17,7 @@ | ||||||
| #include <boost/bimap.hpp> | #include <boost/bimap.hpp> | ||||||
| #include <boost/bimap/unordered_set_of.hpp> | #include <boost/bimap/unordered_set_of.hpp> | ||||||
| 
 | 
 | ||||||
| #if !(defined(_MSC_VER) || defined(__clang__)) | #if (__cpp_lib_chrono < 201907L) | ||||||
| #   include <date/date.h> | #   include <date/date.h> | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  | @ -143,7 +143,7 @@ bool PVtec::Parse(const std::string& s) | ||||||
| { | { | ||||||
|    using namespace std::chrono; |    using namespace std::chrono; | ||||||
| 
 | 
 | ||||||
| #if !(defined(_MSC_VER) || defined(__clang__)) | #if (__cpp_lib_chrono < 201907L) | ||||||
|    using namespace date; |    using namespace date; | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -20,7 +20,7 @@ | ||||||
| 
 | 
 | ||||||
| #include <boost/algorithm/string.hpp> | #include <boost/algorithm/string.hpp> | ||||||
| 
 | 
 | ||||||
| #if !(defined(_MSC_VER) || defined(__clang__)) | #if (__cpp_lib_chrono < 201907L) | ||||||
| #   include <date/date.h> | #   include <date/date.h> | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  | @ -284,7 +284,7 @@ void Placefile::Impl::ProcessLine(const std::string& line) | ||||||
|       { |       { | ||||||
|          using namespace std::chrono; |          using namespace std::chrono; | ||||||
| 
 | 
 | ||||||
| #if !(defined(_MSC_VER) || defined(__clang__)) | #if (__cpp_lib_chrono < 201907L) | ||||||
|          using namespace date; |          using namespace date; | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -11,7 +11,7 @@ | ||||||
| #include <cpr/cpr.h> | #include <cpr/cpr.h> | ||||||
| #include <libxml/HTMLparser.h> | #include <libxml/HTMLparser.h> | ||||||
| 
 | 
 | ||||||
| #if !(defined(_MSC_VER) || defined(__clang__)) | #if (__cpp_lib_chrono < 201907L) | ||||||
| #   include <date/date.h> | #   include <date/date.h> | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  | @ -200,7 +200,7 @@ void DirListSAXHandler::Characters(void* userData, const xmlChar* ch, int len) | ||||||
|    { |    { | ||||||
|       using namespace std::chrono; |       using namespace std::chrono; | ||||||
| 
 | 
 | ||||||
| #if !(defined(_MSC_VER) || defined(__clang__)) | #if (__cpp_lib_chrono < 201907L) | ||||||
|       using namespace date; |       using namespace date; | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -5,7 +5,7 @@ | ||||||
| #include <fmt/chrono.h> | #include <fmt/chrono.h> | ||||||
| #include <fmt/format.h> | #include <fmt/format.h> | ||||||
| 
 | 
 | ||||||
| #if !(defined(_MSC_VER) || defined(__clang__)) | #if (__cpp_lib_chrono < 201907L) | ||||||
| #   include <date/date.h> | #   include <date/date.h> | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  | @ -82,7 +82,7 @@ AwsLevel2DataProvider::GetTimePointFromKey(const std::string& key) | ||||||
|    { |    { | ||||||
|       using namespace std::chrono; |       using namespace std::chrono; | ||||||
| 
 | 
 | ||||||
| #if !(defined(_MSC_VER) || defined(__clang__)) | #if (__cpp_lib_chrono < 201907L) | ||||||
|       using namespace date; |       using namespace date; | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -12,7 +12,7 @@ | ||||||
| #include <fmt/chrono.h> | #include <fmt/chrono.h> | ||||||
| #include <fmt/format.h> | #include <fmt/format.h> | ||||||
| 
 | 
 | ||||||
| #if !(defined(_MSC_VER) || defined(__clang__)) | #if (__cpp_lib_chrono < 201907L) | ||||||
| #   include <date/date.h> | #   include <date/date.h> | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  | @ -110,7 +110,7 @@ AwsLevel3DataProvider::GetTimePointFromKey(const std::string& key) | ||||||
|    { |    { | ||||||
|       using namespace std::chrono; |       using namespace std::chrono; | ||||||
| 
 | 
 | ||||||
| #if !(defined(_MSC_VER) || defined(__clang__)) | #if (__cpp_lib_chrono < 201907L) | ||||||
|       using namespace date; |       using namespace date; | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -14,7 +14,7 @@ | ||||||
| #include <libxml/HTMLparser.h> | #include <libxml/HTMLparser.h> | ||||||
| #include <re2/re2.h> | #include <re2/re2.h> | ||||||
| 
 | 
 | ||||||
| #if !(defined(_MSC_VER) || defined(__clang__)) | #if (__cpp_lib_chrono < 201907L) | ||||||
| #   include <date/date.h> | #   include <date/date.h> | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  | @ -71,7 +71,7 @@ WarningsProvider::ListFiles(std::chrono::system_clock::time_point newerThan) | ||||||
| { | { | ||||||
|    using namespace std::chrono; |    using namespace std::chrono; | ||||||
| 
 | 
 | ||||||
| #if !(defined(_MSC_VER) || defined(__clang__)) | #if (__cpp_lib_chrono < 201907L) | ||||||
|    using namespace date; |    using namespace date; | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -17,7 +17,7 @@ | ||||||
| 
 | 
 | ||||||
| #include <boost/algorithm/string.hpp> | #include <boost/algorithm/string.hpp> | ||||||
| 
 | 
 | ||||||
| #if !(defined(_MSC_VER) || defined(__clang__)) | #if (__cpp_lib_chrono < 201907L) | ||||||
| #   include <date/date.h> | #   include <date/date.h> | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  | @ -59,7 +59,7 @@ std::string TimeString(std::chrono::system_clock::time_point time, | ||||||
| { | { | ||||||
|    using namespace std::chrono; |    using namespace std::chrono; | ||||||
| 
 | 
 | ||||||
| #if (defined(_MSC_VER) || defined(__clang__)) | #if (__cpp_lib_chrono >= 201907L) | ||||||
| #   define FORMAT_STRING_24_HOUR "{:%Y-%m-%d %H:%M:%S %Z}" | #   define FORMAT_STRING_24_HOUR "{:%Y-%m-%d %H:%M:%S %Z}" | ||||||
| #   define FORMAT_STRING_12_HOUR "{:%Y-%m-%d %I:%M:%S %p %Z}" | #   define FORMAT_STRING_12_HOUR "{:%Y-%m-%d %I:%M:%S %p %Z}" | ||||||
|    namespace date = std::chrono; |    namespace date = std::chrono; | ||||||
|  | @ -128,7 +128,7 @@ TryParseDateTime(const std::string& dateTimeFormat, const std::string& str) | ||||||
| { | { | ||||||
|    using namespace std::chrono; |    using namespace std::chrono; | ||||||
| 
 | 
 | ||||||
| #if !(defined(_MSC_VER) || defined(__clang__)) | #if (__cpp_lib_chrono < 201907L) | ||||||
|    using namespace date; |    using namespace date; | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -252,6 +252,15 @@ source_group("Source Files\\wsr88d\\rda" FILES ${SRC_WSR88D_RDA}) | ||||||
| source_group("Header Files\\wsr88d\\rpg" FILES ${HDR_WSR88D_RPG}) | source_group("Header Files\\wsr88d\\rpg" FILES ${HDR_WSR88D_RPG}) | ||||||
| source_group("Source Files\\wsr88d\\rpg" FILES ${SRC_WSR88D_RPG}) | source_group("Source Files\\wsr88d\\rpg" FILES ${SRC_WSR88D_RPG}) | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | try_compile(CHRONO_HAS_TIMEZONES_AND_CALENDERS | ||||||
|  |             ${CMAKE_BINARY_DIR} | ||||||
|  |             ${PROJECT_SOURCE_DIR}/cpp-feature-tests/chrono_feature_test.cpp | ||||||
|  |             CXX_STANDARD 20 | ||||||
|  |             CXX_STANDARD_REQUIRED ON | ||||||
|  |             CXX_EXTENSIONS OFF) | ||||||
|  | message("CHRONO_HAS_TIMEZONES_AND_CALENDERS: ${CHRONO_HAS_TIMEZONES_AND_CALENDERS}") | ||||||
|  | 
 | ||||||
| target_include_directories(wxdata PRIVATE ${Boost_INCLUDE_DIR} | target_include_directories(wxdata PRIVATE ${Boost_INCLUDE_DIR} | ||||||
|                                           ${HSLUV_C_INCLUDE_DIR} |                                           ${HSLUV_C_INCLUDE_DIR} | ||||||
|                                           ${scwx-data_SOURCE_DIR}/include |                                           ${scwx-data_SOURCE_DIR}/include | ||||||
|  | @ -293,9 +302,12 @@ if (WIN32) | ||||||
|     target_link_libraries(wxdata INTERFACE Ws2_32) |     target_link_libraries(wxdata INTERFACE Ws2_32) | ||||||
| endif() | endif() | ||||||
| 
 | 
 | ||||||
|  | if (NOT CHRONO_HAS_TIMEZONES_AND_CALENDERS) | ||||||
|  |     target_link_libraries(wxdata PUBLIC date::date-tz) | ||||||
|  | endif() | ||||||
|  | 
 | ||||||
| if (NOT MSVC) | if (NOT MSVC) | ||||||
|     target_link_libraries(wxdata PUBLIC date::date-tz |     target_link_libraries(wxdata PUBLIC TBB::tbb) | ||||||
|                                         TBB::tbb) |  | ||||||
| endif() | endif() | ||||||
| 
 | 
 | ||||||
| set_target_properties(wxdata PROPERTIES CXX_STANDARD 20 | set_target_properties(wxdata PROPERTIES CXX_STANDARD 20 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat