[CMake] How to create a 64-bit Windows build of cmake? Added for building vtk-5.0.0

John R. Cary cary at txcorp.com
Thu Aug 4 11:58:54 EDT 2011


To close out this thread, I think I can now explain what was
happening.

I was indeed getting a win64-release version of cmake, by
configuring in a Visual Studio Win64 command window with

cmake \
   -G 'NMake Makefiles'
   -DCMAKE_INSTALL_PREFIX:PATH=C:/winsame/contrib-vs9/cmake-2.8.5-ser \
   -DCMAKE_BUILD_TYPE:STRING=RELEASE \
   -DCMAKE_C_COMPILER:FILEPATH='cl' \
   -DCMAKE_CXX_COMPILER:FILEPATH='cl'
<path to source>

then doing "nmake; nmake package" and using that package
to install cmake.  This only problem was that the default
location came out as /Program Files/... instead of /Program
Files (x86)/..., but this was modified at installation time.

But then in configuring VTK, CMake was constructing the
libraries, such as cmVTK_WRAP_TCL2.dll, as Debug.  The problem
was that the flag, -DCMAKE_BUILD_TYPE:STRING=RELEASE,
was not getting used by the TRY_COMPILE in
CMake/vtkCompileCMakeExtensions.cmake to configure
CMake/CMakeLists.txt.

CMake/vtkCompileCMakeExtensions.cmake, which is used by the
configuration of CMake/CMakeLists.txt.  So now I send this
explicitly as shown in the patch below.  All now configures
and builds.

So should CMake pass the flag, CMAKE_BUILD_TYPE, automatically
to try_compile?  Or should the module do that?  (It would seem
that CMake would have to send its build type to the module if
it were to load it, but it would have to respect the build type
if a built application were to load it.)  Because I my
uncertainty, do not know whether to report this as a bug.

Thx......John Cary

cat vtk-5.0.0i.patch
diff -ruN vtk-5.0.0i/CMake/vtkCompileCMakeExtensions.cmake 
vtk-5.0.0i-new/CMake/vtkCompileCMakeExtensions.cmake
--- vtk-5.0.0i/CMake/vtkCompileCMakeExtensions.cmake    2011-03-25 
18:03:24.000000000 -0600
+++ vtk-5.0.0i-new/CMake/vtkCompileCMakeExtensions.cmake        
2011-08-04 07:18:16.000000000 -0600
@@ -19,9 +19,13 @@
      IF(COMMAND VTK_WRAP_TCL2)
      ELSE(COMMAND VTK_WRAP_TCL2)
        MESSAGE(STATUS "Compiling VTK CMake commands")
+      set(TRY_COMPILE_OTHER_FLAGS)
+      if (CMAKE_BUILD_TYPE)
+        set(TRY_COMPILE_OTHER_FLAGS ${TRY_COMPILE_OTHER_FLAGS} 
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE})
+      endif ()
        TRY_COMPILE("${result_var}" "${build_dir}" "${source_dir}"
          VTK_LOADED_COMMANDS
-        CMAKE_FLAGS -DVTK_BUILD_FROM_TRY_COMPILE:BOOL=TRUE
+        CMAKE_FLAGS -DVTK_BUILD_FROM_TRY_COMPILE:BOOL=TRUE 
${TRY_COMPILE_OTHER_FLAGS}
          OUTPUT_VARIABLE VTK_COMPILE_CMAKE_EXTENSIONS_OUTPUT)
        IF("${result_var}")
          MESSAGE(STATUS "Compiling VTK CMake commands - done")
diff -ruN vtk-5.0.0i/Common/vtkPythonUtil.cxx 
vtk-5.0.0i-new/Common/vtkPythonUtil.cxx
--- vtk-5.0.0i/Common/vtkPythonUtil.cxx 2011-03-25 18:03:25.000000000 -0600
+++ vtk-5.0.0i-new/Common/vtkPythonUtil.cxx     2011-08-04 
07:13:41.000000000 -0600
@@ -27,6 +27,7 @@

  #include <vtkstd/map>
  #include <vtkstd/string>
+#include <cstddef>

  #if defined ( _MSC_VER )
  #  define vtkConvertPtrToLong(x) ((long)(PtrToUlong(x)))



 > Date: Tue, 2 Aug 2011 09:42:07 -0400
 > From: David Cole <david.cole at kitware.com>
 > Subject: Re: [CMake] How to create a 64-bit Windows build of cmake?
 > To: "John R. Cary" <cary at txcorp.com>
 > Cc: cmake Mailing List <cmake at cmake.org>
 > Message-ID:
 > <CAAdwe9Wsd7btGPv7S6pZba0FEYSUMq1HrV-ua1xTHJ9sdPOOoQ at mail.gmail.com>
 > Content-Type: text/plain; charset=ISO-8859-1
 >
 > Try commenting out the one line that causes problems, then back up
 > from there, either commenting chunks out or adjusting CMake options
 > until those commands are not loaded.
 >
 >
 > On Tue, Aug 2, 2011 at 8:50 AM, John R. Cary <cary at txcorp.com> wrote:
 >> Thanks for your response. ?This will definitely decrease my headpain.
 >>
 >> It turns out that I need vtk-5.0.0, but right now I am not sure
 >> that I need the wrapping code. ?Am checking on this.
 >>
 >> Would it make sense to just not call vtkLoadCMakeExtensions.cmake?
 >>
 >> Thx....John Cary
 >>
 >> On 8/2/11 5:00 AM, David Cole wrote:
 >>>
 >>> On Tue, Aug 2, 2011 at 7:00 AM, David Cole<david.cole at kitware.com> 
