Project

General

Profile

Start to build Scol using CMAKE » History » Version 13

brainsandwich, 05/20/2015 03:46 PM

1 1 arkeon
h1. Start to build Scol using CMAKE
2
3 10 brainsandwich
h2. Prepare all the necessary tools
4
5
Before going any further, you should take care of having everything ready for the builds.
6
7
h3. Windows
8
9
On Windows, the Scol project is built with CMake and Visual Studio 2010.
10
11
* You can get CMake freely at http://www.cmake.org/download/
12
* However Visual Studio 2010 is not free. If you don't have it you can still get Visual Studio 2010 express at https://www.visualstudio.com/downloads/download-visual-studio-vs (there is VS 2010 express down the page) or the complete edition by -getting the torrent- having a good friend who still has the software at home. Because as far as I know you can't even buy it anymore. Hopefully the express edition should suffice. Eventually the build will migrate to a newer VS edition (like VS 2013 community edition, which is free as soon as you are not doing commercial products).
13
14
It should be about it.
15
16
h3. Android
17
18
On Android you need to download more stuff. The configurator is also CMake but you can build the final project with almost anything.
19
At I-Maginer we're using Visual Studio 2013 community edition with some Nvidia plugins, and NMake (which is provided by any version of Visual Studio).
20
21
First thing is then to download CMake and a version of Visual Studio that suits you.
22
23
When it's done, you have got 2 options : either you want to rely on Visual Studio or only on NMake manual commands.
24
25
* If you opted for the first choice, it's quite simple, just go to https://developer.nvidia.com/gameworksdownload and download the Tegra Android Development Pack (TADP). It contains all you need to develop for android targets, available on Windows, Linux and Mac OS platforms. It will add the Visual Studio "Nsight Tegra" plugin, the android SDK and NDK and all the environment variables you'll need.
26
* If you chosed the second choice, well, it's the way of the hero.
27
¤ Download the JDK (Java Development Kit) at http://www.oracle.com/technetwork/java/javase/downloads
28 11 brainsandwich
¤ Fetch the Android SDK (Software Development Kit) at https://developer.android.com/sdk/installing and go for "Stand-Alone SDK tools" -- when it's done, extract the content and put it in some memorable folder where you keep your dev SDK
29 10 brainsandwich
¤ Same for the Android NDK (Native Development Kit) at https://developer.android.com/tools/sdk/ndk
30 1 arkeon
¤ Finally get the ANT (Another Neat Tool) build system at http://ant.apache.org/
31 11 brainsandwich
Now everything is downloaded, there's one last thing to do :
32
¤ Launch the Android SDK (you can find it in your Android SDK folder) and let it download all the things it wants. 
33 9 brainsandwich
34 1 arkeon
h2. Get the Scol sources
35
36
Scol use Subversion for source control and you can use "Tortoise SVN":http://tortoisesvn.net/ to get the source code.
37
38
So first retrieve the sources from "https://svn.scolring.org/trunk/", accept the certificate and go take some coffee.
39
The source directories contains most of the dependencies, and since some of them are modified they are provided in the sources.
40
41
h2. Dependencies search paths
42
43 7 brainsandwich
h3. Windows
44
45 1 arkeon
Once you get the sources, you can execute "setWindowsSearchPaths.bat" in the dependencies directory.
46 7 brainsandwich
!!WARNING!! when you execute the bat file using the mouse the current directory is wrong.
47 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.
48
 
