Merge pull request #15059 from hugolm84:improved-support-for-wince

* Improve support for Windows Embedded Compact

* Remove redundant set(WINCE true) and format CMake
pull/15150/head
Hugo Lindström 5 years ago committed by Alexander Alekhin
parent ad092bf1ce
commit 2ee00e7f7d
  1. 2
      3rdparty/zlib/zutil.c
  2. 2
      3rdparty/zlib/zutil.h
  3. 62
      CMakeLists.txt
  4. 2
      modules/core/include/opencv2/core/utils/filesystem.private.hpp
  5. 6
      modules/core/src/glob.cpp
  6. 2
      modules/core/src/ocl.cpp
  7. 24
      modules/core/src/system.cpp
  8. 12
      platforms/wince/arm-wince-headless-overrides.cmake
  9. 35
      platforms/wince/arm-wince.toolchain.cmake
  10. 62
      platforms/wince/readme.md

@ -136,7 +136,7 @@ const char * ZEXPORT zError(err)
return ERR_MSG(err); return ERR_MSG(err);
} }
#if defined(_WIN32_WCE) #if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
/* The Microsoft C Run-Time Library for Windows CE doesn't have /* The Microsoft C Run-Time Library for Windows CE doesn't have
* errno. We define it as a global variable to simplify porting. * errno. We define it as a global variable to simplify porting.
* Its value is always 0 and should not be used. * Its value is always 0 and should not be used.

@ -169,11 +169,13 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX #if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
# if defined(_WIN32_WCE) # if defined(_WIN32_WCE)
# if _WIN32_WCE < 0x800
# define fdopen(fd,mode) NULL /* No fdopen() */ # define fdopen(fd,mode) NULL /* No fdopen() */
# ifndef _PTRDIFF_T_DEFINED # ifndef _PTRDIFF_T_DEFINED
typedef int ptrdiff_t; typedef int ptrdiff_t;
# define _PTRDIFF_T_DEFINED # define _PTRDIFF_T_DEFINED
# endif # endif
# endif
# else # else
# define fdopen(fd,type) _fdopen(fd,type) # define fdopen(fd,type) _fdopen(fd,type)
# endif # endif

@ -53,35 +53,6 @@ if(NOT DEFINED CMAKE_INSTALL_PREFIX)
endif() endif()
endif() endif()
if(CMAKE_SYSTEM_NAME MATCHES WindowsPhone OR CMAKE_SYSTEM_NAME MATCHES WindowsStore)
set(WINRT TRUE)
endif()
if(WINRT)
add_definitions(-DWINRT -DNO_GETENV)
# Making definitions available to other configurations and
# to filter dependency restrictions at compile time.
if(CMAKE_SYSTEM_NAME MATCHES WindowsPhone)
set(WINRT_PHONE TRUE)
add_definitions(-DWINRT_PHONE)
elseif(CMAKE_SYSTEM_NAME MATCHES WindowsStore)
set(WINRT_STORE TRUE)
add_definitions(-DWINRT_STORE)
endif()
if(CMAKE_SYSTEM_VERSION MATCHES 10)
set(WINRT_10 TRUE)
add_definitions(-DWINRT_10)
elseif(CMAKE_SYSTEM_VERSION MATCHES 8.1)
set(WINRT_8_1 TRUE)
add_definitions(-DWINRT_8_1)
elseif(CMAKE_SYSTEM_VERSION MATCHES 8.0)
set(WINRT_8_0 TRUE)
add_definitions(-DWINRT_8_0)
endif()
endif()
if(POLICY CMP0026) if(POLICY CMP0026)
cmake_policy(SET CMP0026 NEW) cmake_policy(SET CMP0026 NEW)
endif() endif()
@ -136,6 +107,39 @@ enable_testing()
project(OpenCV CXX C) project(OpenCV CXX C)
if(CMAKE_SYSTEM_NAME MATCHES WindowsPhone OR CMAKE_SYSTEM_NAME MATCHES WindowsStore)
set(WINRT TRUE)
endif()
if(WINRT OR WINCE)
add_definitions(-DNO_GETENV)
endif()
if(WINRT)
add_definitions(-DWINRT)
# Making definitions available to other configurations and
# to filter dependency restrictions at compile time.
if(CMAKE_SYSTEM_NAME MATCHES WindowsPhone)
set(WINRT_PHONE TRUE)
add_definitions(-DWINRT_PHONE)
elseif(CMAKE_SYSTEM_NAME MATCHES WindowsStore)
set(WINRT_STORE TRUE)
add_definitions(-DWINRT_STORE)
endif()
if(CMAKE_SYSTEM_VERSION MATCHES 10)
set(WINRT_10 TRUE)
add_definitions(-DWINRT_10)
elseif(CMAKE_SYSTEM_VERSION MATCHES 8.1)
set(WINRT_8_1 TRUE)
add_definitions(-DWINRT_8_1)
elseif(CMAKE_SYSTEM_VERSION MATCHES 8.0)
set(WINRT_8_0 TRUE)
add_definitions(-DWINRT_8_0)
endif()
endif()
if(MSVC) if(MSVC)
set(CMAKE_USE_RELATIVE_PATHS ON CACHE INTERNAL "" FORCE) set(CMAKE_USE_RELATIVE_PATHS ON CACHE INTERNAL "" FORCE)
endif() endif()

