Project

General

Profile

Start to build Scol using CMAKE » History » Version 41

lpousse, 10/14/2019 10:27 AM

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