2

I've been trying to use CMake with a project I'm doing in SDL, but am running into some problems. My sdl folder for the libraries etc is located at C:\SDL\SDL-1.2.14. The error states:

Could NOT find SDL (missing:  SDL_LIBRARY SDL_INCLUDE_DIR)  Could NOT find SDLIMAGE (missing:  SDLIMAGE_LIBRARY SDLIMAGE_INCLUDE_DIR)  CMake Error at C:/Program Files (x86)/CMake
2.8/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:97 (MESSAGE):   Could NOT find SDL (missing: SDL_LIBRARY SDL_INCLUDE_DIR) Call Stack (most recent call first):   C:/Program Files (x86)/CMake
2.8/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:288 (_FPHSA_FAILURE_MESSAGE)   C:/Program Files (x86)/CMake
2.8/share/cmake-2.8/Modules/FindSDL.cmake:172 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)   CMakeLists.txt:10 (Find_Package)

Here is my CMakeLists.txt file.

Project(SDLExample)
Include(FindSDL)
Include(FindSDL_image)

set(
    SOURCES 
    example.cpp
)

Find_Package(SDL REQUIRED)
Find_Package(SDL_image REQUIRED)

if(NOT SDL_FOUND)
    message( FATAL ERROR "SDL not found!")
endif(NOT SDL_FOUND)

link_libraries(
    ${SDL_LIBRARY}
    ${SDLIMAGE_LIBRARY}
    SDLmain
)

add_executable(
    Example
    WIN32
    MACOSX_BUNDLE
    {$SOURCES}
)

Any ideas?

Edit: I got it to work now by editing fields for the SDL paths in the Windows GUI. The problem is of course I can't find a way to 'backport' this back into the cmake file, so I'd have to re-edit them each time, the generated VS10 file loaded into visual studio, but none of the include paths etc for SDL were correctly loaded into the project, so it won't compile saying it does not know where SDL.h is.

4

1 に答える 1

1

Find<Lib>ファイルを含める必要はありません。find_package( <Lib> )これらのファイルを自動的に見つけて使用します。

Windows を使用している場合は、 SDLDIR 環境変数を、SDL/lib/includeフォルダーが配置されているフォルダーに設定する必要があると思います。

于 2013-12-13T11:12:36.817 に答える