@ -9,7 +9,7 @@
#ifndef OPENCV_HAVE_FILESYSTEM_SUPPORT #ifndef OPENCV_HAVE_FILESYSTEM_SUPPORT
# if defined(__EMSCRIPTEN__) || defined(__native_client__) # if defined(__EMSCRIPTEN__) || defined(__native_client__)
/* no support */ /* no support */
# elif defined WINRT # elif defined WINRT || defined _WIN32_WCE
/* not supported */ /* not supported */
# elif defined __ANDROID__ || defined __linux__ || defined _WIN32 || \ # elif defined __ANDROID__ || defined __linux__ || defined _WIN32 || \
defined __FreeBSD__ || defined __bsdi__ || defined __HAIKU__ defined __FreeBSD__ || defined __bsdi__ || defined __HAIKU__

@ -57,7 +57,7 @@ namespace
struct DIR struct DIR
{ {
#ifdef WINRT #if defined(WINRT) || defined(_WIN32_WCE)
WIN32_FIND_DATAW data; WIN32_FIND_DATAW data;
#else #else
WIN32_FIND_DATAA data; WIN32_FIND_DATAA data;
@ -78,7 +78,7 @@ namespace
{ {
DIR* dir = new DIR; DIR* dir = new DIR;
dir->ent.d_name = 0; dir->ent.d_name = 0;
#ifdef WINRT #if defined(WINRT) || defined(_WIN32_WCE)
cv::String full_path = cv::String(path) + "\\*"; cv::String full_path = cv::String(path) + "\\*";
wchar_t wfull_path[MAX_PATH]; wchar_t wfull_path[MAX_PATH];
size_t copied = mbstowcs(wfull_path, full_path.c_str(), MAX_PATH); size_t copied = mbstowcs(wfull_path, full_path.c_str(), MAX_PATH);
@ -100,7 +100,7 @@ namespace
dirent* readdir(DIR* dir) dirent* readdir(DIR* dir)
{ {
#ifdef WINRT #if defined(WINRT) || defined(_WIN32_WCE)
if (dir->ent.d_name != 0) if (dir->ent.d_name != 0)
{ {
if (::FindNextFileW(dir->handle, &dir->data) != TRUE) if (::FindNextFileW(dir->handle, &dir->data) != TRUE)

@ -1722,7 +1722,7 @@ static bool parseOpenCLDeviceConfiguration(const std::string& configurationStr,
return true; return true;
} }
#ifdef WINRT #if defined WINRT || defined _WIN32_WCE
static cl_device_id selectOpenCLDevice() static cl_device_id selectOpenCLDevice()
{ {
return NULL; return NULL;

@ -378,7 +378,7 @@ struct HWFeatures
void initialize(void) void initialize(void)
{ {
#ifndef WINRT #ifndef NO_GETENV
if (getenv("OPENCV_DUMP_CONFIG")) if (getenv("OPENCV_DUMP_CONFIG"))
{ {
fprintf(stderr, "\nOpenCV build configuration is:\n%s\n", fprintf(stderr, "\nOpenCV build configuration is:\n%s\n",
@ -614,10 +614,10 @@ struct HWFeatures
{ {
bool dump = true; bool dump = true;
const char* disabled_features = const char* disabled_features =
#ifndef WINRT #ifdef NO_GETENV
getenv("OPENCV_CPU_DISABLE");
#else
NULL; NULL;
#else
getenv("OPENCV_CPU_DISABLE");
#endif #endif
if (disabled_features && disabled_features[0] != 0) if (disabled_features && disabled_features[0] != 0)
{ {
@ -892,7 +892,7 @@ String format( const char* fmt, ... )
String tempfile( const char* suffix ) String tempfile( const char* suffix )
{ {
String fname; String fname;
#ifndef WINRT #ifndef NO_GETENV
const char *temp_dir = getenv("OPENCV_TEMP_PATH"); const char *temp_dir = getenv("OPENCV_TEMP_PATH");
#endif #endif
@ -913,6 +913,20 @@ String tempfile( const char* suffix )
CV_Assert((copied != MAX_PATH) && (copied != (size_t)-1)); CV_Assert((copied != MAX_PATH) && (copied != (size_t)-1));
fname = String(aname); fname = String(aname);
RoUninitialize(); RoUninitialize();
#elif defined(_WIN32_WCE)
const auto kMaxPathSize = MAX_PATH+1;
wchar_t temp_dir[kMaxPathSize] = {0};
wchar_t temp_file[kMaxPathSize] = {0};
::GetTempPathW(kMaxPathSize, temp_dir);
if(0 != ::GetTempFileNameW(temp_dir, L"ocv", 0, temp_file)) {
DeleteFileW(temp_file);
char aname[MAX_PATH];
size_t copied = wcstombs(aname, temp_file, MAX_PATH);
CV_Assert((copied != MAX_PATH) && (copied != (size_t)-1));
fname = String(aname);
}
#else #else
char temp_dir2[MAX_PATH] = { 0 }; char temp_dir2[MAX_PATH] = { 0 };
char temp_file[MAX_PATH] = { 0 }; char temp_file[MAX_PATH] = { 0 };

@ -0,0 +1,12 @@
if(WINCE)
# CommCtrl.lib does not exist in headless WINCE Adding this will make CMake
# Try_Compile succeed and therefore also C/C++ ABI Detetection work
# https://gitlab.kitware.com/cmake/cmake/blob/master/Modules/Platform/Windows-
# MSVC.cmake
set(CMAKE_C_STANDARD_LIBRARIES_INIT "coredll.lib")
set(CMAKE_CXX_STANDARD_LIBRARIES_INIT ${CMAKE_C_STANDARD_LIBRARIES_INIT})
foreach(ID EXE SHARED MODULE)
string(APPEND CMAKE_${ID}_LINKER_FLAGS_INIT
" /NODEFAULTLIB:libc.lib /NODEFAULTLIB:oldnames.lib")
endforeach()
endif()

@ -0,0 +1,35 @@
set(CMAKE_SYSTEM_NAME WindowsCE)
if(NOT CMAKE_SYSTEM_VERSION)
set(CMAKE_SYSTEM_VERSION 8.0)
endif()
if(NOT CMAKE_SYSTEM_PROCESSOR)
set(CMAKE_SYSTEM_PROCESSOR armv7-a)
endif()
if(NOT CMAKE_GENERATOR_TOOLSET)
set(CMAKE_GENERATOR_TOOLSET CE800)
endif()
# Needed to make try_compile to succeed
if(BUILD_HEADLESS)
set(CMAKE_USER_MAKE_RULES_OVERRIDE
${CMAKE_CURRENT_LIST_DIR}/arm-wince-headless-overrides.cmake)
endif()
if(NOT CMAKE_FIND_ROOT_PATH_MODE_PROGRAM)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
endif()
if(NOT CMAKE_FIND_ROOT_PATH_MODE_LIBRARY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
endif()
if(NOT CMAKE_FIND_ROOT_PATH_MODE_INCLUDE)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
endif()
if(NOT CMAKE_FIND_ROOT_PATH_MODE_PACKAGE)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
endif()

@ -0,0 +1,62 @@
# Building OpenCV from Source for Windows Embedded Compact (WINCE/WEC)
## Requirements
CMake 3.1.0 or higher
Windows Embedded Compact SDK
## Configuring
To configure CMake for Windows Embedded, specify Visual Studio 2013 as generator and the name of your installed SDK:
`cmake -G "Visual Studio 12 2013" -A "MySDK WEC2013" -DCMAKE_TOOLCHAIN_FILE:FILEPATH=../platforms/wince/arm-wince.toolchain.cmake`
If you are building for a headless WINCE, specify `-DBUILD_HEADLESS=ON` when configuring. This will remove the `commctrl.lib` dependency.
If you are building for anything else than WINCE800, you need to specify that in the configuration step. Example:
```
-DCMAKE_SYSTEM_VERSION=7.0 -DCMAKE_GENERATOR_TOOLSET=CE700 -DCMAKE_SYSTEM_PROCESSOR=arm-v4
```
For headless WEC2013, this configuration may not be limited to but is known to work:
```
-DBUILD_EXAMPLES=OFF `
-DBUILD_opencv_apps=OFF `
-DBUILD_opencv_calib3d=OFF `
-DBUILD_opencv_highgui=OFF `
-DBUILD_opencv_features2d=OFF `
-DBUILD_opencv_flann=OFF `
-DBUILD_opencv_ml=OFF `
-DBUILD_opencv_objdetect=OFF `
-DBUILD_opencv_photo=OFF `
-DBUILD_opencv_shape=OFF `
-DBUILD_opencv_stitching=OFF `
-DBUILD_opencv_superres=OFF `
-DBUILD_opencv_ts=OFF `
-DBUILD_opencv_video=OFF `
-DBUILD_opencv_videoio=OFF `
-DBUILD_opencv_videostab=OFF `
-DBUILD_opencv_dnn=OFF `
-DBUILD_opencv_java=OFF `
-DBUILD_opencv_python2=OFF `
-DBUILD_opencv_python3=OFF `
-DBUILD_opencv_java_bindings_generator=OFF `
-DBUILD_opencv_python_bindings_generator=OFF `
-DBUILD_TIFF=OFF `
-DCV_TRACE=OFF `
-DWITH_OPENCL=OFF `
-DHAVE_OPENCL=OFF `
-DWITH_QT=OFF `
-DWITH_GTK=OFF `
-DWITH_QUIRC=OFF `
-DWITH_JASPER=OFF `
-DWITH_WEBP=OFF `
-DWITH_PROTOBUF=OFF `
-DBUILD_SHARED_LIBS=OFF `
-DWITH_OPENEXR=OFF `
-DWITH_TIFF=OFF `
```
## Building
You are required to build using Unicode:
`cmake --build . -- /p:CharacterSet=Unicode`
Loading…
Cancel
Save