MantisBT - CMake
View Issue Details
0012128CMakeModulespublic2011-04-27 14:122011-11-11 10:45
Dat Chu 
Philip Lowman 
normalminoralways
closedfixed 
x86-64Windows7
CMake 2.8.4 
CMake 2.8.5CMake 2.8.5 
0012128: FindProtobuf module behavior under Windows is annoying
FindProtobuf module at the moment does not allow a Windows user to choose where he has downloaded and built the ProtocolBuffer library. It forces the user to choose by hand 4 variables: library, include, protoc library and protoc executable.

If the user chooses a Release version of the built programs and libraries, then try to build his project in Debug mode, he will receive the error: _iterator_debug_level value '0' doesn't match value '2'

The module currently, thus, does not support multi-type build on Windows
- Build ProtocolBuffer
- Configure a project which uses ProtocolBuffer choosing the Release version
- Build the project in Debug
Attached is the updated FindProtobuf.cmake which solves these issues. Under Windows, there is a new variable: PROTOBUF_SRC_ROOT_FOLDER which will be used to resolved the rest of the variables. The user only need to specify this variable in order to have ProtocolBuffer detected.

Steps:
- Download ProtocolBuffer
- Build ProtocolBuffer with the supplied sln file
- Configure project which uses ProtocolBuffer
- Set PROTOBUF_SRC_ROOT_FOLDER to where one downloaded ProtocolBuffer
No tags attached.
? FindProtobuf.cmake (5,946) 2011-04-27 14:12
https://public.kitware.com/Bug/file/3835/FindProtobuf.cmake
? FindProtobuf2.cmake (6,409) 2011-05-03 00:09
https://public.kitware.com/Bug/file/3845/FindProtobuf2.cmake
Issue History
2011-04-27 14:12Dat ChuNew Issue
2011-04-27 14:12Dat ChuFile Added: FindProtobuf.cmake
2011-04-29 13:31Brad KingNote Added: 0026287
2011-04-29 13:31Brad KingStatusnew => backlog
2011-05-01 18:13Dat ChuNote Added: 0026295
2011-05-02 00:18Philip LowmanAssigned To => Philip Lowman
2011-05-02 00:18Philip LowmanStatusbacklog => assigned
2011-05-03 00:08Philip LowmanTarget Version => CMake 2.8.5
2011-05-03 00:09Philip LowmanFile Added: FindProtobuf2.cmake
2011-05-03 00:23Dat ChuNote Added: 0026418
2011-05-03 00:23Philip LowmanNote Added: 0026419
2011-05-03 00:36Dat ChuNote Added: 0026420
2011-05-04 01:35Philip LowmanNote Added: 0026427
2011-05-25 22:09Philip LowmanNote Added: 0026603
2011-05-25 22:09Philip LowmanStatusassigned => resolved
2011-05-25 22:09Philip LowmanResolutionopen => fixed
2011-05-25 22:09Philip LowmanFixed in Version => CMake 2.8.5
2011-11-11 10:45David ColeNote Added: 0027767
2011-11-11 10:45David ColeStatusresolved => closed

Notes
(0026287)
Brad King   
2011-04-29 13:31   
http://www.cmake.org/Wiki/CMake:Module_Maintainers [^]
(0026295)
Dat Chu   
2011-05-01 18:13   
Contacting FindProtobuf.cmake volunteer maintainer.
(0026418)
Dat Chu   
2011-05-03 00:23   
Great improvement in FindProtobuf2.cmake. Thank you Phillip. I added my name in the Copyright section. I guess we don't need that now. Could you please remove it in the final commit?
(0026419)
Philip Lowman   
2011-05-03 00:23   
Dat,

Thanks for the patch. I've attached a modified version based on your work to this ticket (FindProtobuf2.cmake). Could you please test it? If you have any additional ideas for improving it please let me know.


Your version worked fine, except that it breaks backwards compatibility if anyone defines PROTOBUF_LIBRARY as a cache variable. In CMake, local variables with the same name always override cached variables once they are set().

The solution is to make the normal variable 'PROTOBUF_LIBRARIES' include the debug libraries only if the user is using them.

I also included protobuf-lite in case anyone needs to use that and encapsulated all of the find_library calls into a function.
(0026420)
Dat Chu   
2011-05-03 00:36   
I have tested your FindProtobuf2.cmake. It works great. The addition support for Protobuf Lite is a good addition. Thank you very much.
(0026427)
Philip Lowman   
2011-05-04 01:35   
Dat,

Thanks for testing. I will remove your name from the final commit and push it into git soon.
(0026603)
Philip Lowman   
2011-05-25 22:09   
Should be in the next RC for 2.8.5 (RC02)


Merged topic '12128_FindProtobuf_module_behavior_under_Windows_is_annoying' into next

ca000a0 FindProtobuf: Better MSVC support, Searching for protobuf lite
(0027767)
David Cole   
2011-11-11 10:45   
Closing resolved issues that have not been updated in more than 4 months.