?wrote:
 >>>>
 >>>> On Mon, Aug 1, 2011 at 8:34 PM, John R. Cary<cary at txcorp.com> ?wrote:
 >>>>>
 >>>>> I believe I have followed what I have found on the web for
 >>>>> building a Win64 version of CMake. ?I have downloaded the
 >>>>> win32 version and used it to configure the cmake source.
 >>>>> I used the Visual Studio 9 2008 Win64 generator.
 >>>>>
 >>>>> However, when I then use that cmake to configure vtk (an
 >>>>> old version, 5.0.0) I get the much discussed error,
 >>>>>
 >>>>> -- Loading VTK CMake commands
 >>>>> CMake Error at CMake/vtkLoadCMakeExtensions.cmake:7 (LOAD_COMMAND):
 >>>>> ?load_command Attempt to load the library
 >>>>>
 >>>>> 
?C:/winsame/cary/builds-vs9/composerall/vtk-5.0.0i/ser/CMake/cmVTK_WRAP_TCL2.dll
 >>>>> ?failed. ?Additional error info is:
 >>>>>
 >>>>> ?The application has failed to start because its side-by-side
 >>>>> configuration
 >>>>> ?is incorrect. ?Please see the application event log or use the
 >>>>> command-line
 >>>>> ?sxstrace.exe tool for more detail.
 >>>>>
 >>>>> Call Stack (most recent call first):
 >>>>> ?CMake/vtkLoadCMakeExtensions.cmake:27 
(VTK_LOAD_SINGLE_CMAKE_EXTENSION)
 >>>>> ?CMakeLists.txt:632 (VTK_LOAD_CMAKE_EXTENSIONS)
 >>>>>
 >>>>>
 >>>>> CMake Error at CMake/vtkLoadCMakeExtensions.cmake:11 (MESSAGE):
 >>>>> ?Loading VTK command VTK_WRAP_TCL2 - failed
 >>>>> Call Stack (most recent call first):
 >>>>> ?CMake/vtkLoadCMakeExtensions.cmake:27 
(VTK_LOAD_SINGLE_CMAKE_EXTENSION)
 >>>>> ?CMakeLists.txt:632 (VTK_LOAD_CMAKE_EXTENSIONS)
 >>>>>
 >>>>> Using sxstrace shows
 >>>>>
 >>>>> INFO: Parsing Manifest File
 >>>>>
 >>>>> 
C:\winsame\cary\builds-vs9\composerall\vtk-5.0.0i\ser\CMake\cmVTK_WRAP_TCL2.dll.
 >>>>> ? ?INFO: Manifest Definition Identity is (null).
 >>>>> ? ?INFO: Reference:
 >>>>>
 >>>>> 
Microsoft.VC90.DebugCRT,processorArchitecture="amd64",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8"
 >>>>> INFO: Resolving reference
 >>>>>
 >>>>> 
Microsoft.VC90.DebugCRT,processorArchitecture="amd64",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8".
 >>>>> ? ?INFO: Resolving reference for ProcessorArchitecture amd64.
 >>>>>
 >>>>> which seems to indicate that even though I built cmake with the
 >>>>> VS9-Win64
 >>>>> generator, cmake somehow created the dll as win32? ?Even though cmake
 >>>>> says,
 >>>>>
 >>>>> -- Check for working C compiler: C:/Program Files (x86)/Microsoft 
Visual
 >>>>> Studio
 >>>>> 9.0/VC/bin/amd64/cl.exe
 >>>>>
 >>>>>
 >>>>> showing that it found the 64-bit compiler?
 >>>>>
 >>>>> Any hints on what to do next?

 >>>>>
 >>>> This is a problem with VTK 5.0, not a problem with CMake...
 >>>>
 >>>> Since VTK 5.0, the "loaded custom CMake commands" have been eliminated
 >>>> from VTK for just this reason. Can you use VTK 5.2, 5.4 or 6.5
 >>>> instead...? (I'm not 100% sure exactly when that problem was fixed,
 >>>> but a more recent VTK should fix this issue.)
 >>>>
 >>> make that "5.2, 5.4 or **5.6**"...

-- 
Tech-X Corp., 5621 Arapahoe Ave, Suite A, Boulder CO 80303
cary at txcorp.com, p 303-448-0727, f 303-448-7756


More information about the CMake mailing list