FANDOM


Creating a new Urho3D Project Edit

OUTDATED! This was written for Urho 1.32 Edit

This tries to be a shorter and easier version of http://urho3d.github.io/documentation/1.32/_using_library.html.

1. Urho's folder structure changed a bit:

For Urho 1.32 and before: Create a project folder with the subfolders "Source", "Bin" and "Build". You may want to copy the "CoreData" and "Data" folder from Urho3D's "Bin" folder into your new projects "Bin" folder so that your program can load the data.

For newer Urho (from example from Git repository): Create a project folder with the subfolders "Source" and "Build". You may want to copy the "CoreData" and "Data" folder from Urho3D's "Bin" folder into your new projects "Build/bin" folder so that your program can load the data.

2. Put a file called "CMakeLists.txt" into the "Source" folder, with this content:

# Set project name
project (MyProjectName)
# Define target name
set (TARGET_NAME MyExecutableName)
# Set minimum version
cmake_minimum_required (VERSION 2.8.6)
if (COMMAND cmake_policy)
  cmake_policy (SET CMP0003 NEW)
  if (CMAKE_VERSION VERSION_GREATER 2.8.12 OR CMAKE_VERSION VERSION_EQUAL 2.8.12)
    cmake_policy (SET CMP0022 NEW) # INTERFACE_LINK_LIBRARIES defines the link interface
  endif ()
   if (CMAKE_VERSION VERSION_GREATER 3.0.0 OR CMAKE_VERSION VERSION_EQUAL 3.0.0)
    cmake_policy (SET CMP0026 OLD) # Disallow use of the LOCATION target property - therefore we set to OLD as we still need it
    cmake_policy (SET CMP0042 NEW) # MACOSX_RPATH is enabled by default
  endif ()
 endif ()
 # Set CMake modules search path
set (CMAKE_MODULE_PATH $ENV{URHO3D_HOME}/Source/CMake/Modules CACHE PATH "Path to Urho3D-specific CMake modules")
# Include Urho3D Cmake common module
include (Urho3D-CMake-common)
# Find Urho3D library
find_package (Urho3D REQUIRED)
include_directories (${URHO3D_INCLUDE_DIRS})
# Define source files
define_source_files ()
# Setup target with resource copying
setup_main_executable ()

You can change MyProjectName and MyExecutableName.

3. Add an environment variable to your system called "URHO3D_HOME" that points to your Urho3D folder (the top one, containing the "Source" subfolder). See http://www.computerhope.com/issues/ch000549.htm on how to do that for windows. (You may need to restart CMake-GUI after doing this, if you had it already open.)

4. Use CMake or CMake-GUI, like you did when building Urho3D itself, and select the new Source and Build folders and generate your project file.
Note: If you want to use C++11 you have to add "-std=c++11" to "CMAKE_CXX_FLAGS" inside CMake-GUI or use

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
Note for Mac OS X: There is an issue with the default STL not fully supporting C++11. You need to switch the STL to libc++ with "-stdlib=libc++" like

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")

5. Open the generated project file with the IDE you created the project files for (like CodeBlocks).

6. Select your project as the build target. Selecting "all" would also work for building, but the IDE won't be able to start the program.

7. Create source files, or use this sample code at http://urho3d.wikia.com/wiki/First_Project, or copy source files from a sample inside the Urho3D folder (like "Source/Samples/23_Water"), into the Source folder.

8. You should be able to build and run your program now.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.