Page 1 of 1

[2.1] Empty Project SDL_DIR

Posted: Sun Apr 07, 2019 10:40 am
by Catchmar
Ogre Version: 2.1
Operating System: Windows 10
Render System: :?:
Visual Studio Version: 2017

Hi everyone,

I have built Ogre3D 2.1 according to this tuturial: https://ogrecave.github.io/ogre/api/2.1 ... ndows.html
The engine is inside of the C:/OgreTest/Ogre folder, while the build is in C:/OgreTest/Ogre/build.
I can run the solution and the provided samples work fine.

To create my own project, I have copied the EmptyProject folder from Samples to C:\EmptyProject.
In CMake, I've set OGRE_BINARIES to C:/OgreTest/Ogre/build and OGRE_SOURCE to C:/OgreTest/Ogre.
The project configures, but CMake cannot find the SDL directory:

Code: Select all

Detected DLL build of Ogre
CMake Warning at CMake/Dependencies/OGRE.cmake:227 (find_package):
  By not providing "FindSDL2.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "SDL2", but
  CMake did not find one.

  Could not find a package configuration file provided by "SDL2" with any of
  the following names:

    SDL2Config.cmake
    sdl2-config.cmake

  Add the installation prefix of "SDL2" to CMAKE_PREFIX_PATH or set
  "SDL2_DIR" to a directory containing one of the above files.  If "SDL2"
  provides a separate development package or SDK, be sure it has been installed
.
Call Stack (most recent call first):
  CMakeLists.txt:21 (setupOgre)


Could not find SDL2. https://www.libsdl.org/
Copying Hlms data files from Ogre repository
Copying Common data files from Ogre repository
Copying DLLs and generating Plugins.cfg for Debug
Copying DLLs and generating Plugins.cfg for Release
Copying DLLs and generating Plugins.cfg for RelWithDebInfo
Copying DLLs and generating Plugins.cfg for MinSizeRel
Generating C:/EmptyProject/bin/Data/resources2.cfg from template
		C:/EmptyProject/CMake/Templates/Resources.cfg.in
Copying OgreSamplesCommon cpp and header files to
		C:/EmptyProject/include/OgreCommon
		C:/EmptyProject/src/OgreCommon/
Configuring done
The part of OGRE.cmake that fails is:

Code: Select all

if( NOT IOS )
	set( CMAKE_PREFIX_PATH "${OGRE_SOURCE}/Dependencies ${CMAKE_PREFIX_PATH}" )
	find_package( SDL2 )
	if( NOT SDL2_FOUND )
		message( "Could not find SDL2. https://www.libsdl.org/" )
	else()
		message( STATUS "Found SDL2" )
		include_directories( ${SDL2_INCLUDE_DIR} )
		set( OGRE_DEPENDENCY_LIBS ${OGRE_DEPENDENCY_LIBS} ${SDL2_LIBRARY} )
	endif()
endif()
I have tried setting the SDL_DIR variable to:
  • C:\OgreTest\Ogre\Dependencies
  • C:\OgreTest\Ogre\Dependencies\build
  • C:\OgreTest\Ogre\Dependencies\build\ogredeps
  • C:\SDL-2.0.9 (where I have the SDL's VS development libraries)
But the error persists and SDL_DIR always resets to SDL2_DIR-NOTFOUND.

The generated solution complains about the SDL include not being found, and when I add them with the lib directory inside of VS2017, I get unresolved externals in GraphicsSystem.obj and SdlInputHandler.obj

I would greatly appreciate any help.

Re: [2.1] Empty Project SDL_DIR

Posted: Wed Apr 10, 2019 7:01 pm
by Catchmar
I have changed the SDL2_DIR CMake variable to C:/OgreTest/Ogre/Dependencies/src/SDL2, which removed the "SDL2 not found" error.
CMake states that it "Found SDL", however after generating it, the build fails with the same "Cannot open included file: 'SDL2'. No such file or directory" error.

Image
Image

Re: [2.1] Empty Project SDL_DIR

Posted: Sun Apr 21, 2019 12:27 pm
by Catchmar
Almost there :P

I've built the engine again (using this tutorial: https://ogrecave.github.io/ogre/api/2.1 ... ndows.html).
Everything is working as I've checked all the samples with both OpenGL and DirectX.
When creating an empty project, this time I've simply moved the repository to /Dependencies/Ogre in the project's directory, rather than symlinking/copying it there.
CMake couldn't find a few files, so I've set them as:
  • SDL2MAIN_LIBRARY = C:/OgreEmptyProject/Dependencies/Ogre/Dependencies/build/ogredeps/lib/SDL2main.lib
  • SDL2_BINARY_DBG = C:/OgreEmptyProject/Dependencies/Ogre/Dependencies/build/ogredeps/bin/Debug/SDL2.dll
  • SDL2_BINARY_REL = C:/OgreEmptyProject/Dependencies/Ogre/Dependencies/build/ogredeps/bin/Release/SDL2.dll
  • SDL2_INCLUDE_DIR = C:\OgreEmptyProject\Dependencies\Ogre\Dependencies\build\ogredeps\include\SDL2
When I build the project (both Debug and Release), the resulting exe files work great, but running the project from Visual Studio (F5 or CTRL+F5), I don't have any rendering systems to select from! This isn't the case with Ogre.sln or the exe files located under C:\OgreEmptyProject\bin\Debug and C:\OgreEmptyProject\bin\Release.

Re: [2.1] Empty Project SDL_DIR

Posted: Sun Apr 21, 2019 3:39 pm
by dark_sylinc
Catchmar wrote:
Sun Apr 21, 2019 12:27 pm
When I build the project (both Debug and Release), the resulting exe files work great, but running the project from Visual Studio (F5 or CTRL+F5), I don't have any rendering systems to select from! This isn't the case with Ogre.sln or the exe files located under C:\OgreEmptyProject\bin\Debug and C:\OgreEmptyProject\bin\Release.
Change the working folder in Visual Studio via the Project Settings (Alt+F7->Configuration Properties->Debugging->Working Directory)

Re: [2.1] Empty Project SDL_DIR

Posted: Sun Apr 21, 2019 10:54 pm
by Catchmar
Thanks! That works great :D