add std::chrono test, if available use in thread test
This commit is contained in:
parent
135adc76c8
commit
17b41da525
3 changed files with 30 additions and 4 deletions
|
|
@ -64,6 +64,23 @@ cmake_push_check_state()
|
|||
CHECK_CXX_SOURCE_RUNS( "${TEST_STD_THREAD}" HAVE_STD_THREAD ) #quotes are *required*!
|
||||
cmake_pop_check_state()
|
||||
|
||||
set( TEST_STD_CHRONO "
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
int main() {
|
||||
std::chrono::seconds sec(1);
|
||||
std::cout << \"1s is \"<< std::chrono::duration_cast<std::chrono::milliseconds>(sec).count() << \" ms\" << std::endl;
|
||||
}
|
||||
" )
|
||||
cmake_push_check_state()
|
||||
if( UNIX )
|
||||
set( CMAKE_REQUIRED_FLAGS "-std=c++0x" )
|
||||
else( UNIX )
|
||||
# vars probably need set for embarcadero, etc
|
||||
endif( UNIX )
|
||||
CHECK_CXX_SOURCE_RUNS( "${TEST_STD_CHRONO}" HAVE_STD_CHRONO ) #quotes are *required*!
|
||||
cmake_pop_check_state()
|
||||
|
||||
# Now that all the tests are done, configure the sc_cf.h file:
|
||||
get_property(CONFIG_H_FILE_CONTENTS GLOBAL PROPERTY SC_CONFIG_H_CONTENTS)
|
||||
file(WRITE ${CONFIG_H_FILE} "${CONFIG_H_FILE_CONTENTS}")
|
||||
|
|
|
|||
|
|
@ -24,5 +24,6 @@
|
|||
#cmakedefine HAVE_SSIZE_T 1
|
||||
|
||||
#cmakedefine HAVE_STD_THREAD 1
|
||||
#cmakedefine HAVE_STD_CHRONO 1
|
||||
|
||||
#endif /* SCL_CF_H */
|
||||
|
|
|
|||
|
|
@ -15,6 +15,10 @@
|
|||
# error Need std::thread for this test!
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STD_CHRONO
|
||||
# include <chrono>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
|
@ -22,13 +26,17 @@
|
|||
#include "SdaiAUTOMOTIVE_DESIGN.h"
|
||||
|
||||
//macro for 50 ms sleep (could be more for a larger file, may need reduced for a fast processor)
|
||||
#ifndef __WIN32__
|
||||
# define DELAY(t) usleep( t * 100 );
|
||||
#ifdef HAVE_STD_CHRONO
|
||||
# define DELAY(t) std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||
#else
|
||||
#define DELAY(t) Sleep( t );
|
||||
# ifndef __WIN32__
|
||||
# define DELAY(t) usleep( t * 100 )
|
||||
# else
|
||||
# include <WinBase.h>
|
||||
# define DELAY(t) Sleep( t )
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
// NOTE this test requires std::thread, part of C++11. It will fail to compile otherwise.
|
||||
|
||||
void readProgressParallel( STEPfile & f, float & maxProgress ) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue