Urho3D Wiki
mNo edit summary
Tags: Visual edit apiedit
mNo edit summary
Tags: Visual edit apiedit
Line 22: Line 22:
   
 
2.4. Create a "CMakeLists.txt" and fill it with:
 
2.4. Create a "CMakeLists.txt" and fill it with:
# Set project name<br>
+
# Set project name<br>project (SampleProject)<br># Define target name<br>set (TARGET_NAME SampleProject)<br>
project (SampleProject)<br>
 
# Define target name<br>
 
set (TARGET_NAME SampleProject)<br>
 
 
######################################<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 ()
# 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.
 
Replace SampleProject with your project name.
   

Revision as of 01:25, 14 December 2015

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:

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