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: 118
Joined: Thu Jun 05, 2008 3:26 am
Location: Thames, New Zealand
x 6

FindOGRE.cmake in v1-9

Post by glennr » Mon Feb 03, 2014 3:44 am

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.
0 x

User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
Contact:

Re: FindOGRE.cmake in v1-9

Post by Klaim » Mon Feb 03, 2014 4:06 am

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.
0 x

glennr
Greenskin
Posts: 118
Joined: Thu Jun 05, 2008 3:26 am
Location: Thames, New Zealand
x 6

Re: FindOGRE.cmake in v1-9

Post by glennr » Mon Feb 03, 2014 4:23 am

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 ?
0 x

User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
Contact:

Re: FindOGRE.cmake in v1-9

Post by Klaim » Mon Feb 03, 2014 4:57 am

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.
0 x

glennr
Greenskin
Posts: 118
Joined: Thu Jun 05, 2008 3:26 am
Location: Thames, New Zealand
x 6

Re: FindOGRE.cmake in v1-9

Post by glennr » Mon Feb 03, 2014 5:08 am

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 ).
0 x

User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
Contact:

Re: FindOGRE.cmake in v1-9

Post by Klaim » Mon Feb 03, 2014 5:20 am

It sounds ok but I'll need to test as soon as I can to confirm.
0 x

schroffi
Gnoblar
Posts: 1
Joined: Fri Feb 07, 2014 8:37 pm

Re: FindOGRE.cmake in v1-9

Post by schroffi » Fri Feb 07, 2014 8:48 pm

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?
0 x

glennr
Greenskin
Posts: 118
Joined: Thu Jun 05, 2008 3:26 am
Location: Thames, New Zealand
x 6

Re: FindOGRE.cmake in v1-9

Post by glennr » Sat Feb 08, 2014 7:55 am

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
0 x

User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
Contact:

Re: FindOGRE.cmake in v1-9

Post by Klaim » Sun Feb 16, 2014 2:56 pm

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.
0 x

Post Reply