Then in the CMakeLists.txt file, I have something similar to the following (very simplified):
# Ogre# blah blah# ...set configuration for Ogreadd_subdirectory(ogre)# This will create the targets defined from Ogre cmake files# set some variable so that other dependencies using Ogre can find it (injecting info for FindOgre)# OgreProcedural# blah blah OgreProcedural configurationadd_subdirectory(ogre_procedural)# set some variable so that other dependencies using OgreProcedural can find it
This works well, but FindOgre will look for .lib files whatever the setup, even if you only have source files. At first, it's ok because if there is no .lib file, the script will just make sure there is at least the rest of the library that is found.
However, if FindOgre does find .lib files, it wil try to link with it even if it's not for the right configuration. To clarify, here is how to reproduce the problem:
have the setup described before;
set the CMakeLists.txt so that OGRE_LIBRARIES always contain only "OgreMain" which is the OgreMain target name - it have to be defined BEFORE all add_subdirectory() calls to projects depent on OgreMain;
make sure OGRE_REL_LIBRARY and OGRE_DBG_LIBRARY are empty BEFORE all add_subdirectory() calls to projects depent on OgreMain;
run cmake: OgreProcedural will correctly "Find: OgreMain"
open the project file, compile OgreMain in ReleaseDebug;
run cmake: OgreProcedural will INCORRECTLY "Find: ../../blah/blah/ogre/lib/relwithdebinfo/OgreMain.lib"
at this point, if I try to compile OgreProcedural in Release or Debug, it will ALWAYS link with ogre/lib/relwithdebinfo/OgreMain.lib instead of the right lib file depending on the mode;
So basically, the problem is simply that FindOgre look for library files instead of just adding OgreMain (and other libraries) as a link dependency. If we remove the library files search in the case of Ogre being provided by sources to FindOgre, then the generated projects will always link with the OgreMain target instead of a specific .lib file set on Cmake setup.
I'm not sure if I'm totally clear here so feel free to ask questions.
The change should affect only usage from sources by forcing setting OGRE_LIBRARIES (to clarify which Ogre targets to use in Ogre-dependent projects like OgreProcedural) and skip (with a visible message) the .lib file search if OGRE_SOURCE is set.
I can't check right now if it have no effect on classic setup where binaries of Ogre are installed, but Ogre's team should be able to easily check that.