MantisBT - CMake
View Issue Details
0014833CMakeCMakepublic2014-03-24 20:302016-01-04 11:52
David Hait 
Brad King 
normalminoralways
closedfixed 
x64Windows7
CMake 2.8.11.2 
CMake 3.4CMake 3.4 
0014833: FindProtobuf module under Windows doesn't support 64-bit builds
Default Windows protobuf library builds go in x64\Debug and x64\Release directories, rather than Debug and Release.
The FindProtobuf module has the library directories hard-coded; there is no way to specify the x64 directories to search for the libraries.
1.Build ProtocolBuffer with the VS project using x64 settings
2.Run cmake with FindProtobuf as part of a CMakeLists.txt
3.Run msbuild

Error:
 libprotobuf.lib(common.obj) : fatal error LNK1112: module machine type 'X86'
conflicts with target machine type 'x64' [C:\omserv\build\src\omserv.vcxproj]
There should be an additional CMake variable to specify the library folder.
No tags attached.
diff patch-cmake-protobuf-64.diff (2,640) 2015-07-07 20:27
https://public.kitware.com/Bug/file/5482/patch-cmake-protobuf-64.diff
patch 0001-FindProtobuf-Search-x64-directories-in-VS-built-prot.patch (2,723) 2015-07-08 10:25
https://public.kitware.com/Bug/file/5486/0001-FindProtobuf-Search-x64-directories-in-VS-built-prot.patch
Issue History
2014-03-24 20:30David HaitNew Issue
2014-03-26 08:47Brad KingNote Added: 0035519
2015-04-20 18:54Joël LamotteNote Added: 0038567
2015-04-21 08:34Brad KingNote Added: 0038568
2015-04-21 08:40Joël LamotteNote Added: 0038569
2015-04-21 09:00Brad KingNote Added: 0038570
2015-07-07 20:27Joël LamotteFile Added: patch-cmake-protobuf-64.diff
2015-07-07 20:29Joël LamotteNote Added: 0039030
2015-07-07 20:31Joël LamotteNote Added: 0039031
2015-07-08 10:25Brad KingFile Added: 0001-FindProtobuf-Search-x64-directories-in-VS-built-prot.patch
2015-07-08 10:32Brad KingNote Added: 0039088
2015-07-08 10:38Brad KingNote Added: 0039089
2015-07-08 10:45Joël LamotteNote Added: 0039090
2015-07-09 14:41Joël LamotteNote Added: 0039113
2015-08-10 18:44Joël LamotteNote Added: 0039264
2015-08-11 09:00Brad KingNote Added: 0039265
2015-08-11 09:00Brad KingStatusnew => resolved
2015-08-11 09:00Brad KingResolutionopen => fixed
2015-08-11 09:00Brad KingFixed in Version => CMake 3.4
2015-08-11 09:00Brad KingTarget Version => CMake 3.4
2015-08-11 09:00Brad KingAssigned To => Brad King
2015-08-11 09:00Brad KingStatusresolved => assigned
2015-08-11 09:01Brad KingStatusassigned => resolved
2016-01-04 11:52Robert MaynardNote Added: 0040110
2016-01-04 11:52Robert MaynardStatusresolved => closed

Notes
(0035519)
Brad King   
2014-03-26 08:47   
The FindProtobuf module should be taught to check CMAKE_SIZEOF_VOID_P to see whether it needs to check the x64 directory.

Meanwhile you can work around this by setting the PROTOBUF_LIBRARY and PROTOBUF_LIBRARY_DEBUG cache entries in your local build tree by hand.
(0038567)
Joël Lamotte   
2015-04-20 18:54   
Are there plans to fix this soon?
(0038568)
Brad King   
2015-04-21 08:34   
Currently FindProtobuf has no maintainer:

 http://www.cmake.org/Wiki/CMake:Module_Maintainers [^]

so no one is actively working on this.
(0038569)
Joël Lamotte   
2015-04-21 08:40   
Ok I will try a pull request soon then. Will it be reviewed by someone from the CMake team?
(0038570)
Brad King   
2015-04-21 09:00   
Re 0014833:0038569: Great, thanks! Please read CONTRIBUTING.rst and mention this issue number in the patch.
(0039030)
Joël Lamotte   
2015-07-07 20:29   
It took some time but I managed to find the time to provide a patch.

As said in the commit, it's tested with the last stable Protobuf release which is 1.6.1.
I didn't try Protobuf 3.0.0 (which is in alpha) that provide cmake files for building at least on windows. I suspect that FindProtobuf.cmake will need an update for that too.
(0039031)
Joël Lamotte   
2015-07-07 20:31   
"There should be an additional CMake variable to specify the library folder."

I am not totally sure about this part but would a PROTOBUF_LIBRARIES_DIR option set to PROTOBUF_OUTPUT_BINARIES_DIR (from my patch) by default would seem to be good enough?
(0039088)
Brad King   
2015-07-08 10:32   
Re 0014833:0039030: Thanks. Based on that I produced "0001-FindProtobuf-Search-x64-directories-in-VS-built-prot.patch". Please try it.
(0039089)
Brad King   
2015-07-08 10:38   
> There should be an additional CMake variable to specify the library folder.

Almost no find modules do this. CMake find_* commands honor variables like CMAKE_LIBRARY_PATH that can be used for this. Or, one can always set the individual find_* cache entries directly.

If Protobuf upstream now builds with CMake they should distribute packaging files as documented here:

 http://www.cmake.org/cmake/help/v3.3/manual/cmake-packages.7.html [^]

and then there will be no need for a find module.
(0039090)
Joël Lamotte   
2015-07-08 10:45   
By the way, I tried to generate (using cmake (3.3)) and build Protobuf (master) with vs2013 64bit and it compiled and linked without any problem, but as I expected the output paths are not at all located in usual places.
So I will make sure that the protobuf team are aware of your recommendation.

I will be able to do so and to try your patch in a few hours.
(0039113)
Joël Lamotte   
2015-07-09 14:41   
See: https://github.com/google/protobuf/issues/578 [^]

I just tried your patch and it seems to work too.

BTW I'm curious: could you explain to me the reasoning behind the changes you made from the patch I provided? Is it mostly just a more conventional way to do it for the cmake team? I'm asking mostly because it looks like only stylistic changes but there might be an impact on maintenance too, but not sure which way is best.
(0039264)
Joël Lamotte   
2015-08-10 18:44   
Hi, when will this fix be merged? It don't seem so "minor" to me as it prevent the usage of Protobuf in 64bit on Windows using CMake; and it seems like a simple fix. It's still marked "new" but it seems to me it could be merged in 3.3.1?
(0039265)
Brad King   
2015-08-11 09:00   
Re 0014833:0039264: Sorry for the delay. For some reason I never received notification of your confirmation in 0014833:0039113. Yes, the changes to your patch are just for style preference.

I've applied the patch:

 FindProtobuf: Search x64 directories in VS-built protobuf source
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8dc6cbcb [^]

It will be in CMake 3.4.
(0040110)
Robert Maynard   
2016-01-04 11:52   
Closing resolved issues that have not been updated in more than 4 months.