Project

General

Profile

Start to build Scol using CMAKE » History » Version 39

lpousse, 04/02/2019 03:41 PM

1 1 arkeon
h1. Start to build Scol using CMAKE
2
3
4 20 brainsandwich
h2. Tools
5 1 arkeon
6 20 brainsandwich
h3. Common to all platforms
7 1 arkeon
8 39 lpousse
* "CMake":http://www.cmake.org/download/ (While installing, allow CMake to add the CMake directory to the PATH)
9
* Visual Studio Community 2015 Update 3
10 20 brainsandwich
* "Tortoise SVN":http://tortoisesvn.net/ (or any SVN client)
11
* "Tortoise git":https://code.google.com/p/tortoisegit/ (or any Git client too)
12 1 arkeon
13
h3. Windows target
14
15 39 lpousse
* "DirectX9 SDK:https://www.microsoft.com/en-us/download/details.aspx?id=6812
16
If the installation fails: https://support.microsoft.com/fr-fr/help/2728613/s1023-error-when-you-install-the-directx-sdk-june-2010
17
* a Perl installation (such as "Strawberry Perl":http://strawberryperl.com/)
18
Be careful not to let Perl add paths to c headers and executables to your path as it can mess with your build environnement
19
20
The minimum compiler supported is the one in Visual Studio 2015.
21 20 brainsandwich
You can try with a newer version at your own risks !
22 1 arkeon
23 20 brainsandwich
h3. Android target
24 1 arkeon
25 20 brainsandwich
_With standard tools_
26 1 arkeon
27 20 brainsandwich
i.e. free tools found on the web or provided by Google
28 1 arkeon
29 20 brainsandwich
* "Java Development Kit (JDK)":http://www.oracle.com/technetwork/java/javase/downloads
30
* "Android SDK":https://developer.android.com/sdk/installing
31
* "Native Development Kit (NDK)":https://developer.android.com/tools/sdk/ndk
32
* "Apache ANT":http://ant.apache.org/
33 1 arkeon
34 20 brainsandwich
_With Tegra Android Development Pack_
35 10 brainsandwich
36 20 brainsandwich
A package provided by Nvidia to build applications for Android. The download process requires authentication to the Nvidia Developper Network (it's free and not too spammy though)
37
38
* "TADP":https://developer.nvidia.com/gameworksdownload
39
* On setup, let it download everything or at least the tools described in the previous section.
40 1 arkeon
41 20 brainsandwich
_SDK preparation_
42
43
You should launch the SDK to download other tools like emulators for each API you want to target.
44 39 lpousse
(Our target API is 19 so you can get any emulator above).
45 20 brainsandwich
46
h3. Linux target
47
48 30 arkeon
TODO.
49 20 brainsandwich
50
h3. Mac OS target
51
52 31 arkeon
TODO.
53 20 brainsandwich
54 7 brainsandwich
h2. Get the Scol sources
55 1 arkeon
56 20 brainsandwich
Scol uses Subversion for source control and you can use your SVN client to get the source code.
57 6 arkeon
58 1 arkeon
So first retrieve the sources from "https://svn.scolring.org/trunk/", accept the certificate and go take some coffee.
59
The source directories contains most of the dependencies, and since some of them are modified they are provided in the sources.
60 7 brainsandwich
61 20 brainsandwich
Some sources like curl use Git as source control and are downloaded when building, so make sure it's installed before building the project
62 7 brainsandwich
63 20 brainsandwich
64
65 1 arkeon
h2. Dependencies search paths
66 8 brainsandwich
67 1 arkeon
h3. Windows
68
69
Once you get the sources, you can execute "setWindowsSearchPaths.bat" in the dependencies directory.
70
!!WARNING!! when you execute the bat file using the mouse the current directory is wrong.
71
You need to start a DOS command line "cmd.exe" as administrator and go to the dependencies directory to start the bat file manually.
72
 
73
This will add needed environment variables and paths.
74
75
h3. Android
76
77 20 brainsandwich
If you downloaded the TADP, the following variables are likely to be defined already (or they should look alike).
78
If not, add these to the environment variables
79 1 arkeon
* ANDROID_HOME : path/to/sdk
80
* ANDROID_SDK_HOME : path/to/sdk
81
* ANDROID_SDK : path/to/sdk
82
* ANDROID_NDK : path/to/ndk
83
* ANT_HOME : path/to/ant
84 7 brainsandwich
* JAVA_HOME : path/to/jdk -- should be something like "C:\Progra~1\Java\<jdkfolder>"
85 1 arkeon
* CMAKE : path/to/cmake
86 7 brainsandwich
87 20 brainsandwich
Then you should add these variables into the PATH:
88 1 arkeon
89 20 brainsandwich
@%ANDROID_NDK%;%ANT_HOME%\bin;%ANDROID_SDK%\tools;%ANDROID_SDK%\platform-tools;%CMAKE%;%JAVA_HOME%\bin;@
90 1 arkeon
91 36 arkeon
92
93 1 arkeon
94 36 arkeon
h2. Build needed dependencies
95
96
h3. From Windows, for Windows
97 32 arkeon
98 39 lpousse
To compile for 64 bits Windows, specify the 64 bits toolchain (trunk/dependencies/CMake/toolchain/win64.toolchain.cmake) for each CMake configuration, and replace every instance of "x86" by "x64" in the instructions below
99 37 arkeon
100 39 lpousse
Launch cmake-gui from a Visual Studio command line (it configures the environment so you can build things correctly)
101 22 hector
# Specify the source folder to trunk/dependencies and the build to trunk/dependencies/build/windows/x86
102 39 lpousse
# Hit Configure. In the message box, select your Visual Studio version as generator, and check "Use default native compilers" (for 64 bits, select the 64 bits variant of you VS version, select "Specify toolchain file for cross-compiling" and select the toolchain mentioned above). This first configure will take some time as it will download and compile some of the basic dependencies.
103 1 arkeon
104
You will see a list of categories, under which are variables to tweak build parameters.
105
The category SCOLDEPS contains CMake variables that enable/disable the build of individual SCOL dependencies.
106
Some of these dependencies depend on one or several others. Since CMake needs to detect these "sub-dependencies" when configuring,
107 21 hector
we need to make several build passes, in order to build said "sub-dependencies" before the dependencies that depend on them.
108
109
# Leave all variables at their default values.
110
# Keep hitting Configure until no variables are highlighted in red.
111 1 arkeon
# Hit Generate to generate a Visual Studio project.
112
# Build the project in Visual Studio (Build->Batch Build, check debug and release for "INSTALL" configuration).
113 39 lpousse
# When the build is done, in CMake, check HYDRAX and SKYX under SCOLDEPS (leave the other variables as they are).
114 21 hector
# Hit Configure again. When configuring is done, you will see new variables appear in red. Leave them at their default values.
115 1 arkeon
# Repeat steps 2 to 4.
116
# HYDRAX / SKYX build might fail due to header conflicts. To solve them, in Visual Studio :
117
## In the solution explorer, open the properties of the *RenderSystem_Direct3D11* project.
118
## In the properties window, Select *All configurations*.
119 25 hector
## Under *Configuration Properties* > *C/C++* > *General*, modify the *Other include directories* entry.
120 1 arkeon
## In the directories list, move the directory at the bottom all the way to the top.
121 22 hector
## Save the changes.
122 24 hector
## Repeat the same steps for the *RenderSystem_Direct3D9* project.
123 1 arkeon
## Re-run the build.
124 39 lpousse
# Optionnal: Check SCOLDEPS_BUILD_TUIO and SCOLDEPS_BUILD_TUIO, hit configure and repeat steps 2 to 4.
125 38 aurelio
126 39 lpousse
Almost everything is built with CMAKE, but FFMPEG still need manual process.
127
Check the trunk/dependencies/ffmpeg/sources/README.txt file
128
# sh ffmpeg_build.sh win32 release $SCOL_DEPENDENCIES_PATH/ffmpeg/sources/FFmpeg $SCOL_DEPENDENCIES_PATH/ffmpeg/sdk/windows/x86
129
130 26 hector
Now every required dependency should be built. The ones that we left unchecked aren't needed.
131
132
h3. From Windows, for Android
133
134 39 lpousse
Supported ABIs : armeabi-v7a, arm64-v8a, x86, x86_64
135
Android API version : 19 (21 for 64 bits ABIs)
136
137 7 brainsandwich
Do the same as for Windows target, but
138 39 lpousse
* If you did not already make a Windows build, run trunk/dependencies/boost/bootstrap.bat from a Visual Studio command line
139
* Set source folder to trunk/dependencies and build folder to trunk/scol/build/android/<target ABI> (More generally, replace every instance of "windows/x86" in the build and install paths by "android/<target ABI>")
140 20 brainsandwich
* Specify the generator : "NMake"
141 39 lpousse
* The toolchain for crosscompile : trunk/dependencies/CMake/toolchain/android.<target ABI>.toolchain.cmake
142
* When building the Scol dependencies uncheck CAUDIO_ENABLE_REROUTE_STL_ALLOCATIONS
143
* Build dependencies with "nmake install" command from a Visual Studio command line.
144
* FFmpeg build command line : ./ffmpeg_build.sh android release $SCOL_DEPENDENCIES_PATH/ffmpeg/sources/FFmpeg $SCOL_DEPENDENCIES_PATH/ffmpeg/sdk/android/<target ABI> $ANDROID_NDK <Android API version> <target ABI> $SCOL_DEPENDENCIES_PATH/sdk/android/<target ABI>
145 13 brainsandwich
146
147 19 brainsandwich
148 20 brainsandwich
149 19 brainsandwich
h2. Build the Scol project
150 13 brainsandwich
151 20 brainsandwich
As for the dependencies:
152 13 brainsandwich
153 20 brainsandwich
h3. Windows target
154 3 arkeon
155 20 brainsandwich
* Set source folder to trunk/scol and build folder to trunk/scol/build/windows/x86
156
* Configure, generate and build from Visual Studio
157
158
h3. Android target
159
160
* Set source folder to trunk/scol and build folder to trunk/scol/build/android/<target abi>
161
* If you're using Nsight with Visual Studio (TADP), some build paramaters should be modified for each build if you want to install and test the project on a device :
162
  - Open ScolLauncher subproject -> properties
163
  - Configuration Properties -> General -> Configuration Type -> Make Application (ndk-build -> .apk|.so|.a)
164
  - Configuration Properties -> Deployment -> Fast Deploy -> No
165
  - Configuration Properties -> Ant Build -> Skip Ant Step -> No
166
* Without TADP, after it's build, go to trunk/scol/build/android/<target abi>/App/bin, and run "ant debug install" if you wish to install the project on an emulator or your device  
167 1 arkeon
168
h1. Start your new plugin
169
170
h2. Source paths
171
172
Start by creating a directory with your new plugin name in the trunk/scol/plugins folder.
173
For example trunk/scol/plugins/myPlugin
174 4 arkeon
175
Usually we prefer to separate the sources and the includes.
176 1 arkeon
So creates a "src" and "include" directory in your plugin folder.
177
178
Creates the empty files you will need for your project, usually :
179
- include/myplugin.h for your classes declaration
180
- src/myplugin.cpp for your classes definition
181
- src/scolplugin.cpp for the Scol binding functions
182
183
h2. Dependencies
184
185
If your project need an external SDK or dependencies, add then in the trunk/dependencies directory.
186
Then create a findMydepname.cmake file in trunk\scol\CMake\Packages.
187
You can copy and change an existing Find.cmake file to make yours.
188
Start from a simple one like FindMyo.cmake for example.
189
190
h2. Cmake files
191
192
It's time to creates the CMAKE script for your plugin.
193
194
Create a "CMakeLists.txt" file in the plugin directory.
195
trunk/scol/plugins/myPlugin/CMakeLists.txt
196
197
And edit the file with a text editor.
198
199
<pre>
200
#-------------------------------------------------------------------
201
# This file is part of the CMake build system for Scol
202
#
203
# The contents of this file are placed in the public domain. Feel
204
# free to make use of it in any way you like.
205
#-------------------------------------------------------------------
206
207
############################################################
208
# CmakeList file for Myplugin
209
############################################################
210
211
#Your project name
212
PROJECT(myPLugin)
213
214
# define header and source files for the library
215
set (MYPLUGIN_HEADER_FILES
216
  include/myplugin.h
217
)
218
219
set (MYPLUGIN_SOURCE_FILES
220
  src/myplugin.cpp
221
  src/scolplugin.cpp
222
)
223
224
# Add includes directories from dependencies
225
#  include_directories(include ${MYDEP_INCLUDE_DIRS})
226
227
# Add definition for P4 optimizations, warnings removal.
228
add_definitions(-DOPTI_P4 -D_CRT_SECURE_NO_WARNINGS -D)
229
230
# Add dependencies libraries
231
#  set(LIBRARIES
232
#    ${MYDEP_LIBRARIES}
233
#    ${ZLIB_LIBRARIES}
234
#    ${PNG_LIBRARIES}
235
#  )
236
237
# setup Scol plugin target
238
add_library(myPLugin
239
  ${Scol_LIB_TYPE}
240
  ${MYPLUGIN_HEADER_FILES}
241
  ${MYPLUGIN_SOURCE_FILES}
242
)
243
add_dependencies(myPLugin kernel)
244
245
# set the dll version.
246
set_target_properties(myPLugin PROPERTIES VERSION ${Scol_VERSION} SOVERSION ${Scol_VERSION_MAJOR})
247
target_link_libraries(myPLugin ${LIBRARIES})
248
249
# install Scol
250
scol_config_plugin(myPLugin)
251
install(FILES ${MYPLUGIN_HEADER_FILES} DESTINATION include/SCOL/plugins/myPLugin)
252
</pre>
253
254
Now we need to declare this new plugin in the common Scol cmake files.
255
Edit the trunk/scol/CMakeLists.txt file and add your plugin definition like the following.
256
257
If you don't have dependencies.
258
<pre>
259
option(Scol_BUILD_MYPLUGIN "Build myPluginplugin, my library" TRUE)
260
</pre>
261
262
If you have depencies
263
<pre>
264
cmake_dependent_option(Scol_BUILD_MYPLUGIN "Build myPlugin, my library." TRUE "MYDEP_FOUND;ZLIB_FOUND;PNG_FOUND" FALSE)
265
</pre>
266
267
Now edit the trunk/scol/plugin/CMakeLists.txt file and add the following.
268
<pre>
269
# Configure myPlugin plugin build
270
if (Scol_BUILD_MYPLUGIN)
271
  add_subdirectory(myPlugin)
272
endif ()
273
</pre>
274
275
Only if you have dependencies, edit the trunk/scol/CMake/ScolDependencies.cmake file and add the dependencies resolution as the following
276
277
<pre>
278
# Find MyDep
279
find_package(MYDEP)
280
macro_log_feature(MYDEP_FOUND "Mydep" "MydepLibrary" "http://Mydep.org/" FALSE "" "")
281
</pre>
282
283
h2. Almost done
284
285
Open the CMAKE-gui again.
286
Hit the "Configure button" and check if you found your plugin in the scol group.
287
Then hit the generate button, and open the scol.sln project again.
288
289
You should have the project added in Visual Studio.