diff --git a/cmake/SC_Config_Headers.cmake b/cmake/SC_Config_Headers.cmake index dc005f34..6fe3e7c6 100644 --- a/cmake/SC_Config_Headers.cmake +++ b/cmake/SC_Config_Headers.cmake @@ -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 +#include +int main() { + std::chrono::seconds sec(1); + std::cout << \"1s is \"<< std::chrono::duration_cast(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}") diff --git a/include/sc_cf_cmake.h.in b/include/sc_cf_cmake.h.in index fcb59df4..417e5c57 100644 --- a/include/sc_cf_cmake.h.in +++ b/include/sc_cf_cmake.h.in @@ -24,5 +24,6 @@ #cmakedefine HAVE_SSIZE_T 1 #cmakedefine HAVE_STD_THREAD 1 +#cmakedefine HAVE_STD_CHRONO 1 #endif /* SCL_CF_H */ diff --git a/test/cpp/schema_specific/stepfile_rw_progress.cc b/test/cpp/schema_specific/stepfile_rw_progress.cc index 03d5949d..f6f43da6 100644 --- a/test/cpp/schema_specific/stepfile_rw_progress.cc +++ b/test/cpp/schema_specific/stepfile_rw_progress.cc @@ -15,6 +15,10 @@ # error Need std::thread for this test! #endif +#ifdef HAVE_STD_CHRONO +# include +#endif + #ifdef HAVE_UNISTD_H # include #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 +# 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 ) {