[vtkusers] Compiling VTK with MinGW, fixes to CMake rules
Kalle Pahajoki
kalpaha at st.jyu.fi
Wed Sep 14 03:22:21 EDT 2005
Hi
I've been compiling VTK with MinGW for a while now and I've had two
problems with the CMake generated makefiles:
1) they name the generated libraries libvtk<something>.dll when they
should be vtk<something>.dll
2) the flag -lgcc should not be there
So far I've worked around this by fixing the makefiles after they've
been generated (with a shell script) but that's slow and complex.
So I took some time to figure out if I could get proper makefiles
generated instead of fixing them afterwards.
Here are my preliminary results, which seem to work fine.
I edited the C:\Program files\Cmake20\Modules\Platform\Windows-gcc.cmake
and added the following block of code (which is adapted from the
Cygwin.cmake):
IF(CMAKE_COMPILER_IS_MINGW)
SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared
-Wl,--export-all-symbols -Wl,--enable-auto-import")
SET(CMAKE_DL_LIBS "-lgdi32" )
SET(CMAKE_SHARED_LIBRARY_PREFIX "")
SET(CMAKE_SHARED_LIBRARY_SUFFIX ".dll")
# no pic for gcc on cygwin
SET(CMAKE_SHARED_LIBRARY_C_FLAGS "")
SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "")
ENDIF(CMAKE_COMPILER_IS_MINGW)
The C:\program files\cmake20\modules\CMakeDefaultMakeRuleVariables.cmake
has the following lines:
IF(CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_CXX_CREATE_SHARED_LIBRARY
"${CMAKE_CXX_CREATE_SHARED_LIBRARY} -lgcc")
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
I modified them to read:
IF(CMAKE_COMPILER_IS_GNUCXX)
IF(NOT CMAKE_COMPILER_IS_MINGW)
SET(CMAKE_CXX_CREATE_SHARED_LIBRARY
"${CMAKE_CXX_CREATE_SHARED_LIBRARY} -lgcc")
ENDIF(NOT CMAKE_COMPILER_IS_MINGW)
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
With these changes, the generated Makefiles seem to work correctly. I
feel a bit stupid for wasting so much time repairing bad makefiles when
it took less than an hour to figure this out.
Hopefully someone finds this useful.
Kalle
--
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition not smart enough to debug it. -- Brian W. Kerninghan
More information about the vtkusers
mailing list