File tree Expand file tree Collapse file tree 3 files changed +51
-12
lines changed
Expand file tree Collapse file tree 3 files changed +51
-12
lines changed Original file line number Diff line number Diff line change @@ -97,4 +97,12 @@ target_link_libraries(sysyplus_compiler ${llvm_libs})
9797# ${CMAKE_SOURCE_DIR}/ui/ui ${CMAKE_CURRENT_BINARY_DIR}/ui)
9898
9999#message(STATUS "配置目标库")
100- #add_subdirectory(module)
100+ #add_subdirectory(module)
101+
102+ # time module
103+ aux_source_directory (module/time/src TIME_MODULE)
104+ message (STATUS "${TIME_MODULE} " )
105+ add_library (time "${TIME_MODULE} " )
106+
107+ # test.cpp
108+ add_executable (test test /test1.c)
Original file line number Diff line number Diff line change @@ -3,23 +3,27 @@ project(KingtousProject)
33set (CMAKE_CXX_STANDARD 17)
44
55message (STATUS ${CMAKE_SOURCE_DIR} )
6- set (CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR} /time/ obj/unknown)
7- set (LOCATION "" )
6+ set (CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR} /obj/unknown)
7+ set (LOCATION ". " )
88
99if (APPLE )
1010 message (STATUS "macOS detected" )
11- set (CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR} /time/ obj/x86_64/mac)
12- # set(CMAKE_C_FLAGS "-fPIC")
13- # set(CMAKE_SHARED_LINKER_FLAGS "-fPIC")
11+ set (CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR} /obj/x86_64/mac)
12+ # set(CMAKE_C_FLAGS "-fPIC")
13+ # set(CMAKE_SHARED_LINKER_FLAGS "-fPIC")
1414endif ()
1515
16- if (LINUX )
17- set (CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR} /time/ obj/x86_64/linux)
18- message (STATUS "linux detected" )
16+ if (UNIX )
17+ set (CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR} /obj/x86_64/linux)
18+ message (STATUS "unix detected" )
1919endif ()
2020
2121aux_source_directory (src SRC)
2222
2323add_library (time STATIC ${SRC} )
2424
25- install (TARGETS time LIBRARY DESTINATION ${LOCATION} )
25+
26+ install (TARGETS time
27+ ARCHIVE DESTINATION ${LOCATION}
28+ LIBRARY DESTINATION ${LOCATION}
29+ )
Original file line number Diff line number Diff line change 22// Created by 金韬 on 2021/2/26.
33//
44
5+ #ifdef WIN32
6+ #include <Windows.h>
7+ #include <time.h>
8+ #else
59
610#include <sys/time.h>
711
12+ #endif
13+
14+ #ifdef WIN32
15+ int gettimeofday (struct timeval * tp , void * tzp )
16+ {
17+ time_t clock ;
18+ struct tm tm ;
19+ SYSTEMTIME wtm ;
20+ GetLocalTime (& wtm );
21+ tm .tm_year = wtm .wYear - 1900 ;
22+ tm .tm_mon = wtm .wMonth - 1 ;
23+ tm .tm_mday = wtm .wDay ;
24+ tm .tm_hour = wtm .wHour ;
25+ tm .tm_min = wtm .wMinute ;
26+ tm .tm_sec = wtm .wSecond ;
27+ tm .tm_isdst = -1 ;
28+ clock = mktime (& tm );
29+ tp -> tv_sec = clock ;
30+ tp -> tv_usec = wtm .wMilliseconds * 1000 ;
31+ return (0 );
32+ }
33+ #endif
34+
835/**
936 * 获取ms数
1037 * @return ms
1138 */
12- long __getms (){
39+ long __getms () {
1340 struct timeval tp ;
14- gettimeofday (& tp , NULL );
41+ gettimeofday (& tp , 0 );
1542 long ms = tp .tv_sec * 1000 + tp .tv_usec / 1000 ;
1643 return ms ;
1744}
You can’t perform that action at this time.
0 commit comments