Page 2 of 20

Posted: Sat Nov 22, 2008 9:20 pm
by jacmoe
milliams wrote:.. if you just want a tarball, you can get one from the link at the bottom of this page.
Er, how do I download a tarball?

I looked at the git repository, but I failed to see a download link..

If I can avoid installing git on windows .. :wink:

Posted: Sun Nov 23, 2008 3:55 am
by milliams
Ah, it seems you need to be logged in to Gitorious to see that link. I've gzipped it up at http://milliams.com/ogre-cmake.tar.gz for those who don't have Git.

p.s. There's a pretty good Windows port of Git at http://code.google.com/p/msysgit/. Though I agree it's a lot of work just to try out a build system :)

Posted: Sun Nov 23, 2008 12:29 pm
by PolyVox
I tried it on Windows and it basically worked with a couple of problems.

Firstly the Direct3D9 RenderSystem didn't build because it couldn't find the .lib. This was a simple oversight, as the variable 'DirectX_LIBRARY_PATHS' had been defined by the FindDirectX.cmake script but wasn't being used. I fixed this by adding:

Code: Select all

link_directories(${DirectX_LIBRARY_PATHS})
to the Direct3D9 CmakeLists.txt

Secondly, it didn't find OIS or CEGUI and so was unable to build the samples. I didn't know how to fix this because I didn't know how it was trying to find them (I didn't see a FindOIS.cmake file). Any tips?

It didn't find Cg either, but I can investigate that a bit.

Posted: Sun Nov 23, 2008 2:12 pm
by jacmoe
Dependencies are almost always put in the root of the Ogre source directory.
That solves a lot of problems, doesn't it?
If it's in a non-standard location, give the user the option of changing that variable in the cmake configuration screen. :wink:

Posted: Sun Nov 23, 2008 5:32 pm
by milliams
PolyVox wrote:Firstly the Direct3D9 RenderSystem didn't build because it couldn't find the .lib. This was a simple oversight, as the variable 'DirectX_LIBRARY_PATHS' had been defined by the FindDirectX.cmake script but wasn't being used. I fixed this by adding:

Code: Select all

link_directories(${DirectX_LIBRARY_PATHS})
to the Direct3D9 CmakeLists.txt
Fixed, thanks.
PolyVox wrote:Secondly, it didn't find OIS or CEGUI and so was unable to build the samples. I didn't know how to fix this because I didn't know how it was trying to find them (I didn't see a FindOIS.cmake file). Any tips?
Currently all the dependency finding is done in CMakeModules/FindDependencies.cmake. I'm planning on phasing out the blocks there into separate FindWhatever.cmake files at some point but for testing they're fine.
PolyVox wrote:It didn't find Cg either, but I can investigate that a bit.
Again, Cg is searched for in that same file so have a look.

Posted: Wed Nov 26, 2008 12:39 pm
by tdev
wow, thanks for your work!

i just wanted to offer my own cmake files for ogre, but they are much simpler than yours :)

nice work, will test it out now.

EDIT: tested (under linux), working well.

i backported it to 1.4.9, some changes were needed to make it compile and some changes should flow into the latest version.

diff for 1.4.9:

Code: Select all

diff -Taur ./mainline/CMakeLists.txt ../ogrenew/CMakeLists.txt
--- ./mainline/CMakeLists.txt	2008-11-26 11:43:11.000000000 +0000
+++ ../ogrenew/CMakeLists.txt	2008-11-26 13:14:23.000000000 +0000
@@ -8,12 +8,13 @@
	
	#Yes, this is duplicated from OgrePrerequisites.h
	set(OGRE_VERSION_MAJOR "1")
-	set(OGRE_VERSION_MINOR "6")
-	set(OGRE_VERSION_PATCH "0")
+	set(OGRE_VERSION_MINOR "4")
+	set(OGRE_VERSION_PATCH "9")
	set(OGRE_VERSION "${OGRE_VERSION_MAJOR}.${OGRE_VERSION_MINOR}.${OGRE_VERSION_PATCH}")
	
	# Configure target output directories
-	set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules/")
+	message(${OGRE3D_SOURCE_DIR}/CMakeModules/)
+	set(CMAKE_MODULE_PATH "${OGRE3D_SOURCE_DIR}/CMakeModules/")
	include(MacroLogFeature)
	include(Packaging)
	
@@ -33,7 +34,7 @@
	endif (MSVC)
	
	# Add OgreMain include path
-	include_directories("${CMAKE_SOURCE_DIR}/OgreMain/include")
+	include_directories("${OGRE3D_SOURCE_DIR}/OgreMain/include")
	
	# Find dependencies
	find_package(Dependencies)
