Project

General

Profile

Start to build Scol using CMAKE » History » Version 7

brainsandwich, 05/20/2015 02:49 PM

1 1 arkeon
h1. Start to build Scol using CMAKE
2
3
h2. Get the Scol sources
4
5
Scol use Subversion for source control and you can use "Tortoise SVN":http://tortoisesvn.net/ to get the source code.
6
7
So first retrieve the sources from "https://svn.scolring.org/trunk/", accept the certificate and go take some coffee.
8
The source directories contains most of the dependencies, and since some of them are modified they are provided in the sources.
9
10
h2. Dependencies search paths
11
12 7 brainsandwich
h3. Windows
13
14 1 arkeon
Once you get the sources, you can execute "setWindowsSearchPaths.bat" in the dependencies directory.
15 7 brainsandwich
!!WARNING!! when you execute the bat file using the mouse the current directory is wrong.
16 6 arkeon
You need to start a DOS command line "cmd.exe" as administrator and go to the dependencies directory to start the bat file manually.
17
 
18 1 arkeon
This will add needed environment variables and paths.
19 7 brainsandwich
20
h3. Android
21
22
For Android build on Windows, there's no such bat file for the moment (sorry). You will have to put the environment variables
23
yourself. Right click on Computer->Properties (in file explorer for example) ->System Parameters->Environment Variables
24
Then add these entries (into "system variables") :
25
* ANDROID_HOME : path/to/sdk
26
* ANDROID_SDK_HOME : path/to/sdk
27
* ANDROID_SDK : path/to/sdk
28
* ANDROID_NDK : path/to/ndk
29
* ANT_HOME : path/to/ant
30
* JAVA_HOME : path/to/jdk -- should be something like "C:\Progra~1\Java\<jdkfolder>"
31
* CMAKE : path/to/cmake
32
33
Then add these variables into the PATH one (you can copy pasta the following) :
34
35
@%ANDROID_NDK%;%ANT_HOME%\bin;%ANDROID_SDK%\tools;%ANDROID_SDK%\platform-tools;%CMAKE%;%JAVA_HOME%\bin;@
36 1 arkeon
37
h2. Build needed dependencies
38
39
Most of the dependencies are built for Visual Studio 2010.
40 5 arkeon
But some build are too huge to put on the SVN, so you will have to build them manually. This is the case of Ogre3D to build the SO3Engine for example.
41 1 arkeon
So this is not needed for the Scol kernel and most of the plugins.
42 5 arkeon
43
Scol Kernel only need Boost dependencies.
44
To build it go to the trunk/dependencies/boost directory.
45
first build the bjam program by launching the bootstrap.bat file.
46
Then you can build Boost using the ScolBoostBuild.bat
47
Now CMake should find it when building Scol.
48 3 arkeon
49
h2. Build the projects using CMAKE 
50 1 arkeon
51
Download and install "CMAKE":http://www.cmake.org/, there is a GUI for windows called "cmake-gui".
52
53
Now launch CMAKE and build the project using the sources and build path, for example :
54
souces : trunk/scol
55
binaries : trunk/scol/build
56
57
Hit the "Configure" button and choose "Visual Studio 10" as project target.
58
Hit "Configure" again until you don't have red lines anymore.
59
60
Then you can hit the "Generate" button.
61
62
h2. Build the sources
63
64
Open the Scol.sln file generated in the trunk/scol/build
65
And finally build the project.
66
67
The compiled binaries are exported under trunk/scol_sdk/bin/Release or Debug.
68
69
70
h1. Start your new plugin
71
72
h2. Source paths
73 2 arkeon
74 1 arkeon
Start by creating a directory with your new plugin name in the trunk/scol/plugins folder.
75
For example trunk/scol/plugins/myPlugin
76
77
Usually we prefer to separate the sources and the includes.
78
So creates a "src" and "include" directory in your plugin folder.
79
80
Creates the empty files you will need for your project, usually :
81 4 arkeon
- include/myplugin.h for your classes declaration
82
- src/myplugin.cpp for your classes definition
83 1 arkeon
- src/scolplugin.cpp for the Scol binding functions
84
85
h2. Dependencies
86
87
If your project need an external SDK or dependencies, add then in the trunk/dependencies directory.
88
Then create a findMydepname.cmake file in trunk\scol\CMake\Packages.
89
You can copy and change an existing Find.cmake file to make yours.
90
Start from a simple one like FindMyo.cmake for example.
91
92
h2. Cmake files
93
94
It's time to creates the CMAKE script for your plugin.
95
96
Create a "CMakeLists.txt" file in the plugin directory.
97
trunk/scol/plugins/myPlugin/CMakeLists.txt
98
99
And edit the file with a text editor.
100
101
<pre>
102
#-------------------------------------------------------------------
103
# This file is part of the CMake build system for Scol
104
#
105
# The contents of this file are placed in the public domain. Feel
106
# free to make use of it in any way you like.
107
#-------------------------------------------------------------------
108
109
############################################################
110
# CmakeList file for Myplugin
111
############################################################
112
113
#Your project name
114
PROJECT(myPLugin)
115
116
# define header and source files for the library
117
set (MYPLUGIN_HEADER_FILES
118
  include/myplugin.h
119
)
120
121
set (MYPLUGIN_SOURCE_FILES
122
  src/myplugin.cpp
123
  src/scolplugin.cpp
124
)
125
126
# Add includes directories from dependencies
127
#  include_directories(include ${MYDEP_INCLUDE_DIRS})
128
129
# Add definition for P4 optimizations, warnings removal.
130
add_definitions(-DOPTI_P4 -D_CRT_SECURE_NO_WARNINGS -D)
131
132
# Add dependencies libraries
133
#  set(LIBRARIES
134
#    ${MYDEP_LIBRARIES}
135
#    ${ZLIB_LIBRARIES}
136
#    ${PNG_LIBRARIES}
137
#  )
138
139
# setup Scol plugin target
140
add_library(myPLugin
141
  ${Scol_LIB_TYPE}
142
  ${MYPLUGIN_HEADER_FILES}
143
  ${MYPLUGIN_SOURCE_FILES}
144
)
145
add_dependencies(myPLugin kernel)
146
147
# set the dll version.
148
set_target_properties(myPLugin PROPERTIES VERSION ${Scol_VERSION} SOVERSION ${Scol_VERSION_MAJOR})
149
target_link_libraries(myPLugin ${LIBRARIES})
150
151
# install Scol
152
scol_config_plugin(myPLugin)
153
install(FILES ${MYPLUGIN_HEADER_FILES} DESTINATION include/SCOL/plugins/myPLugin)
154
</pre>
155
156
Now we need to declare this new plugin in the common Scol cmake files.
157
Edit the trunk/scol/CMakeLists.txt file and add your plugin definition like the following.
158
159
If you don't have dependencies.
160
<pre>
161
option(Scol_BUILD_MYPLUGIN "Build myPluginplugin, my library" TRUE)
162
</pre>
163
164
If you have depencies
165
<pre>
166
cmake_dependent_option(Scol_BUILD_MYPLUGIN "Build myPlugin, my library." TRUE "MYDEP_FOUND;ZLIB_FOUND;PNG_FOUND" FALSE)
167
</pre>
168
169
Now edit the trunk/scol/plugin/CMakeLists.txt file and add the following.
170
<pre>
171
# Configure myPlugin plugin build
172
if (Scol_BUILD_MYPLUGIN)
173
  add_subdirectory(myPlugin)
174
endif ()
175
</pre>
176
177
Only if you have dependencies, edit the trunk/scol/CMake/ScolDependencies.cmake file and add the dependencies resolution as the following
178
179
<pre>
180
# Find MyDep
181
find_package(MYDEP)
182
macro_log_feature(MYDEP_FOUND "Mydep" "MydepLibrary" "http://Mydep.org/" FALSE "" "")
183
</pre>
184
185
h2. Almost done
186
187
Open the CMAKE-gui again.
188
Hit the "Configure button" and check if you found your plugin in the scol group.
189
Then hit the generate button, and open the scol.sln project again.
190
191
You should have the project added in Visual Studio.