Ok, so you have the Urho3D source folder, and a build folder. And set the URHO3D_HOME environment variable.
so far so good.
This is what I do.
I have a project folder, example “/urho_project”.
Inside this folder I have a “/bin” folder and a “/src” folder.
And from the docs a "CMakeLists.txt"
as well, I have this script, that I call "/link.sh"
So I have so far:
[ul]
/urho_project
/urho_project/bin
/urho_project/src
/urho_project/link.sh
/urho_project/CMakeLists.txt
[/ul]
Use the script passing in the path to the Urho3D source directory.
sh ./link.sh /Urho3D
Pardon my bash, but it works:
#!/bin/bash
#i need to create a bin folder if it does not exists
#setup.sh /Urho3D_Source
#needs 1 arguents, the urho source folder
make_alias(){
#$1 FOLDER $2 LINKEDFOLDER $3 NEWFOLDER
if [ ! -e $3 ];then
#link does not exist, we can make it
ln -s $2 $3
echo " -"$1" directory LINKED"
else
echo " -"$1" link ALREADY EXISTS"
fi
}
URHOPATH=$1
#first make sure that the given folder is good
if [ $# -eq 0 ];then
echo "***********************************"
echo "no arguments given, please provide:"
echo " -urho source path"
echo "***********************************"
else
if [ -d $URHOPATH ];then
#if [[ ( -d $URHOPATH ) && ( -d $URHOBUILD ) ]];then
echo "***********************************"
echo "linking folders from urho source"
# Absolute path this script is in, thus /home/user/bin
SCRIPT=$(readlink -f "$0")
SCRIPTPATH=$(dirname "$SCRIPT")
#link the data and core data folder
echo " -link CMake, CoreData and Data folders"
make_alias "CMake" $URHOPATH"/CMake" $SCRIPTPATH"/CMake"
make_alias "CoreData" $URHOPATH"/bin/CoreData" $SCRIPTPATH"/bin/CoreData"
make_alias "Data" $URHOPATH"/bin/Data" $SCRIPTPATH"/bin/Data"
echo "***********************************"
echo "create launch editor script"
EDIT=$URHOPATH"/bin/Urho3DPlayer /Scripts/Editor.as -pp "$SCRIPTPATH"/bin -p \"CoreData;Data;Resources\" -w -s"
EFILE=$SCRIPTPATH/editor.sh
if [ -f "$EFILE" ];then
printf "$EDIT" > $EFILE
echo " -editor.sh edited"
else
touch $EFILE
printf "$EDIT" > $EFILE
echo " -editor.sh created"
fi
echo "***********************************"
else
echo "***********************************"
echo "invalid path or paths given:"
echo " -source:" $URHOPATH
echo "***********************************"
fi
fi
What this script does it a few things.
It makes some necessary symbolic links.
[ul]
/urho_project/bin/CoreData
/urho_project/bin/Data"
/urho_project/CMake
[/ul]
Side note: The bash script also creates another bash script called “editor.sh” I do this cause I usually modify it to pass in variables specific to my project as far as renderpaths that I want to editor to use, etc.
For completion, here is my CMakeLists.txt with a modification that searches sub folders in my “/src” directory:
# Set project name
project (your_urho_project_name)
# 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 target name
set (TARGET_NAME urho_project_executable_name)
# Define source files
#define_source_files (GLOB_CPP_PATTERNS src/*.cpp src/*.cc GLOB_H_PATTERNS src/*.h)
define_source_files (GLOB_CPP_PATTERNS src/*.c* GLOB_H_PATTERNS src/*.h* RECURSE GROUP )
# Setup target with resource copying
setup_main_executable ()
special attentions to the lines:
project (your_urho_project_name)
set (TARGET_NAME urho_project_executable_name)
Add your code to src, and that should do it. It does it for me anyway.