diff -Taur ./mainline/CMakeModules/FindDependencies.cmake ../ogrenew/CMakeModules/FindDependencies.cmake
--- ./mainline/CMakeModules/FindDependencies.cmake	2008-11-26 11:43:11.000000000 +0000
+++ ../ogrenew/CMakeModules/FindDependencies.cmake	2008-11-26 13:14:06.000000000 +0000
@@ -5,13 +5,13 @@
	if (WIN32)
	  #Set path from variables
	  set(OGRE_DEPENDENCIES_DIR "" CACHE PATH "Path to OGRE dependencies folder")
-	  set(DEP_INCLUDE_SEARCH_DIR "${CMAKE_SOURCE_DIR}" "${OGRE_DEPENDENCIES_DIR}")
+	  set(DEP_INCLUDE_SEARCH_DIR "${OGRE3D_SOURCE_DIR}" "${OGRE_DEPENDENCIES_DIR}")
	  set(DEP_INCLUDE_SEARCH_SUFFIXES "Dependencies/include" "Dependencies/include/CEGUI" "Dependencies/include/OIS")
-	  set(DEP_LIB_SEARCH_DIR "${CMAKE_SOURCE_DIR}" "${OGRE_DEPENDENCIES_DIR}")
+	  set(DEP_LIB_SEARCH_DIR "${OGRE3D_SOURCE_DIR}" "${OGRE_DEPENDENCIES_DIR}")
	  set(DEP_LIB_SEARCH_SUFFIXES "Dependencies/lib/Release")
-	  set(DEP_LIBD_SEARCH_DIR "${CMAKE_SOURCE_DIR}" "${OGRE_DEPENDENCIES_DIR}")
+	  set(DEP_LIBD_SEARCH_DIR "${OGRE3D_SOURCE_DIR}" "${OGRE_DEPENDENCIES_DIR}")
	  set(DEP_LIBD_SEARCH_SUFFIXES "Dependencies/lib/Debug")
