Hello, I've been playing for some days with cmake, and I have to say that I quite love the way it works. But while trying to compile a sourceforge project under Windows using MSYS, I run into a problem.
I do not know if the problem is related to the CMakeLists.txt that I did not wrote correctly or to an issue into the FindSDL.cmake. That's why I write here. What I did: - I wrote the CMakeLists.txt under Linux. There, everything compiled like a charm. I added the code of my CMakeLists.txt at the end of the mail - Under Windows, I then generated the make files for MSYS and tried to compile it using msys and mingw: $ make Scanning dependencies of target bloodybeard [ 25%] Building CXX object CMakeFiles/bloodybeard.dir/main.obj [ 50%] Building CXX object CMakeFiles/bloodybeard.dir/qGameEngine.obj [ 75%] Building CXX object CMakeFiles/bloodybeard.dir/moc_qGameEngine.obj Linking CXX executable bloodybeard.exe CMakeFiles/bloodybeard.dir/qGameEngine.obj(.text+0x1d7):qGameEngine.cpp: undefined reference to `SDL_Init' CMakeFiles/bloodybeard.dir/qGameEngine.obj(.text+0x1eb):qGameEngine.cpp: undefined reference to `SDL_WM_SetCaption' ... So, the SDL lib is not correctly linked under Windows/MSYS. I then checked the "build.make" file generated. It does not includes all the needed link flags needed for SDL under mingw ( -lmingw32 -lSDLmain -lSDL -lmwindows). Why aren't those flags added? It looks like the SDL_LIBRARY variable is empty, but why ? I would need some help to investigate further. - In the FindSDL.cmake, there is a specific part related to MINGW: # MinGW needs an additional library, mwindows # It's total link flags should look like -lmingw32 -lSDLmain -lSDL -lmwindows # (Actually on second look, I think it only needs one of the m* libraries.) IF(MINGW) SET(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW") ENDIF(MINGW) So, why doesn't this work ? Is there a specific MSYS flag to add? I have a few workarounds in order to compile my project, but would like to help. Regards, Pierre-André Galmes I - Links: The project is at the following adress: http://sourceforge.net/projects/bloodybeard You can access to the svn source if you want to. II - CMakeLists.txt : # The Qt flags # I do not need QtGui. SET(QT_DONT_USE_QTGUI True) # find and setup Qt4 for this project # SDL for this project find_package(Qt4 REQUIRED) find_package(SDL REQUIRED) find_package(SDL_image REQUIRED) include(${QT_USE_FILE}) INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${SDLIMAGE_INCLUDE_DIR}) LINK_LIBRARIES(${SDL_LIBRARY} ${SDLIMAGE_LIBRARY} ${SDLMAIN_LIBRARY}) # the variable "bloodybeard_SRCS" contains all .cpp files of this project set(bloodybeard_SRCS main.cpp qGameEngine.cpp ) SET(bloodybeard_MOC_HDRS qGameEngine.h ) # After this call, bloodybeard_MOC_SRCS = moc_Class1.cxx moc_Class2.cxx moc_Class3.cxx. QT4_WRAP_CPP(bloodybeard_MOC_SRCS ${bloodybeard_MOC_HDRS}) ADD_EXECUTABLE(bloodybeard ${bloodybeard_SRCS} ${bloodybeard_MOC_SRCS}) # tell cmake to create .moc files for all files in the variable bloodybeard_SRCS # that require such a file. # note: this assumes that you use #include "header.moc" in your files qt4_automoc(${bloodybeard_SRCS}) # create an executable file named "bloodybeard" from the source files in the # variable "bloodybeard_SRCS". add_executable(bloodybeard ${bloodybeard_SRCS}) # link the "bloodybeard" target against the Qt libraries. which libraries # exactly, is defined by the "include(${QT_USE_FILE})" line above, which sets # up this variable. target_link_libraries(bloodybeard ${QT_LIBRARIES}) -- Pierre-André Galmes Free Software consultant StarXpert - www.starxpert.fr 6, rue Eugène Varlin - 75010 Paris
_______________________________________________ CMake mailing list [email protected] http://www.cmake.org/mailman/listinfo/cmake
