Support for MSVC 2013 -- Take 2#190
Conversation
…oved OpenCV searching/installing, instead rely on cmake find_package. Tested in Windows Mingw64-32 bit, Ubuntu local and system OpenCV, OSX local and system OpenCV.
… Also switched libusb to a submodule. Note that the MSVC build currently does not work with OpenCV3 whereas all other builds do.
…event mismatches in debug/release CRT libraries in applications linking to libusb - /W4 instead of /Wall (/Wall in msvc is not equivalent to -Wall in gcc) - Support for msvc solution folders - Set cmake project
… using the PS3EyeDriver was inside the PSMOVE_USE_PSEYE block, which seems to be used for capturing through opencv
- Disabled some unimportant (spammy) warnings
…d in the generated VS2013 solution - Fixed some warnings in cmaera_control_win32.c - When using the PS3EyeDriver, camera control settings are no longer saved/restore from the registry
- Added SDL2 support (FindSDL2.cmake) to examples/CMakeLists.txt - OpenGL examples now build again. Most of the work done by cboulay (psmoveservice@348c1d2). I simply took the relevant changes and modified them a bit (FindSDL2 finds both debug & release versions of the libs so there is no mismatching of debug/release CRT going on + post-build command copy correct debug/release version of SDL2.dll) - Fixed bug in test_opengl2 (particles were incorrectly removed from the particles list)
- Suppressed some more warnings
…h PSMoveAPI instead of relying on OpenCV camera capture support
…busb and ps3eyedriver) still have warnings, but I don't know how to get changes to files in submodules back to GitHub.
- Enabled debug information for all configurations on msvc, not just Debug - Fixed some incorrect code when building Release. Code inside assert(...) is compiled out in release, causing things like setsockopt not to be called, which is probably wrong. Moved critical code inside asserts outside of the assert and assert on the result value instead.
|
Thanks for the work; that's a big change. I could start by cherry-picking some changes and then review the rest? There are nearly 40.000 lines removed and only 1.300 added; is this intended? |
|
@thp , the reason for the almost 40k lines removed is that the libusb source has been removed and replaced with a submodule. A large chunk of the added 1.3k lines is adding pthreads-w32 to external. If you deem it necessary, it might be possible for @rovarma to first do the libusb replacement (and corresponding changes to the build system) as a separate pull request (A), then do the pthreads addition by itself as another (B, based on A), and finally this PR (C, based on B). Then you can more easily browse the detailed changes to psmoveapi after you've merged B (> A). One problem with this is that 'B' will be pointless without the changes in C so you'll have to merge B on faith that C is forthcoming. |
|
@cboulay already explained what the reason is for the removal of 40k lines, but to summarize what's changed at a high level:
Altogether, if you disregard the removal of libusb and addition of pthreads, this is actually a surprisingly small change. I can imagine though that it's a bit hard for you to review in its current form; I'm open to redoing this in a way that makes it easier for you. I could do the thing @cboulay suggested (issueing seperate pull requests), but I'd need someone to walk me through how to do that; I'm a complete Git(Hub) noob. |
|
You're absolutely right that pthreads-w32 is not needed. I actually don't have it in my fork's master anymore. But getting rid of pthreads-w32 means lots of little changes to the code that makes it a bit harder to evaluate. Same with getopt.c and unistd.c. That's why my I haven't tested it exactly, but your git flow would look something like the following (please backup the directory before attempting this):
When thp views the pull requests, the libusb_submodule PR will have only the changes in that branch, the win32_posix will have the libusb_submodule changes AND the changes from its branch, and the last PR will have all the changes. Viewing the vs2013 PR will be like viewing the present PR, unless he first merges the previous PRs or he uses github URL trickery to compare the vs2013 PR against (e.g.) the win32_posix PR. |
BTW, since this exact same problem with submodules comes up from time to |
|
@cboulay Thanks for the detailed instructions. It seems like quite a bit of work (having to redo the changes in different branches, basically). I'll leave it up to @thp if he wants me to do that or not. @nitsch Actually, one of the changes @cboulay has made as part of the CMake refactor is that OpenCV can now be a locally built version. I believe it first searches for a version in /external/ and if it can't find it there, use the system version. |
The option for a locally built OpenCV was part of the build system |
|
@nitch Okay -- I misunderstood what you meant then. |
|
@rovarma , Honestly, I can't remember. And that was at a time when OpenCV3 was still in beta. It might work now. You'll probably have to make some changes, especially in the cmake files, but it may work now. |
|
@cboulay Okay. I tested OpenCV 3.0 and while it builds & links fine (no changes needed to the CMake files), it crashes when running test_tracker in cvGetSize during psmove_tracker_blinking_calibration. Looking at the disassembly, it appears that incorrect code is generated for cvGetSize (it's reading the argument to cvGetSize from the wrong register, causing it to basically work with a garbage pointer). This is probably due to some disagreement between PSMoveAPI and OpenCV 3.0 about what the memory layout of CvSize is, causing caller and callee not to match up during code gen. I haven't tracked it down exactly yet, but it should be relatively straightforward to find and fix. It's not a high priority for me right now, but I might have a look at it over the weekend. @thp Any news on how you want to proceed with this PR? |
|
Reviewing this one right now |
I needed VS2013 support, but noticed that the pull request for it (#182) is in a bit of a limbo state. As @cboulay suggested in the comments, I took his original changes and finished them; the credit for the CMake work goes to him.
I've further extended his CMake changes and fixed some code which, as far as I can tell, never should have compiled/worked in the first place (?).
With this, the VS2013 solution is correctly generated and all projects now build without warnings or errors (I have not tested the bindings because I don't know how).
Note: I've tried to keep all my cmake changes in IF(MSVC), so it shouldn't affect other platforms/compilers, but I don't have a linux or osx system to test on, so I can't be sure.