-	  include_directories("${CMAKE_SOURCE_DIR}/Dependencies/include" "${OGRE_DEPENDENCIES_DIR}/Dependencies/include")
+	  include_directories("${OGRE3D_SOURCE_DIR}/Dependencies/include" "${OGRE_DEPENDENCIES_DIR}/Dependencies/include")
	elseif (UNIX)
	  set(DEP_INCLUDE_SEARCH_DIR
	    /usr/local/include
diff -Taur ./mainline/CMakeTemplates/CMakeLists.txt ../ogrenew/CMakeTemplates/CMakeLists.txt
--- ./mainline/CMakeTemplates/CMakeLists.txt	2008-11-26 11:43:11.000000000 +0000
+++ ../ogrenew/CMakeTemplates/CMakeLists.txt	2008-11-26 13:02:30.000000000 +0000
@@ -51,8 +51,8 @@
		set(CONFIG_FILE_DIR "lib/OGRE/CMake")
	endif(WIN32)
	
-	configure_file(${CMAKE_SOURCE_DIR}/CMakeTemplates/OGREConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/OGREConfig.cmake @ONLY)
-	configure_file(${CMAKE_SOURCE_DIR}/CMakeTemplates/OGREConfigVersion.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/OGREConfigVersion.cmake @ONLY)
+	configure_file(${OGRE3D_SOURCE_DIR}/CMakeTemplates/OGREConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/OGREConfig.cmake @ONLY)
+	configure_file(${OGRE3D_SOURCE_DIR}/CMakeTemplates/OGREConfigVersion.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/OGREConfigVersion.cmake @ONLY)
	install(FILES
		${CMAKE_CURRENT_BINARY_DIR}/OGREConfig.cmake
		${CMAKE_CURRENT_BINARY_DIR}/OGREConfigVersion.cmake
@@ -67,5 +67,5 @@
	set(OGRE_CFLAGS ) #TODO
	set(OGRE_THREAD_LIBS ) #TODO
	set(exec_prefix ${CMAKE_INSTALL_PREFIX})
-	configure_file(${CMAKE_SOURCE_DIR}/OGRE.pc.in ${CMAKE_CURRENT_BINARY_DIR}/OGRE.pc @ONLY)
+	configure_file(${OGRE3D_SOURCE_DIR}/OGRE.pc.in ${CMAKE_CURRENT_BINARY_DIR}/OGRE.pc @ONLY)
	install(FILES ${CMAKE_CURRENT_BINARY_DIR}/OGRE.pc DESTINATION lib/pkgconfig)
diff -Taur ./mainline/OgreMain/CMakeLists.txt ../ogrenew/OgreMain/CMakeLists.txt
--- ./mainline/OgreMain/CMakeLists.txt	2008-11-26 11:43:11.000000000 +0000
+++ ../ogrenew/OgreMain/CMakeLists.txt	2008-11-26 12:38:40.000000000 +0000
@@ -12,7 +12,7 @@
	  include/OgreArchive.h
	  include/OgreArchiveFactory.h
	  include/OgreArchiveManager.h
-	  include/OgreAtomicWrappers.h
+	#  include/OgreAtomicWrappers.h
	  include/OgreAutoParamDataSource.h
	  include/OgreAxisAlignedBox.h
	  include/OgreBillboard.h
@@ -88,12 +88,12 @@
	  include/OgreMath.h
	  include/OgreMatrix3.h
	  include/OgreMatrix4.h
-	  include/OgreMemoryAllocatedObject.h
-	  include/OgreMemoryAllocatorConfig.h
-	  include/OgreMemoryNedAlloc.h
-	  include/OgreMemoryStdAlloc.h
-	  include/OgreMemorySTLAllocator.h
-	  include/OgreMemoryTracker.h
+	#  include/OgreMemoryAllocatedObject.h
+	#  include/OgreMemoryAllocatorConfig.h
+	#  include/OgreMemoryNedAlloc.h
+	#  include/OgreMemoryStdAlloc.h
+	#  include/OgreMemorySTLAllocator.h
+	#  include/OgreMemoryTracker.h
	  include/OgreMesh.h
	  include/OgreMeshFileFormat.h
	  include/OgreMeshManager.h
@@ -150,12 +150,12 @@
	  include/OgreRenderQueueSortingGrouping.h
	  include/OgreRenderSystem.h
	  include/OgreRenderSystemCapabilities.h
-	  include/OgreRenderSystemCapabilitiesManager.h
-	  include/OgreRenderSystemCapabilitiesSerializer.h
+	#  include/OgreRenderSystemCapabilitiesManager.h
+	#  include/OgreRenderSystemCapabilitiesSerializer.h
	  include/OgreRenderTarget.h
	  include/OgreRenderTargetListener.h
	  include/OgreRenderTexture.h
-	  include/OgreRenderToVertexBuffer.h
+	#  include/OgreRenderToVertexBuffer.h
	  include/OgreRenderWindow.h
	  include/OgreResource.h
	  include/OgreResourceBackgroundQueue.h
@@ -168,18 +168,18 @@
	  include/OgreSceneManagerEnumerator.h
	  include/OgreSceneNode.h
	  include/OgreSceneQuery.h
-	  include/OgreScriptCompiler.h
-	  include/OgreScriptLexer.h
+	#  include/OgreScriptCompiler.h
+	#  include/OgreScriptLexer.h
	  include/OgreScriptLoader.h
-	  include/OgreScriptParser.h
-	  include/OgreScriptTranslator.h
+	#  include/OgreScriptParser.h
+	#  include/OgreScriptTranslator.h
	  include/OgreSearchOps.h
	  include/OgreSerializer.h
	  include/OgreShadowCameraSetup.h
	  include/OgreShadowCameraSetupFocused.h
	  include/OgreShadowCameraSetupLiSPSM.h
	  include/OgreShadowCameraSetupPlaneOptimal.h
-	  include/OgreShadowCameraSetupPSSM.h
+	#  include/OgreShadowCameraSetupPSSM.h
	  include/OgreShadowCaster.h
	  include/OgreShadowTextureManager.h
	  include/OgreShadowVolumeExtrudeProgram.h
@@ -205,7 +205,7 @@
	  include/OgreSubEntity.h
	  include/OgreSubMesh.h
	  include/OgreTagPoint.h
-	  include/OgreTangentSpaceCalc.h
+	#  include/OgreTangentSpaceCalc.h
	  include/OgreTechnique.h
	  include/OgreTextAreaOverlayElement.h
	  include/OgreTexture.h
@@ -234,7 +234,7 @@
	  src/OgreAnimationTrack.cpp
	  src/OgreArchiveManager.cpp
	  src/OgreAutoParamDataSource.cpp
-	  src/OgreAxisAlignedBox.cpp
+	#  src/OgreAxisAlignedBox.cpp
	  src/OgreBillboard.cpp
	  src/OgreBillboardChain.cpp
	  src/OgreBillboardParticleRenderer.cpp
@@ -299,9 +299,9 @@
	  src/OgreMath.cpp
	  src/OgreMatrix3.cpp
	  src/OgreMatrix4.cpp
-	  src/OgreMemoryAllocatedObject.cpp
-	  src/OgreMemoryNedAlloc.cpp
-	  src/OgreMemoryTracker.cpp
+	#  src/OgreMemoryAllocatedObject.cpp
+	#  src/OgreMemoryNedAlloc.cpp
+	#  src/OgreMemoryTracker.cpp
	  src/OgreMesh.cpp
	  src/OgreMeshManager.cpp
	  src/OgreMeshSerializer.cpp
@@ -346,11 +346,11 @@
	  src/OgreRenderQueueSortingGrouping.cpp
	  src/OgreRenderSystem.cpp
	  src/OgreRenderSystemCapabilities.cpp
-	  src/OgreRenderSystemCapabilitiesManager.cpp
-	  src/OgreRenderSystemCapabilitiesSerializer.cpp
+	#  src/OgreRenderSystemCapabilitiesManager.cpp
+	#  src/OgreRenderSystemCapabilitiesSerializer.cpp
	  src/OgreRenderTarget.cpp
	  src/OgreRenderTexture.cpp
-	  src/OgreRenderToVertexBuffer.cpp
+	#  src/OgreRenderToVertexBuffer.cpp
	  src/OgreRenderWindow.cpp
	  src/OgreResource.cpp
	  src/OgreResourceBackgroundQueue.cpp
@@ -363,16 +363,16 @@
	  src/OgreSceneManagerEnumerator.cpp
	  src/OgreSceneNode.cpp
	  src/OgreSceneQuery.cpp
-	  src/OgreScriptCompiler.cpp
-	  src/OgreScriptLexer.cpp
-	  src/OgreScriptParser.cpp
-	  src/OgreScriptTranslator.cpp
+	#  src/OgreScriptCompiler.cpp
+	#  src/OgreScriptLexer.cpp
+	#  src/OgreScriptParser.cpp
+	#  src/OgreScriptTranslator.cpp
	  src/OgreSerializer.cpp
	  src/OgreShadowCameraSetup.cpp
	  src/OgreShadowCameraSetupFocused.cpp
	  src/OgreShadowCameraSetupLiSPSM.cpp
	  src/OgreShadowCameraSetupPlaneOptimal.cpp
-	  src/OgreShadowCameraSetupPSSM.cpp
+	#  src/OgreShadowCameraSetupPSSM.cpp
	  src/OgreShadowCaster.cpp
	  src/OgreShadowTextureManager.cpp
	  src/OgreShadowVolumeExtrudeProgram.cpp
@@ -390,7 +390,7 @@
	  src/OgreSubEntity.cpp
	  src/OgreSubMesh.cpp
	  src/OgreTagPoint.cpp
-	  src/OgreTangentSpaceCalc.cpp
+	#  src/OgreTangentSpaceCalc.cpp
	  src/OgreTechnique.cpp
	  src/OgreTextAreaOverlayElement.cpp
	  src/OgreTexture.cpp
diff -Taur ./mainline/PlugIns/CMakeLists.txt ../ogrenew/PlugIns/CMakeLists.txt
--- ./mainline/PlugIns/CMakeLists.txt	2008-11-26 11:43:11.000000000 +0000
+++ ../ogrenew/PlugIns/CMakeLists.txt	2008-11-26 12:32:51.000000000 +0000
@@ -21,8 +21,8 @@
	  add_subdirectory(ParticleFX)
	endif (OGRE_BUILD_PLUGIN_PFX)
	
-	if (OGRE_BUILD_PLUGIN_PCZ)
-	  add_subdirectory(PCZSceneManager)
-	  add_subdirectory(OctreeZone)
-	endif (OGRE_BUILD_PLUGIN_PCZ)
+	#if (OGRE_BUILD_PLUGIN_PCZ)
+	#  add_subdirectory(PCZSceneManager)
+	#  add_subdirectory(OctreeZone)
+	#endif (OGRE_BUILD_PLUGIN_PCZ)
	
diff -Taur ./mainline/RenderSystems/GL/CMakeLists.txt ../ogrenew/RenderSystems/GL/CMakeLists.txt
--- ./mainline/RenderSystems/GL/CMakeLists.txt	2008-11-26 11:43:11.000000000 +0000
+++ ../ogrenew/RenderSystems/GL/CMakeLists.txt	2008-11-26 12:32:23.000000000 +0000
@@ -22,7 +22,7 @@
	  include/OgreGLPrerequisites.h
	  include/OgreGLRenderSystem.h
	  include/OgreGLRenderTexture.h
-	  include/OgreGLRenderToVertexBuffer.h
+	#  include/OgreGLRenderToVertexBuffer.h
	  include/OgreGLSupport.h
	  include/OgreGLTexture.h
	  include/OgreGLTextureManager.h
@@ -51,7 +51,7 @@
	  src/OgreGLPlugin.cpp
	  src/OgreGLRenderSystem.cpp
	  src/OgreGLRenderTexture.cpp
-	  src/OgreGLRenderToVertexBuffer.cpp
+	#  src/OgreGLRenderToVertexBuffer.cpp
	  src/OgreGLSupport.cpp
	  src/OgreGLTexture.cpp
	  src/OgreGLTextureManager.cpp
@@ -104,14 +104,14 @@
	  src/GLSL/include/OgreGLSLGpuProgram.h
	  src/GLSL/include/OgreGLSLLinkProgram.h
	  src/GLSL/include/OgreGLSLLinkProgramManager.h
-	  src/GLSL/include/OgreGLSLPreprocessor.h
+	#  src/GLSL/include/OgreGLSLPreprocessor.h
	  src/GLSL/include/OgreGLSLProgramFactory.h
	  src/GLSL/include/OgreGLSLProgram.h
	  src/GLSL/src/OgreGLSLExtSupport.cpp
	  src/GLSL/src/OgreGLSLGpuProgram.cpp
	  src/GLSL/src/OgreGLSLLinkProgram.cpp
	  src/GLSL/src/OgreGLSLLinkProgramManager.cpp
-	  src/GLSL/src/OgreGLSLPreprocessor.cpp
+	#  src/GLSL/src/OgreGLSLPreprocessor.cpp
	  src/GLSL/src/OgreGLSLProgram.cpp
	  src/GLSL/src/OgreGLSLProgramFactory.cpp
	)
diff -Taur ./mainline/Samples/CMakeLists.txt ../ogrenew/Samples/CMakeLists.txt
--- ./mainline/Samples/CMakeLists.txt	2008-11-26 11:43:11.000000000 +0000
+++ ../ogrenew/Samples/CMakeLists.txt	2008-11-26 12:34:12.000000000 +0000
@@ -21,17 +21,17 @@
	  add_subdirectory(CameraTrack)
	  add_subdirectory(CelShading)
	  add_subdirectory(CubeMapping)
-	  add_subdirectory(DeferredShading)
+	#  add_subdirectory(DeferredShading)
	  add_subdirectory(Dot3Bump)
	  add_subdirectory(DynTex)
	  add_subdirectory(EnvMapping)
	  add_subdirectory(Fresnel)
	  add_subdirectory(Grass)
-	  add_subdirectory(Isosurf)
+	#  add_subdirectory(Isosurf)
	  add_subdirectory(Lighting)
	  add_subdirectory(ParticleFX)
-	  add_subdirectory(ParticleGS)
-	  add_subdirectory(PCZTestApp)
+	#  add_subdirectory(ParticleGS)
+	#  add_subdirectory(PCZTestApp)
	  add_subdirectory(RenderToTexture)
	  add_subdirectory(SkeletalAnimation)
	  add_subdirectory(SkyBox)
however you should use ${OGRE3D_SOURCE_DIR} instead of ${CMAKE_SOURCE_DIR} everywhere. Otherwise it is impossible to attach Ogre into a bigger cmake project that has its root above the ogre directory. (the above patch also fixes that)

edit2: forgot to add a "src/GLX/OgreGLXUtils.cpp" to the UNIX PLATFORM_FILES in OgreMain/CMakeLists.txt in the above patch ...

Posted: Wed Nov 26, 2008 5:56 pm
by milliams
tdev wrote:however you should use ${OGRE3D_SOURCE_DIR} instead of ${CMAKE_SOURCE_DIR} everywhere. Otherwise it is impossible to attach Ogre into a bigger cmake project that has its root above the ogre directory. (the above patch also fixes that)
Yes, that's true. I had been meaning to change that. I'm also going to specify subprojects for OgreMain, plugins, samples etc. to allow more fine-grained make-time build options.

I'll merge in your ${CMAKE_*} -> ${OGRE_*} changes but I'll leave the 1.4.9 port on this forum as a patch for those who want to build 1.4.9 with CMake.

Posted: Wed Nov 26, 2008 6:12 pm
by tdev
milliams wrote: Yes, that's true. I had been meaning to change that. I'm also going to specify subprojects for OgreMain, plugins, samples etc. to allow more fine-grained make-time build options.

I'll merge in your ${CMAKE_*} -> ${OGRE_*} changes but I'll leave the 1.4.9 port on this forum as a patch for those who want to build 1.4.9 with CMake.
sure, thanks for fixing :)

