[CMake] Building a Windows project in both 32- and 64-bit mode using the nmake generator.
We're trying to convert a project from using a very old hand-built makefile (the original version was written over 20 years ago!) to using cmake. We want to do the builds using command line nmake, not using Visual Studio project files. With our existing setup, to switch between 32- and 64- bit builds, we only need to change the option specified on the vcvarsall batch file and do a clean build. The tools figure out from the environment variables which build we're doing any everything works great. We've started our conversion by converting one of our smaller library files. All of the source files appear to compile correctly, but when we get to the link, we're getting the following error: Linking CXX shared library CMakeFiles\bin\rexxapi.dll msvcprtd.lib(MSVCP120D.dll) : fatal error LNK1112: module machine type 'x64' con flicts with target machine type 'X86' LINK Pass 1 failed. with 1112 NMAKE : fatal error U1077: '"C:\Program Files (x86)\CMake 2.8\bin\cmake.exe"' : return code '0x' Stop. NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0 \VC\BIN\amd64\nmake.exe"' : return code '0x2' Stop. NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0 \VC\BIN\amd64\nmake.exe"' : return code '0x2' Stop. looking at the generated build.make file, I see that the option /machine:X86 appears on the link command. I tried manually deleting that option, but the error persisted. What do I need to do for cmake to generate the correct 64-bit logic...and equally as important, how do we switch between doing 32-bit and 64-bit builds when needed? And let me repeat, we do not want to use the Visual Studio generators...we want the nmake version. Rick -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Building a Windows project in both 32- and 64-bit mode using the nmake generator.
On 01.05.2014 15:04, Rick McGuire wrote: With our existing setup, to switch between 32- and 64- bit builds, we only need to change the option specified on the vcvarsall batch file and do a clean build. The tools figure out from the environment variables which build we're doing any everything works great. Does the "clean build" involve removing the build directory or at least removing CMakeCache.txt/CMakeFiles? Otherwise CMake will keep using the cached compiler information from the initial configuration rather than querying the build environment again. Nils -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Building a Windows project in both 32- and 64-bit mode using the nmake generator.
"clean build" referred to our existing system, not the cmake conversion. For our current system, it is only necssary to nuke the build output directory. Figuring out the mechanics of doing a switching mode under cmake is something we'll deal with once we're able to get the different kinds of build working. Rick On Thu, May 1, 2014 at 9:09 AM, Nils Gladitz wrote: > On 01.05.2014 15:04, Rick McGuire wrote: > >> >> With our existing setup, to switch between 32- and 64- bit builds, we >> only need to change the option specified on the vcvarsall batch file and do >> a clean build. The tools figure out from the environment variables which >> build we're doing any everything works great. >> >> > Does the "clean build" involve removing the build directory or at least > removing CMakeCache.txt/CMakeFiles? > Otherwise CMake will keep using the cached compiler information from the > initial configuration rather than querying the build environment again. > > Nils > -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Building a Windows project in both 32- and 64-bit mode using the nmake generator.
On 01.05.2014 15:13, Rick McGuire wrote: "clean build" referred to our existing system, not the cmake conversion. For our current system, it is only necssary to nuke the build output directory. Figuring out the mechanics of doing a switching mode under cmake is something we'll deal with once we're able to get the different kinds of build working. So this was with a fresh (empty; specifically no CMakeCache.txt/CMakeFiles) build directory? The machine type is determined (and cached) the first time cmake runs for a build directory. It is determined by querying the compiler from within the environment in which it runs. If this was with a clean build directory is it possible the project sets up custom compiler flags that would override the existing flags? If that isn't the case either could you provide a minimal, self-contained test case that reproduces the issue? Nils -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Building a Windows project in both 32- and 64-bit mode using the nmake generator.
On 01.05.2014 15:54, Rick McGuire wrote: Is it possible to get cmake to check the actual compile/link commands when they are issued? I'd love to compare the cmake versions to our existing build to see if things are ending up the same. To a degree (response files on window limit the output in some cases); see below. Creating a minimal self-contained test case would not be easy. This is an open source project though, if you're willing to try checking it out. The svn url is svn http://svn.code.sf.net/p/oorexx/code-0/main/trunk I was able to build the project with these steps: - Open the "VS2013 x64 Cross Tools Command Prompt" - Add target_link_libraries(rexxapi ws2_32) to the end of CMakeLists.txt - Create a "build" directory in the source directory - Run "cmake -G NMake Makefiles .." from the build directory - Run nmake VERBOSE=1 The command for the link this generates on my system is: C:\PROGRA~2\MICROS~2.0\VC\bin\X86_AM~1\link.exe /nologo @CMakeFiles\rexxapi.dir\objects1.rsp /out:..\CMakeFiles\bin\rexxapi.dll /implib:..\CMakeFiles\bin\rexxapi.lib /pdb:C:\Users\ngladitz\src\main\CMakeFiles\bin\rexxapi.pdb /dll /version:0.0 /machine:x64 /debug /INCREMENTAL ws2_32.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:..\CMakeFiles\bin\rexxapi.dll.intermediate.manifest ..\CMakeFiles\bin\rexxapi.dll.embed.manifest.res The link is successful. Some of the project's setup looks unorthodox. Specifically: - outputting binaries in the sources directory rather than the build directory (this might break parallel build directories or being able to purge build directories since they would not contain all artifacts) - using a directory called CMakeFiles for the output (which in in source-tree builds would belong to cmake and should not be used by the project) - The two platform dependent add_library() calls could be merged into a single call that uses a list variable for the platform specific sources. The redundant listing looks error prone. Nils -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Building a Windows project in both 32- and 64-bit mode using the nmake generator.
On 01.05.2014 16:57, Rick McGuire wrote: I was able to build the project with these steps: - Open the "VS2013 x64 Cross Tools Command Prompt" This is not something I'm familiar with...where do I find this? Also, if this is something only available if you have the full Visual Studio installed, that is a problem. We really need to have this project buildable using the free download version of the compiler. It is a shortcut to vcvarsall.bat (with x86_amd64 as a parameter) in the windows start menu as installed (on my system) by the "VS Express 2013 for Desktop" (free edition). - Add target_link_libraries(rexxapi ws2_32) to the end of CMakeLists.txt what does the ws2_32 do? ws2_32 is the windows' winsock2 library. Without it I got unresolved symbols to winsock calls made by the project. The existing comment in CMakeLists.txt about missing windows libraries implies that this is a known issue. - Create a "build" directory in the source directory to you mean at the trunk root, or some other location? Do I need to copy the CMakeLists.txt or any other files there? I created an empty directory called "build" inside the directory called "main". I did not copy any files there. CMake will fill the directory when invoked from within. Nils -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake