2015-05-06 71 views
2

我正在運行Windows,並且我想將SDL開發文件安裝在一個位置,以便find_package(SDL)能夠正常工作。如何安裝SDL開發庫,以便CMake可以找到它

我應該將其中的一部分包含在PATH中嗎?

EDITS: 我創建的環境變量SDLDIR並將其設置到該目錄含LIB /和包括/

CMake的輸出:

cmake -G "Visual Studio 12 2013 Win64" .. 
-- The C compiler identification is MSVC 18.0.31101.0 
-- The CXX compiler identification is MSVC 18.0.31101.0 
-- Check for working C compiler using: Visual Studio 12 2013 Win64 
-- Check for working C compiler using: Visual Studio 12 2013 Win64 -- works 
-- Detecting C compiler ABI info 
-- Detecting C compiler ABI info - done 
-- Check for working CXX compiler using: Visual Studio 12 2013 Win64 
-- Check for working CXX compiler using: Visual Studio 12 2013 Win64 -- works 
-- Detecting CXX compiler ABI info 
-- Detecting CXX compiler ABI info - done 
-- Detecting CXX compile features 
-- Detecting CXX compile features - done 
-- Looking for include file pthread.h 
-- Looking for include file pthread.h - not found 
-- Found Threads: TRUE 
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.2/Modules/FindPackageHandleStandardArgs.cmake:138 (message): 
    Could NOT find SDL (missing: SDL_LIBRARY) (found version "2.0.3") 
Call Stack (most recent call first): 
    C:/Program Files (x86)/CMake/share/cmake-3.2/Modules/FindPackageHandleStandardArgs.cmake:374 (_FPHSA_FAILURE_MESSAGE) 
    C:/Program Files (x86)/CMake/share/cmake-3.2/Modules/FindSDL.cmake:199 (FIND_PACKAGE_HANDLE_STANDARD_ARGS) 
    CMakeLists.txt:4 (find_package) 


-- Configuring incomplete, errors occurred! 
See also "E:/Code/Projects/OpenGL-SDL/build/CMakeFiles/CMakeOutput.log". 
See also "E:/Code/Projects/OpenGL-SDL/build/CMakeFiles/CMakeError.log". 

的CMakeLists.txt:

project(OpenGL-Sample-SDL) 
cmake_minimum_required(VERSION 2.8) 

find_package(SDL REQUIRED) 


include_directories(${SDL_INCLUDE_DIR}) 
link_libraries(PRIVATE ${SDL_LIBRARY}) 

add_executable(OpenGL-SDL main.cpp) 
+0

我將SDLDIR設置爲包含include和lib的目錄。 Cmake找到include目錄,但找不到lib目錄。 –

+1

'find_package'是否給出錯誤?如果發佈錯誤。如果不是,請檢查以下打印語句的輸出:'message(STATUS「SDL_LIBS = $ {SDL_LIBS}」)' – Antonio

+0

它找到SDL 2.0.3,但由於某種原因無法定義SDL_LIBRARY。 –

回答

1

我讀了wiki頁面了一下,發現有輕微的解決方法。我不認爲這是完美的,但現在沒問題。

cmake -G "Visual Studio 12 2013 Win64" -D SDL_LIBRARY_TEMP=%SDLDIR%\lib\x64\SDL2.lib .. 

這正確地找到SDL2,雖然我遇到了另一個問題,但我會爲它做一個新的話題。

0

檢查應該找到您的包裝的CMace模塊的文檔和來源

FindSDL.cmake包含以下文檔註釋:

# $SDLDIR is an environment variable that would correspond to the 
# ./configure --prefix=$SDLDIR used in building SDL. l.e.galup 9-20-02 
+0

不幸的是,我做了不是自己構建SDL,我從他們的網站下載了開發包。 –

相關問題