[CMake] Re: FindSDL.cmake and mingw / msys

Werner Smekal smekal at iap.tuwien.ac.at
Tue Mar 13 15:38:47 EST 2007


Hi Pierre,

okay, I looked at FindSDL.cmake more carefully. First I think you should 
make sure that SDL is actually found. You should have something like 
this in you cmakeLists.txt:

find_package(SDL)
if( NOT SDL_FOUND )
    message( "Warning: SDL not found" )
endif( NOT SDL_FOUND )

or since you need it anyway for your package:

find_package(SDL REQUIRED)

than cmake stops if SDL isn't found (actually not, since FindSDL.cmake 
misses this feature :).

Anyway, from what I see, you set the path SDLMAIN_LIBRARY, but libsdl.a 
is not found, since you don't tell it where to find it. it is much 
better to use environment variables here, e.g.

set CMAKE_LIBRARY_PATH=c:\sdl\lib
set CMAKE_INCLUDE_PATH=c:\sdl\include
cmake ..

or for msys

export CMAKE_LIBRARY_PATH=pathtosdl/lib
export CMAKE_INCLUDE_PATH=pathtosdl/include
cmake ..

Than if cmake looks for includes (any kind) it also searches in 
CMAKE_INCLUDE_PATH and if it looks for libraries (any kind) it searches 
in also CMAKE_LIBRARY_PATH. FindSDL.cmake should than find automatically 
the sdl headers and the libraries, I assume they are in the same 
directory. If not you could set it like that:

export CMAKE_LIBRARY_PATH=pathtosdl/lib/main:pathtosdl/lib/image

But still you need to change BOTH (!) "IF(MINGW)" clauses to "IF(MINGW 
AND MSYS)" if you want to use msys.

HTH,
Werner

PA Galmes wrote:
>  
> - launched CMake,
> - selected MINGW,
> - configured a few variables (QT_QMAKE_EXECUTABLE, 
> SDLIMAGE_INCLUDE_DIR, SDLIMAGE_LIBRARY, SDL_INCLUDE_DIR, SDLMAIN_LIBRARY).
> - generated the makefiles.
>  
> - click on start menu, and click on the launcher.
> - launched "cmd" (I suppose that this is what you called Windows CLI)
> - went to the directory
> - launched "mingw32-make.exe"
>  
> And the error is the same as before. The "build.make" is the same as 
> before (I copied the linking part at the end of this mail).
> Any idea?
>  
> I would like to check the value of the variables in the FindSDL.cmake 
> (like "MINGW"...) when I try to compile
> my program. Is this possible?
>  
> Can the problem be relevant to the fact that I am using the MINGW 
> version coming with Qt ?
>  
>  
>  
>
>         Another solution would be to
>         change the lines above to
>
>         IF(MINGW AND MSYS)
>         SET(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW")
>         ENDIF(MINGW AND MSYS)
>
>         and similar code in  FindSDL.cmake. This should work  than.
>
>      
>
>  
> Currently, I suppose that the first issue is not related to that, as 
> even with
> MINGW it does not work...
>  
> Any idea?
>  



More information about the CMake mailing list