[cmake-developers] [CMake 0013769]: FindSDL.cmake libraries in wrong order
Mantis Bug Tracker
mantis at public.kitware.com
Sun Dec 2 03:53:53 EST 2012
The following issue has been SUBMITTED.
======================================================================
http://public.kitware.com/Bug/view.php?id=13769
======================================================================
Reported By: R Cullen
Assigned To:
======================================================================
Project: CMake
Issue ID: 13769
Category: Modules
Reproducibility: always
Severity: major
Priority: normal
Status: new
======================================================================
Date Submitted: 2012-12-02 03:53 EST
Last Modified: 2012-12-02 03:53 EST
======================================================================
Summary: FindSDL.cmake libraries in wrong order
Description:
The FindSDL.cmake file does not order the SDL libraries correctly. "-lSDLmain"
must be added to the g++ arguments before "-lSDL", not doing this results in
linking errors like those below :
c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/lib\libSDLmain.a(SDL_win32_main.o):
In function `redirect_output':
/Users/slouken/release/SDL/SDL-1.2.15/./src/main/win32/SDL_win32_main.c:219:
undefined reference to `SDL_strlcpy'
/Users/slouken/release/SDL/SDL-1.2.15/./src/main/win32/SDL_win32_main.c:220:
undefined reference to `SDL_strlcat'
...
Steps to Reproduce:
Install MinGW
Compile SDL using MinGW
Compile attached program using :
cmake -Wdev -DSDL_BUILDING_LIBRARY=FALSE -G"MSYS Makefiles" .. && make VERBOSE=1
Additional Information:
Here are the sources if you dont trust the .zip
test.cpp
#include "SDL.h"
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240
#define SCREEN_DEPTH 8
int main(int argc, char *argv[]) {
SDL_Surface *screen;
Uint8 *p;
int x = 10;
int y = 20;
SDL_Init(SDL_INIT_VIDEO);
screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_DEPTH,
SDL_SWSURFACE);
p = (Uint8 *)screen->pixels + y * screen->pitch + x *
screen->format->BytesPerPixel;
*p=0xf0;
SDL_Flip(screen);
while(1);
}
CMakeLists.txt
cmake_minimum_required(VERSION 2.6)
project(MyProject)
set(EXECUTABLE_NAME "sdl_bug")
#SET THIS TO YOUR MING INSTALATION
if( WIN32 )
set(CMAKE_PREFIX_PATH "c:/MinGW/")
endif()
add_executable(${EXECUTABLE_NAME} test.cpp)
find_package(SDL REQUIRED)
if(SDL_FOUND)
include_directories(${SDL_INCLUDE_DIR})
target_link_libraries(${EXECUTABLE_NAME} ${SDL_LIBRARY})
endif()
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2012-12-02 03:53 R Cullen New Issue
2012-12-02 03:53 R Cullen File Added: sources.zip
======================================================================
More information about the cmake-developers
mailing list