File tree Expand file tree Collapse file tree 3 files changed +30
-4
lines changed
Expand file tree Collapse file tree 3 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,23 @@ cmake_push_check_state()
6464 CHECK_CXX_SOURCE_RUNS ( "${TEST_STD_THREAD} " HAVE_STD_THREAD ) #quotes are *required*!
6565cmake_pop_check_state ()
6666
67+ set ( TEST_STD_CHRONO "
68+ #include <iostream>
69+ #include <chrono>
70+ int main() {
71+ std::chrono::seconds sec(1);
72+ std::cout << \" 1s is \" << std::chrono::duration_cast<std::chrono::milliseconds>(sec).count() << \" ms\" << std::endl;
73+ }
74+ " )
75+ cmake_push_check_state ()
76+ if ( UNIX )
77+ set ( CMAKE_REQUIRED_FLAGS "-std=c++0x" )
78+ else ( UNIX )
79+ # vars probably need set for embarcadero, etc
80+ endif ( UNIX )
81+ CHECK_CXX_SOURCE_RUNS ( "${TEST_STD_CHRONO} " HAVE_STD_CHRONO ) #quotes are *required*!
82+ cmake_pop_check_state ()
83+
6784# Now that all the tests are done, configure the sc_cf.h file:
6885get_property (CONFIG_H_FILE_CONTENTS GLOBAL PROPERTY SC_CONFIG_H_CONTENTS )
6986file (WRITE ${CONFIG_H_FILE} "${CONFIG_H_FILE_CONTENTS} " )
Original file line number Diff line number Diff line change 2424#cmakedefine HAVE_SSIZE_T 1
2525
2626#cmakedefine HAVE_STD_THREAD 1
27+ #cmakedefine HAVE_STD_CHRONO 1
2728
2829#endif /* SCL_CF_H */
Original file line number Diff line number Diff line change 1515# error Need std::thread for this test!
1616#endif
1717
18+ #ifdef HAVE_STD_CHRONO
19+ # include < chrono>
20+ #endif
21+
1822#ifdef HAVE_UNISTD_H
1923# include < unistd.h>
2024#endif
2125
2226#include " SdaiAUTOMOTIVE_DESIGN.h"
2327
2428// macro for 50 ms sleep (could be more for a larger file, may need reduced for a fast processor)
25- #ifndef __WIN32__
26- # define DELAY (t ) usleep( t * 100 );
29+ #ifdef HAVE_STD_CHRONO
30+ # define DELAY (t ) std::this_thread::sleep_for(std::chrono::milliseconds( 50 ) );
2731#else
28- #define DELAY (t ) Sleep( t );
32+ # ifndef __WIN32__
33+ # define DELAY (t ) usleep( t * 100 )
34+ # else
35+ # include < WinBase.h>
36+ # define DELAY (t ) Sleep( t )
37+ # endif
2938#endif
3039
31-
3240// NOTE this test requires std::thread, part of C++11. It will fail to compile otherwise.
3341
3442void readProgressParallel ( STEPfile & f, float & maxProgress ) {
You can’t perform that action at this time.
0 commit comments