Project

General

Profile

Start to build Scol using CMAKE » History » Version 10

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