49 1 arkeon
This will add needed environment variables and paths.
50 7 brainsandwich
51
h3. Android
52
53 12 brainsandwich
(Don't take care about this if you downloaded the TADP thing)
54 7 brainsandwich
For Android build on Windows, there's no such bat file for the moment (sorry). You will have to put the environment variables
55 8 brainsandwich
yourself. Right click on Computer -> Properties (in file explorer for example) -> System Parameters -> Environment Variables
56 7 brainsandwich
Then add these entries (into "system variables") :
57
* ANDROID_HOME : path/to/sdk
58
* ANDROID_SDK_HOME : path/to/sdk
59
* ANDROID_SDK : path/to/sdk
60
* ANDROID_NDK : path/to/ndk
61
* ANT_HOME : path/to/ant
62
* JAVA_HOME : path/to/jdk -- should be something like "C:\Progra~1\Java\<jdkfolder>"
63
* CMAKE : path/to/cmake
64
65
Then add these variables into the PATH one (you can copy pasta the following) :
66
67
@%ANDROID_NDK%;%ANT_HOME%\bin;%ANDROID_SDK%\tools;%ANDROID_SDK%\platform-tools;%CMAKE%;%JAVA_HOME%\bin;@
68 1 arkeon
69
h2. Build needed dependencies
70
71 13 brainsandwich
Most of the configure/build process is automated, but there is little manual actions to do.
72
73
First either launch cmake-gui from a Visual Studio command line (very important, Visual Studio command line adds environment variables important for a correct configuration) or prepare to run cmake from a command line if you are on Linux (or just a command-line masochist -- as I am but not enough for this huge project).
74
75
In cmake-gui, set the sources directory to trunk/dependencies and the build to trunk/dependencies/build/<target OS>/<target platform> and hit the "configure" button. After a moment, there should be lots of red variables on the gui. Don't change anything, hit configure again and finally "generate". Now take your terminal window, go to the build folder and run @nmake install@. If you're not doing the build on an IBM supercluster, you should go take another coffee.
76
77
When it's done, come check back on cmake-gui. Now look into "SCOLDEPS" variables and turn on libPng, curl, OpenAL and Ogre. Same as before, build the newly generated project and seriously make us a call if you're doing this with a supercomputer and tell us how Scol's doing on that beast.
78
79
Finally, check once again the cmake-gui and tell it to build SkyX, HydraX and CAUDIO.
80
Now 
81
82
83
84
85 1 arkeon
Most of the dependencies are built for Visual Studio 2010.
86 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.
87 1 arkeon
So this is not needed for the Scol kernel and most of the plugins.
88 5 arkeon
89
Scol Kernel only need Boost dependencies.
90
To build it go to the trunk/dependencies/boost directory.
91
first build the bjam program by launching the bootstrap.bat file.
92
Then you can build Boost using the ScolBoostBuild.bat
93
Now CMake should find it when building Scol.
94 3 arkeon
95
h2. Build the projects using CMAKE 
96 1 arkeon
97
Download and install "CMAKE":http://www.cmake.org/, there is a GUI for windows called "cmake-gui".
98
99
Now launch CMAKE and build the project using the sources and build path, for example :
100
souces : trunk/scol
101
binaries : trunk/scol/build
102
103
Hit the "Configure" button and choose "Visual Studio 10" as project target.
104
Hit "Configure" again until you don't have red lines anymore.
105
106
Then you can hit the "Generate" button.
107
108
h2. Build the sources
109
110
Open the Scol.sln file generated in the trunk/scol/build
111
And finally build the project.
112
113
The compiled binaries are exported under trunk/scol_sdk/bin/Release or Debug.
114
115
116
h1. Start your new plugin
117
118
h2. Source paths
119 2 arkeon
120 1 arkeon
Start by creating a directory with your new plugin name in the trunk/scol/plugins folder.
121
For example trunk/scol/plugins/myPlugin
122
123
Usually we prefer to separate the sources and the includes.
124
So creates a "src" and "include" directory in your plugin folder.
125
126
Creates the empty files you will need for your project, usually :
127 4 arkeon
- include/myplugin.h for your classes declaration
128
- src/myplugin.cpp for your classes definition
129 1 arkeon
- src/scolplugin.cpp for the Scol binding functions
130
131
h2. Dependencies
132
133
If your project need an external SDK or dependencies, add then in the trunk/dependencies directory.
134
Then create a findMydepname.cmake file in trunk\scol\CMake\Packages.
135
You can copy and change an existing Find.cmake file to make yours.
136
Start from a simple one like FindMyo.cmake for example.
137
138
h2. Cmake files
139
140
It's time to creates the CMAKE script for your plugin.
141
142
Create a "CMakeLists.txt" file in the plugin directory.
143
trunk/scol/plugins/myPlugin/CMakeLists.txt
144
145
And edit the file with a text editor.
146
147
<pre>
148
#-------------------------------------------------------------------
149
# This file is part of the CMake build system for Scol
150
#
151
# The contents of this file are placed in the public domain. Feel
152
# free to make use of it in any way you like.
153
#-------------------------------------------------------------------
154
155
############################################################
156
# CmakeList file for Myplugin
157
############################################################
158
159
#Your project name
160
PROJECT(myPLugin)
161
162
# define header and source files for the library
163
set (MYPLUGIN_HEADER_FILES
164
  include/myplugin.h
165
)
166
167
set (MYPLUGIN_SOURCE_FILES
168
  src/myplugin.cpp
169
  src/scolplugin.cpp
170
)
171
172
# Add includes directories from dependencies
173
#  include_directories(include ${MYDEP_INCLUDE_DIRS})
174
175
# Add definition for P4 optimizations, warnings removal.
176
add_definitions(-DOPTI_P4 -D_CRT_SECURE_NO_WARNINGS -D)
177
178
# Add dependencies libraries
179
#  set(LIBRARIES
180
#    ${MYDEP_LIBRARIES}
181
#    ${ZLIB_LIBRARIES}
182
#    ${PNG_LIBRARIES}
183
#  )
184
185
# setup Scol plugin target
186
add_library(myPLugin
187
  ${Scol_LIB_TYPE}
188
  ${MYPLUGIN_HEADER_FILES}
189
  ${MYPLUGIN_SOURCE_FILES}
190
)
191
add_dependencies(myPLugin kernel)
192
193
# set the dll version.
194
set_target_properties(myPLugin PROPERTIES VERSION ${Scol_VERSION} SOVERSION ${Scol_VERSION_MAJOR})
195
target_link_libraries(myPLugin ${LIBRARIES})
196
197
# install Scol
198
scol_config_plugin(myPLugin)
199
install(FILES ${MYPLUGIN_HEADER_FILES} DESTINATION include/SCOL/plugins/myPLugin)
200
</pre>
201
202
Now we need to declare this new plugin in the common Scol cmake files.
203
Edit the trunk/scol/CMakeLists.txt file and add your plugin definition like the following.
204
205
If you don't have dependencies.
206
<pre>
207
option(Scol_BUILD_MYPLUGIN "Build myPluginplugin, my library" TRUE)
208
</pre>
209
210
If you have depencies
211
<pre>
212
cmake_dependent_option(Scol_BUILD_MYPLUGIN "Build myPlugin, my library." TRUE "MYDEP_FOUND;ZLIB_FOUND;PNG_FOUND" FALSE)
213
</pre>
214
215
Now edit the trunk/scol/plugin/CMakeLists.txt file and add the following.
216
<pre>
217
# Configure myPlugin plugin build
218
if (Scol_BUILD_MYPLUGIN)
219
  add_subdirectory(myPlugin)
220
endif ()
221
</pre>
222
223
Only if you have dependencies, edit the trunk/scol/CMake/ScolDependencies.cmake file and add the dependencies resolution as the following
224
225
<pre>
226
# Find MyDep
227
find_package(MYDEP)
228
macro_log_feature(MYDEP_FOUND "Mydep" "MydepLibrary" "http://Mydep.org/" FALSE "" "")
229
</pre>
230
231
h2. Almost done
232
233
Open the CMAKE-gui again.
234
Hit the "Configure button" and check if you found your plugin in the scol group.
235
Then hit the generate button, and open the scol.sln project again.
236
237
You should have the project added in Visual Studio.