Skip to main content

History: Building Your Projects With CMake

Source of version: 11

Copy to clipboard
            {BOX(width="100%",class="Layout_box9")}{SPLIT(colsize=10%|70%)}{IMG(src="img/wiki_up/Libraries.png",imalign="left",link="Building Your Projects With CMake",title="Building Your Projects With CMake")}{IMG}
---
{DIV(class="bigBold")}((Building Your Projects With CMake)){DIV}
This section is an introduction on how to use CMake to build your own projects and have them link against Ogre. For more detailed information about CMake, refer to the official CMake website: [http://www.cmake.org]
{SPLIT}{BOX}
!!Introduction

{maketoc}

!!A Template
The following files are needed:
* CMakeLists.txt
* include/
** *.h
* src/
** *.cpp

!!Your CMakeLists.txt file
A sample is included below
{CODE(wrap="1",colors="cmake")}
#/*
#-----------------------------------------------------------------------------
#Filename:    CMakeLists.txt
#-----------------------------------------------------------------------------
#
#This source file is part of the
#   ___                 __    __ _ _    _ 
#  /___\__ _ _ __ ___  / / /\ \ (_) | _(_)
# //  // _` | '__/ _ \ \ \/  \/ / | |/ / |
#/ \_// (_| | | |  __/  \  /\  /| |   <| |
#\___/ \__, |_|  \___|   \/  \/ |_|_|\_\_|
#      |___/                              
#	  Tutorial Framework
#	  http://www.ogre3d.org/tikiwiki/
#-----------------------------------------------------------------------------
#*/
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

project(OgreApp)

if(WIN32)
	getenv_path(OGRE_HOME)
	set(CMAKE_MODULE_PATH "${ENV_OGRE_HOME}/CMake/;${CMAKE_MODULE_PATH}")
	set(OGRE_SAMPLES_INCLUDEPATH
		${ENV_OGRE_HOME}/Samples/include
	)
endif(WIN32)

if(UNIX)
	set(CMAKE_MODULE_PATH "/usr/local/lib/OGRE/cmake/;${CMAKE_MODULE_PATH}")
	set(OGRE_SAMPLES_INCLUDEPATH
		/usr/local/share/OGRE/samples/Common/include/
	)
endif(UNIX)

if (CMAKE_BUILD_TYPE STREQUAL "")
  # CMake defaults to leaving CMAKE_BUILD_TYPE empty. This screws up
  # differentiation between debug and release builds.
  set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: None (CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif ()

SET(CMAKE_DEBUG_POSTFIX "_d")

find_package(OGRE REQUIRED)

IF (NOT "${OGRE_VERSION_NAME}" STREQUAL "Cthugha")
  MESSAGE(SEND_ERROR "You need Ogre 1.7 Cthugha to build this.")
ENDIF()

FIND_PACKAGE(OIS REQUIRED)

IF(NOT OIS_FOUND)
    MESSAGE(SEND_ERROR "Failed to find OIS.")
ENDIF()

SET(HDRS
	./BaseApplication.h
	./TutorialApplication.h
)

SET(SRCS
	./BaseApplication.cpp
	./TutorialApplication.cpp
)

include_directories( ${OIS_INCLUDE_DIRS}
	${OGRE_INCLUDE_DIRS}
	${OGRE_SAMPLES_INCLUDEPATH}
)

ADD_EXECUTABLE(OgreApp WIN32 ${HDRS} ${SRCS})

SET_TARGET_PROPERTIES(OgreApp PROPERTIES DEBUG_POSTFIX _d)

TARGET_LINK_LIBRARIES(OgreApp ${OGRE_LIBRARIES} ${OIS_LIBRARIES})
{CODE}

Replace __OgreApp__ with any name you want.
CMAKE_MODULE_PATH points to where you installed the Ogre3D cmake modules.
OGRE_SAMPLES_INCLUDEPATH points to where you installed the Ogre3D Samples framework include directory.
This usually happens when you run __make install__.

!!resources.cfg & plugins.cfg
!!!Linux
Copy '''plugins.cfg''' and '''resources.cfg''' from the Ogre media directory - usually '''/usr/local/share/OGRE''' - to your build directory:
{CODE(wrap="1", colors="bash")}cp /usr/local/share/OGRE/plugins.cfg /path/to/OgreApp/build_directory/plugins.cfg
cp /usr/local/share/OGRE/resources.cfg /path/to/OgreApp/build_directory/resources.cfg{CODE}
!!!Windows
TBD
        

History

Information Version
Sat 28 of Dec, 2024 15:43 GMT-0000 paroj 80
Thu 08 of Apr, 2021 21:22 GMT-0000 paroj 79
Thu 08 of Apr, 2021 21:22 GMT-0000 paroj 78
Thu 08 of Apr, 2021 21:20 GMT-0000 paroj 77
Sun 18 of Jun, 2017 11:18 GMT-0000 paroj 76
Fri 20 of Jan, 2017 01:47 GMT-0000 paroj 75
Sun 24 of Jan, 2016 13:33 GMT-0000 azmeuk 74
Sun 10 of Jan, 2016 16:35 GMT-0000 azmeuk 73
Sat 07 of Nov, 2015 11:45 GMT-0000 azmeuk 72
Sat 07 of Nov, 2015 11:44 GMT-0000 azmeuk 71
Thu 15 of Oct, 2015 19:02 GMT-0000 Sauermann Added v1.10 Windows framework 70
Tue 31 of Mar, 2015 06:09 GMT-0000 kabbotta 69
Tue 31 of Mar, 2015 05:59 GMT-0000 kabbotta 68
Tue 31 of Mar, 2015 05:56 GMT-0000 kabbotta 67
Tue 31 of Mar, 2015 05:54 GMT-0000 kabbotta 66
Tue 31 of Mar, 2015 05:54 GMT-0000 kabbotta 65
Tue 31 of Mar, 2015 05:53 GMT-0000 kabbotta 64
Tue 31 of Mar, 2015 05:53 GMT-0000 kabbotta 63
Fri 13 of Dec, 2013 05:57 GMT-0000 c6burns 62
Tue 10 of Dec, 2013 19:10 GMT-0000 c6burns added zip with changes for 1.9 61
Tue 13 of Nov, 2012 22:18 GMT-0000 jazztickets boost path was wrong for ogre 1.81 60
Thu 01 of Dec, 2011 21:48 GMT-0000 TcR1oo565 59
Tue 02 of Aug, 2011 14:07 GMT-0000 jacmoe 58
Sun 31 of Jul, 2011 23:34 GMT-0000 jacmoe 57
Thu 10 of Feb, 2011 10:53 GMT-0000 jacmoe 56