i thought about if you want to use
FILE(GLOB_RECURSE hydrax_src Hydrax/*.cpp)
at some points, as it makes the buildsystem independent from the actual files. For sure its not going to work if platform specific files need to be included/excluded. Maybe it makes more sense for header files.

Posted: Wed Nov 26, 2008 7:43 pm
by CABAListic
No, that's already been discussed and rejected. :)

Anyway, thanks for moving this forward. In approximately two weeks I'll have the time to look at the new versions and help with whatever's left to do by then.

Posted: Wed Nov 26, 2008 8:37 pm
by milliams
CABAListic wrote:Anyway, thanks for moving this forward. In approximately two weeks I'll have the time to look at the new versions and help with whatever's left to do by then.
Excellent. In about 2 weeks I'll suddenly have a lot more time to work on this so we should be able to blitz out a fully working solution then. In the meantime I'll be putting all my changes into the git repository.

Posted: Thu Nov 27, 2008 3:43 am
by tdev
good to hear :)
also i noticed already a minor bug: Even if you want to disable freeimage you still have to fulfill the dependency, otherwise cmake will abort.

Posted: Thu Nov 27, 2008 6:57 am
by jacmoe
tdev wrote:good to hear :)
also i noticed already a minor bug: Even if you want to disable freeimage you still have to fulfill the dependency, otherwise cmake will abort.
That should be an option, like FREEIMAGE = YES/NO.

Of course, it should look for and configure the alternative. :wink:

Would be nice if we are given a nice cmake configuration screen, where we can set this option, along with installation prefix, etc. :)

Posted: Thu Nov 27, 2008 11:23 am
by tdev
jacmoe wrote: Would be nice if we are given a nice cmake configuration screen, where we can set this option, along with installation prefix, etc. :)
you mean like that:
Image
(thats cmake-gui)
there is also a console version thats called ccmake :)

Posted: Thu Nov 27, 2008 12:46 pm
by jacmoe
tdev wrote:you mean like that:
Exactly!
ccmake is what I use on Linux.
Pretty cool. Beats passing arguments to a configure script. :)

Re: CMake build files for Ogre 1.6

Posted: Sat Jan 17, 2009 11:19 pm
by CABAListic
Ok, finally spent some more time on this (based on milliams' latest updates), and I think I'm now almost there. I finally managed to get the precompiled header running for Visual Studio, and this also fixes the weird linking error in debug build. That was a major hurdle for me.

I reworked the dependency finding; it's not perfect yet, but the packages are now handled separately in custom modules (or in those shipped with CMake, if available). The CMake scripts do not look for debug versions of the libraries, so currently for some libraries it's using the release builds even in debug mode on Windows.


In any case, the build process on any platform now works as follows: You have basically three directories involved:
  • The Ogre source dir: As checked out from svn, this directory remains completely untouched during build.
  • The build dir: Any location of your choice where the compilation takes place. Any compiler output is collected here, this directory is managed by CMake.
  • The install dir: The directory where all the results are put for further use. Unix users are familiar with it, Windows users probably not so much. The Visual Studio project file has an additional target "INSTALL" which will put all the DLLs, header files and whatnot to the specified install directory in an ordered way, so that you get a clean result.
The aim is that the install dir structure after a successful build more or less resembles the SDK layout (so that not only can you use it for your Ogre work, but sinbad and other SDK maintainers have to spend less time to create an SDK build). This means that under Windows, you get the following structure:
  • bin: Subdivided into Release and Debug; contains all the DLLs and built samples.
  • include: Contains the Ogre header files
  • docs: Contains the Ogre documentation (if you choose to install it, this is a CMake option)
  • media: Contains the sample media (if you choose to install it, this is a CMake option)
  • lib: Contains the link libraries and the directory opt, where link libraries for the plugins exist.
The directory layout for Unix is slightly different to adopt to the standard Unix choices, but is in spirit similar. CMake will automatically generate .cfg files for the bin directory(s) with correct paths and plugin includes so that the samples are immediately usable from there. The one thing that's still missing to complete a full SDK build is the Samples source code with a structure to build the samples. I will probably look into this tomorrow.


There's also two minor changes involved that you need to do to the Ogre source dir:
  • Remove the OgreConfig.h in OgreMain/include: This file is auto-generated by the CMake system from a template residing in CMakeTemplates/OgreConfig.h.in. The template is generated in the build directory and will be installed in the install dir. If it's still present in OgreMain/include, it will screw up your build (or at least render the CMake config options which modify OgreConfig.h useless).
  • Ogre's version number is now set inside CMake. There is a file OgreVersion.cmake in the root directory which contains all the version variables (i. e. major, minor, patch, suffix, name). During build, CMake automatically generates a file OgreVersion.h from a template in CMakeTemplates/OgreVersion.h.in which contains all the macro definitions that currently reside in OgrePrerequisites.h. So OgrePrerequisites.h needs to be changed to #include "OgreVersion.h" instead.
Furthermore, I'm thinking about restructuring the layout of the Samples directory a little. This might ease the installation of the samples source as mentioned above, and in any case, the current structure was meant for a different build system than what CMake does. Also, the DLLs of the Dependencies packages for Windows should no longer go into Samples/Common/bin, but instead to Dependencies/bin, so that an install rule can be created for the Dependencies directory which installs all required dependencies along with the build. I hope that's reasonable enough?

My goal would be that the CMake system could become the primary (and only) build system for Cthugha. There are of course still a few problems left, but as far as sinbad's release schedule goes, there's also quite a bit of time left :)

My current list of remaining problems/features:
  • Under Windows, many of the samples crash for me at load. I haven't yet investigated since they were release builds.
  • Under Windows, two of the samples don't compile because their main function is not #ifdef'ed as for the rest of the demos. This interferes with my settings of CONSOLE or WINDOWS subsystems depending on release or debug build modes. I think the sample code should be fixed, not the CMake build system.
  • Under Linux, Demo_BSP doesn't compile for me, some error with linking to OIS (but only in BSP). Have to investigate further.
  • Under Linux, CMake currently generates a warning due to the way one of the find_package modules works. Harmless, but slightly annoying, will fix.
  • OSX support missing. This is currently the primary obstacle for the system before becoming official (as far as I'm concerned).
  • On all systems: Install samples source code along with a build system (CMake) if enabled in CMake. This is primarily intended for assembling binary SDK packages.
  • On all systems: CPack support to (more or less) automatically generate SDK packages from the install directory.

If you want to test it, here's my current version: http://downloads.oddbeat.de/ogre.cmake.zip
Check out Ogre 1.6 from svn, make the two changes outlined above to it, then copy the files from the ZIP archive into your ogre source dir and start cmake-gui. Choose the source dir, a build dir and an install dir as you like and generate the build system :)

Re: CMake build files for Ogre 1.6

Posted: Sat Jan 17, 2009 11:41 pm
by jacmoe
Wow, cool. I'll download it now and test it tomorrow.
Then I'll let you know if I like it. :)

Re: CMake build files for Ogre 1.6

Posted: Sun Jan 18, 2009 12:24 am
by milliams
Good work! I haven't tried it out yet but I'll have a go tomorrow. Was this based on the latest .zip file I posted to the forum or on the latest stuff in the git repo? Not much has changed since I made the .zip but there were one or two small things.

Re: CMake build files for Ogre 1.6

Posted: Sun Jan 18, 2009 12:51 am
by CABAListic
Based on the git repo. The main changes include the FindDependencies.cmake, which, as mentioned, now calls separate packages for each dependency. I have put the OGRE_DEPENDENCIES_DIR variable as a general one, independent of system, because I think it might have some uses in special cases even under Unix systems. The hardcoded guesses (including that variable) are passed on to CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH, so that all the find_package calls can take advantage of it.
The other change is that I decided to have the samples go into the bin directory, and I created some special install functions which (on Windows) can sort the files into the Debug/Release directories that are commonly used on Windows. I also wrote another module to install resource files (media and documentation as well as the generated plugins.cfg/resources.cfg etc. files).

Re: CMake build files for Ogre 1.6

Posted: Sun Jan 18, 2009 12:26 pm
by sinbad
Gah, I've had a post-it on my desk for ages telling me to look at this, but I just haven't had time. Will definitely get to it soon, thanks for all the effort...

Re: CMake build files for Ogre 1.6

Posted: Sun Jan 18, 2009 3:46 pm
by CABAListic
Ok, I fixed both Linux problems. The BSP demo not linking was actually a stupid mistake due to copying my CMake files from Windows - the directory in my CMake files was written in lower-case (bsp), but the Ogre sources on Linux have it written BSP, so my updated CMakeLists.txt did not come through.
Furthermore, I discovered that the Cg plugin didn't work on Linux, apparently you have to link OgreMain to pthread even if not using threads yourself since Cg needs it. Fixed this, the Cg plugin is now working properly. All in all, the Linux build looks relatively solid now, to me at least. I didn't test everything, especially didn't test threading support. My CPU is single-threaded and not the fastest anymore, so the constant recompiles just take too much time ;)

I updated the ZIP archive and will now look at the Windows samples problem.

Re: CMake build files for Ogre 1.6

Posted: Sun Jan 18, 2009 6:31 pm
by milliams
Okay, I did a clean checkout of of Ogre and your cmake files and I'm getting an error regarding nedmalloc. I realise the nedmalloc stuff changed quite recently but I guess either necmalloc need to be included in the Ogre source tree in SVN or we need to write a cmake check for it.

Code: Select all

[ 19%] Building CXX object OgreMain/CMakeFiles/OgreMain.dir/src/OgreMemoryNedAlloc.o
/home/matt/ogre-cmake-trunk/OgreMain/src/OgreMemoryNedAlloc.cpp:38:23: error: nedmalloc.c: No such file or directory
/home/matt/ogre-cmake-trunk/OgreMain/src/OgreMemoryNedAlloc.cpp: In static member function ‘static void* Ogre::NedAllocImpl::allocBytes(size_t, const char*,int, const char*)’:
/home/matt/ogre-cmake-trunk/OgreMain/src/OgreMemoryNedAlloc.cpp:47: error: ‘nedalloc’ has not been declared
/home/matt/ogre-cmake-trunk/OgreMain/src/OgreMemoryNedAlloc.cpp: In static member function ‘static void Ogre::NedAllocImpl::deallocBytes(void*)’:
/home/matt/ogre-cmake-trunk/OgreMain/src/OgreMemoryNedAlloc.cpp:66: error: ‘nedalloc’ has not been declared
/home/matt/ogre-cmake-trunk/OgreMain/src/OgreMemoryNedAlloc.cpp: In static member function ‘static void* Ogre::NedAllocImpl::allocBytesAligned(size_t, size_t, const char*, int, const char*)’:
/home/matt/ogre-cmake-trunk/OgreMain/src/OgreMemoryNedAlloc.cpp:73: error: ‘nedalloc’ has not been declared
/home/matt/ogre-cmake-trunk/OgreMain/src/OgreMemoryNedAlloc.cpp:74: error: ‘nedalloc’ has not been declared
/home/matt/ogre-cmake-trunk/OgreMain/src/OgreMemoryNedAlloc.cpp: In static member function ‘static void Ogre::NedAllocImpl::deallocBytesAligned(size_t, void*)’:
/home/matt/ogre-cmake-trunk/OgreMain/src/OgreMemoryNedAlloc.cpp:94: error: ‘nedalloc’ has not been declared
make[2]: *** [OgreMain/CMakeFiles/OgreMain.dir/src/OgreMemoryNedAlloc.o] Error 1
make[1]: *** [OgreMain/CMakeFiles/OgreMain.dir/all] Error 2
make: *** [all] Error 2
Also, I've put your latest changes into the [url=git://gitorious.org/ogre-cmake/mainline.git]git repo[/url] to keep track of the changes. Hopefully though, we'll be able to import this into SVN some time soon.

Re: CMake build files for Ogre 1.6

Posted: Sun Jan 18, 2009 6:39 pm
by CABAListic
There is a config option for the allocator behaviour. It defaults to nedmalloc now, but you can change it back. A value of 2 is nedmalloc, a value of 1 is standard allocation. A check would probably be useful, though.

I'm currently on Windows trying to find out why the demos don't work. Unfortunately, building the demos in Debug mode gives even less useful results, as in that case they are just outputting garbage numbers to the console. I've seen this before, but I'm not yet sure what's causing it.

Re: CMake build files for Ogre 1.6

Posted: Sun Jan 18, 2009 9:17 pm
by milliams
Cheers, that did it.

A few changes I've had to make are that the .zip file you provided contained a folder RenderSystems/gl whereas the ogre svn has RenderSystems/GL. Also, a few files were missing from the OgreMain build which was causing the samples to fail building.

The only issues remaining which stand in the way of this build system being perfect for Linux are:
  • nedmalloc check
  • Running the samples from the install directory gives an error since it can't find the .cfg files (this is a minor problem since I hardly ever run the demos anyway). Maybe we should disable building the samples as a default? Since they make most sense for the SDK anyway.
On Windows there are a few more things to go, mostly due to the need for a SDK building/packaging system (there's no need for this on Linux as Ogre will either be compiled from source or obtained as a distribution package).

How were you planning on reordering the Samples directory? It sounds like a good idea regardless (incidentally, I've always found it strange that the CEGUI renderer was hidden away inside the Samples/Common directory instead of in PlugIns).

Has anyone else had a go at building Ogre with this?

Re: CMake build files for Ogre 1.6

Posted: Sun Jan 18, 2009 9:23 pm
by CABAListic
Re nedmalloc: I just found out that it's actually in the Ogre sources, you just need to add the correct include directory (OgreMain/src/nedmalloc). I'll fix this. As for the directory names, yeah sorry, next time I'll assemble the zip file from Linux. Those Lod files are new additions, probably in Ogre head? I created my version against Shoggoth.
As for the samples, those work fine for me under Linux? I haven't yet decided how to go about the Samples directory, because first I need to fix the Windows build.

Unfortunately, no luck so far with the samples on Windows. Something's just not right, everything compiles nicely and installs just fine, and all that is working really well. But something's wrong with the demos. In Release, most of them just crash on startup. In debug, almost all of them (with two exceptions) only print some weird stuff on the console instead of doing anything, it looks like this:

Code: Select all

//
// This is an automatically generated file.
// Do not edit.
//

const unsigned short expTable[] =
{
    0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 
    0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 
    0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 
    0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 
    0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 

// etc. pp., this goes on forever

};
I currently have no idea what might be causing this, and a google search comes up empty. Even more puzzling is that two of the demos work, plus I can link my ETL project against that compiled Ogre version just fine. Seeing as all of the demos basically are setup identically in CMake, I just don't get it. I'm slightly frustrated right now and need a break ;)

Re: CMake build files for Ogre 1.6

Posted: Sun Jan 18, 2009 10:52 pm
by milliams
Yeah, nedmalloc now seems to be building fine. I am indeed working from SVN HEAD because I assumed you were too. I can't guess what the problem is with the samples on Windows. I haven't an easy way to test it right now.

I've got the API docs building and installing now with Doxygen (just a make doc will do it).

With the exception of the samples (which I'll look into why they're not working for me), I would say that this is completely working for Linux as a build system. It would be great to have some more people testing this so we can iron out some package searching bugs etc.