Urho3D Wiki
Register
(Created page with "This tries to be a shorter and easier version of http://urho3d.github.io/documentation/1.5/_using_library.html. (There's an old guide for Urho 1.32 here: [[Creating a new Urh...")
Tag: rte-source
 
mNo edit summary
Tags: Visual edit apiedit
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
  +
[This page is currently conflicting with the [[First project]] page. They both have a first project example. I'll be restructuring that to have one really minimal testing sample here, and one a bit more complex example in the First Project page that explains basic Urho ideas. This page should be more about setting the project up and less about how to use Urho.]
  +
 
This tries to be a shorter and easier version of http://urho3d.github.io/documentation/1.5/_using_library.html.
 
This tries to be a shorter and easier version of http://urho3d.github.io/documentation/1.5/_using_library.html.
   
 
(There's an old guide for Urho 1.32 here: [[Creating a new Urho3D 1.32 Project]].
 
(There's an old guide for Urho 1.32 here: [[Creating a new Urho3D 1.32 Project]].
   
  +
== 1. Urho3D Environment Variable ==
1. Create a new environment variable (user or system variable) called "URHO3D_HOME" and set the value to the path where you build Urho into.
+
Create a new environment variable (user or system variable) called "URHO3D_HOME" and set the value to the path where you build Urho into:
   
 
[[File:Urho_sv.jpg|thumb|center|600px]]
 
[[File:Urho_sv.jpg|thumb|center|600px]]
   
 
How this is done in Windows is explained in more details here: [[Building Urho 1.5 (Windows 10, MinGW/GCC)#3._Set_up_MinGW_for_CMake]]
 
How this is done in Windows is explained in more details here: [[Building Urho 1.5 (Windows 10, MinGW/GCC)#3._Set_up_MinGW_for_CMake]]
  +
  +
2. Create and Fill Project Folder
  +
  +
You can use this quite minimal Urho Sample Project to skip copying and filling the folder manually: https://github.com/gawag/UrhoSampleProject
  +
  +
2. 1. Copy those files and folders from Urho
  +
CMake/
  +
cmake_generic.bat
  +
2.2. Copy one or more of the "cmake_*.bat" files depending on the build system you want to use. If you are using codeblocks, copy "cmake_codeblocks.bat". If you are not on Windows, get the files ending on ".sh" instead of ".bat".
  +
  +
2.3. Create a "bin" folder with a "CoreData" and a "Data" folder inside. You may want to copy "CoreData" from Urho to get same basic materials.
  +
  +
2.4. Create a "CMakeLists.txt" and fill it with:
  +
# Set project name<br>project (SampleProject)<br># Define target name<br>set (TARGET_NAME SampleProject)<br>
  +
######################################<br>
  +
# Set minimum version<br>cmake_minimum_required (VERSION 2.8.6)<br>if (COMMAND cmake_policy)<br> cmake_policy (SET CMP0003 NEW)<br> if (CMAKE_VERSION VERSION_GREATER 2.8.12 OR CMAKE_VERSION VERSION_EQUAL 2.8.12)<br> # INTERFACE_LINK_LIBRARIES defines the link interface<br> cmake_policy (SET CMP0022 NEW)<br> endif ()<br> if (CMAKE_VERSION VERSION_GREATER 3.0.0 OR CMAKE_VERSION VERSION_EQUAL 3.0.0)<br> # Disallow use of the LOCATION target property - therefore we set to OLD as we still need it<br> cmake_policy (SET CMP0026 OLD)<br> # MACOSX_RPATH is enabled by default<br> cmake_policy (SET CMP0042 NEW)<br> endif ()<br>endif ()<br># Set CMake modules search path<br>set (CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake/Modules)<br># Include Urho3D Cmake common module<br>include (Urho3D-CMake-common)<br># Find Urho3D library<br>find_package (Urho3D REQUIRED)<br>include_directories (${URHO3D_INCLUDE_DIRS})<br># Define source files<br>define_source_files ()<br># Setup target with resource copying<br>setup_main_executable ()
  +
Replace SampleProject with your project name.
  +
  +
2.5. Create source files. CMake needs at least one .cpp file to set the linker correctly.
  +
  +
Your folder could now look like:
  +
[[File:Urho new project.JPG|centre|thumb|525x525px]]
  +
  +
== 3. Prepare Build and Build ==
  +
Like in [[Building Urho 1.5 (Windows 10, MinGW/GCC)|Building Urho 1.5 (Windows 10, MinGW/GCC)#4._Run_CMake_to_create_the_project_files_for_Urho]] open a terminal and use the cmake script to generate the project build files:
  +
[[File:Urho new project prepare.JPG|centre|thumb|600x600px]]
  +
You have to use the same options you used to build Urho.
  +
  +
You can also use the CMake GUI:
  +
[[File:Urho new project cmake gui.JPG|centre|thumb|600x600px]]
  +
'''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 "<code>-stdlib=libc++</code>" like
  +
  +
<code>set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")</code>
  +
  +
== 4. Build ==
  +
Open the created project file and build it:
  +
[[File:Urho new project build.JPG|centre|thumb|600x600px]]

Latest revision as of 14:54, 14 December 2015

[This page is currently conflicting with the First project page. They both have a first project example. I'll be restructuring that to have one really minimal testing sample here, and one a bit more complex example in the First Project page that explains basic Urho ideas. This page should be more about setting the project up and less about how to use Urho.]

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

(There's an old guide for Urho 1.32 here: Creating a new Urho3D 1.32 Project.

1. Urho3D Environment Variable[]

Create a new environment variable (user or system variable) called "URHO3D_HOME" and set the value to the path where you build Urho into:

Urho sv

How this is done in Windows is explained in more details here: Building Urho 1.5 (Windows 10, MinGW/GCC)#3._Set_up_MinGW_for_CMake

2. Create and Fill Project Folder

You can use this quite minimal Urho Sample Project to skip copying and filling the folder manually: https://github.com/gawag/UrhoSampleProject

2. 1. Copy those files and folders from Urho

CMake/
cmake_generic.bat

2.2. Copy one or more of the "cmake_*.bat" files depending on the build system you want to use. If you are using codeblocks, copy "cmake_codeblocks.bat". If you are not on Windows, get the files ending on ".sh" instead of ".bat".

2.3. Create a "bin" folder with a "CoreData" and a "Data" folder inside. You may want to copy "CoreData" from Urho to get same basic materials.

2.4. Create a "CMakeLists.txt" and fill it with:

# Set project name
project (SampleProject)
# Define target name
set (TARGET_NAME SampleProject)
######################################
# 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)
# INTERFACE_LINK_LIBRARIES defines the link interface
cmake_policy (SET CMP0022 NEW)
endif ()
if (CMAKE_VERSION VERSION_GREATER 3.0.0 OR CMAKE_VERSION VERSION_EQUAL 3.0.0)
# Disallow use of the LOCATION target property - therefore we set to OLD as we still need it
cmake_policy (SET CMP0026 OLD)
# MACOSX_RPATH is enabled by default
cmake_policy (SET CMP0042 NEW)
endif ()
endif ()
# Set CMake modules search path
set (CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/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 ()

Replace SampleProject with your project name.

2.5. Create source files. CMake needs at least one .cpp file to set the linker correctly.

Your folder could now look like:

Urho new project

3. Prepare Build and Build[]

Like in Building Urho 1.5 (Windows 10, MinGW/GCC)#4._Run_CMake_to_create_the_project_files_for_Urho open a terminal and use the cmake script to generate the project build files:

Urho new project prepare

You have to use the same options you used to build Urho.

You can also use the CMake GUI:

Urho new project cmake gui

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++")

4. Build[]

Open the created project file and build it:

Urho new project build