diff --git a/osal/CMakeLists.txt b/osal/CMakeLists.txt index c3a8e95f..32fdecc6 100644 --- a/osal/CMakeLists.txt +++ b/osal/CMakeLists.txt @@ -18,19 +18,25 @@ add_library(osal STATIC # On window import win32 pthread library # ---------------------------------------------------------------------------- if(MSVC) - set(WIN32_PTHREAD_INCLUDE_DIRS window/pthread/inc) + set(WIN32_PTHREAD_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/window/pthread/inc") include_directories(${WIN32_PTHREAD_INCLUDE_DIRS}) add_library(pthread STATIC IMPORTED) message(STATUS "platform X86 ${X86} X64 ${X64}") + set(WIN32_PTHREAD_LIB_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/window/pthread/lib") + set(WIN32_PTHREAD_DLL_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/window/pthread/dll") if(X64) + set(WIN32_ARCH "x64") set_target_properties(pthread PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/window/pthread/lib/x64/pthreadVC2.lib") else() + set(WIN32_ARCH "x86") + endif() + include_directories("${WIN32_PTHREAD_LIB_DIRS}/${WIN32_ARCH}") + include_directories("${WIN32_PTHREAD_DLL_DIRS}/${WIN32_ARCH}") set_target_properties(pthread PROPERTIES IMPORTED_LOCATION - "${CMAKE_CURRENT_SOURCE_DIR}/window/pthread/lib/x86/pthreadVC2.lib") - endif() + "${WIN32_PTHREAD_LIB_DIRS}/${WIN32_ARCH}/pthreadVC2.lib") endif() target_link_libraries(osal pthread) install(TARGETS osal diff --git a/osal/inc/rk_thread.h b/osal/inc/rk_thread.h index 4e34d7f1..b4cf4d02 100644 --- a/osal/inc/rk_thread.h +++ b/osal/inc/rk_thread.h @@ -33,6 +33,7 @@ #include #include "pthread.h" #define sleep Sleep +#pragma comment(lib, "pthreadVC2.lib") #else diff --git a/readme.txt b/readme.txt index c9f3699b..da8fb7a7 100644 --- a/readme.txt +++ b/readme.txt @@ -14,6 +14,9 @@ c. header file should not contain any relative path or absolute path, all includ a. for cross platform compiling use cmake as the compiling management system. b. use cmake out-of-source build, final binary and library will be install to out/ directory. +NOTE: +1. when run on window pthreadVC2.dll needed to be copied to the system directory. + ---- top | |----- build CMake out-of-source build directory