3
votes

I'm running Windows and I want to install the SDL development files in a place so that find_package(SDL) works.

Should I include part of it in the PATH or what?

EDITS: I created the environment variable SDLDIR and set it to the directory containing lib/ and include/

Cmake output:

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)
2
I set SDLDIR to the directory containing include and lib. Cmake finds the include directory but not the lib directory. - Brady Dean
Is find_package giving any error? In case, post the error. If not, check the output of the following print statement: message(STATUS "SDL_LIBS=${SDL_LIBS}") - Antonio
It finds SDL 2.0.3 but cannot define SDL_LIBRARY for some reason. - Brady Dean
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.2/Modules/FindPackageH andleStandardArgs.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/FindPackageHandleStandard Args.cmake:374 (_FPHSA_FAILURE_MESSAGE) C:/Program Files (x86)/CMake/share/cmake-3.2/Modules/FindSDL.cmake:199 (FIND_P ACKAGE_HANDLE_STANDARD_ARGS) CMakeLists.txt:4 (find_package) I think Cmake quits before the message() because SDL cannot be found - Brady Dean

2 Answers

1
votes

I read a bit on the wiki page and found a slight workaround. I don't think it's perfect but it's fine for now.

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

This correctly find SDL2 although I am running into another issue, but I will make a new topic for it.

0
votes

Check the documentation and source of the CMace module that is supposed to find your package

FindSDL.cmake contains the following documentation comment:

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