FindOGRE.cmake in v1-9

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
Post Reply
glennr
Greenskin
Posts: 126
Joined: Thu Jun 05, 2008 3:26 am
Location: Thames, New Zealand
x 9

FindOGRE.cmake in v1-9

Post by glennr »

In FindOGRE.cmake in 1-9 the piece of code that does the library finding is wrapped in this logic:

Code: Select all

if (NOT OGRE_SOURCE) # If using ogre sources, use the target names instead of library files to link.
	find_library(OGRE_LIBRARY_REL NAMES ${OGRE_LIBRARY_NAMES} HINTS ${OGRE_LIB_SEARCH_PATH} ${OGRE_PKGC_LIBRARY_DIRS} ${OGRE_FRAMEWORK_SEARCH_PATH} PATH_SUFFIXES "" "Release" "RelWithDebInfo" "MinSizeRel")
	find_library(OGRE_LIBRARY_DBG NAMES ${OGRE_LIBRARY_NAMES_DBG} HINTS ${OGRE_LIB_SEARCH_PATH} ${OGRE_PKGC_LIBRARY_DIRS} ${OGRE_FRAMEWORK_SEARCH_PATH} PATH_SUFFIXES "" "Debug")
else()
	if( NOT OGRE_LIBRARIES OR OGRE_LIBRARIES STREQUAL "" )
		message( FATAL_ERROR "When using Ogre from sources, please specify target names in OGRE_LIBRARIES!" )
	else()
		message( "Using Ogre source instead of binary libraries - skipping library files search." )
	endif()
endif()
What is the purpose of that? It seems either broken or incomplete.

What I would like to be able to do is have CMake find a copy of Ogre that I have built but not installed. This is what I thought that the variables OGRE_BUILD and OGRE_SOURCE are for, at least that worked in 1.8. OGRE_SOURCE so it can find the headers and OGRE_BUILD so it can find the built libraries. If I remove the if clause (and add macosx to the search path) then it is able to find them.
Last edited by glennr on Thu Feb 06, 2014 11:01 pm, edited 1 time in total.
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56
Contact:

Re: FindOGRE.cmake in v1-9

Post by Klaim »

I'm the one who added the if/then/else : https://bitbucket.org/sinbad/ogre/pull- ... aries/diff
The rational is explained there.

However, I'm not a CMake expert and I still find it problematic as soon as I try to work with dependencies. So maybe I misunderstood an idiomatic or just better way to avoid these problems (which seems to be the same problem than what you describe).
Maybe it's just incomplete as you said. My current understanding of the problem is limited to what I described in the pull request.
glennr
Greenskin
Posts: 126
Joined: Thu Jun 05, 2008 3:26 am
Location: Thames, New Zealand
x 9

Re: FindOGRE.cmake in v1-9

Post by glennr »

Ok, I sort of get it, but not fully. In any case I think your fix needs some amendment because it breaks the intended use of the OGRE_SOURCE variable. This comment in FindOGRE.cmake implies that this variable is used to find Ogre when it has been built from source, rather than an installed version.

Code: Select all

# If both OGRE_BUILD and OGRE_SOURCE are set, prepare to find Ogre in a build dir
Perhaps a better solution would be to add an additional variable to prevent the invocation of find_library instead of using OGRE_SOURCE ?
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56
Contact:

Re: FindOGRE.cmake in v1-9

Post by Klaim »

As long as it allows me to use Ogre sources directly as described in the comments of the PR, adding a variable for this case would be perfectly fine for me. I can't work on this though so if you could setup this and make a PR I could maybe find time to test it sometime this week or the coming week end.
glennr
Greenskin
Posts: 126
Joined: Thu Jun 05, 2008 3:26 am
Location: Thames, New Zealand
x 9

Re: FindOGRE.cmake in v1-9

Post by glennr »

Would it suffice to add a variable named OGRE_DONT_FIND_LIBS and use that, instead of NOT OGRE_SOURCE to disable find_library for your use case? So you would just need to set that in your CMakeLists.txt before calling find_package( OGRE ).
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56
Contact:

Re: FindOGRE.cmake in v1-9

Post by Klaim »

It sounds ok but I'll need to test as soon as I can to confirm.
schroffi
Gnoblar
Posts: 1
Joined: Fri Feb 07, 2014 8:37 pm

Re: FindOGRE.cmake in v1-9

Post by schroffi »

I have the same problem, so i cannot build my android app with the new version.
Is there any solution for this problem right now?
glennr
Greenskin
Posts: 126
Joined: Thu Jun 05, 2008 3:26 am
Location: Thames, New Zealand
x 9

Re: FindOGRE.cmake in v1-9

Post by glennr »

schroffi wrote:I have the same problem, so i cannot build my android app with the new version.
Is there any solution for this problem right now?
Just disable the if() around find_library in FindOgre.cmake. Something like this would do it:
https://bitbucket.org/sinbad/ogre/pull- ... sable/diff
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56
Contact:

Re: FindOGRE.cmake in v1-9

Post by Klaim »

I'm getting trouble having my Ogre setup compile with recent 1.9 and I'm not sure why yet. Anyway I'll be able to check that very soon.
Post Reply