Project

General

Profile

Start to build Scol using CMAKE » History » Version 44

lpousse, 10/14/2019 11:26 AM
Delete instruction about ANT, JDK and Perl for Android. They should not be necessary anymore for Android, but it might be a mistake

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 42 lpousse
* "MSYS2":https://www.msys2.org/ (once installed, launch 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 42 lpousse
h3. Android target from Windows
27 1 arkeon
28 42 lpousse
* "Android Studio":https://developer.android.com/studio
29
Launch Android Studio and go to File > Settings > Appearance & Behaviour > System Settings > Android SDK. In the SDK Tools tab, check the LLDB, CMake and NDK (not "NDK(Side by side)") boxes to install these components
30
* "MSYS2":https://www.msys2.org/ (once installed, launch msys2.exe and install make with the command "pacman -S make")
31 20 brainsandwich
32 42 lpousse
Our target API is 19.
33 20 brainsandwich
34
h3. Linux target
35
36 30 arkeon
TODO.
37 20 brainsandwich
38
h3. Mac OS target
39
40 31 arkeon
TODO.
41 20 brainsandwich
42 7 brainsandwich
h2. Get the Scol sources
43 1 arkeon
44 20 brainsandwich
Scol uses Subversion for source control and you can use your SVN client to get the source code.
45 6 arkeon
46 1 arkeon
So first retrieve the sources from "https://svn.scolring.org/trunk/", accept the certificate and go take some coffee.
47
The source directories contains most of the dependencies, and since some of them are modified they are provided in the sources.
48 7 brainsandwich
49 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
50 7 brainsandwich
51 20 brainsandwich
52
53 1 arkeon
h2. Dependencies search paths
54 8 brainsandwich
55 1 arkeon
h3. Windows
56
57
Once you get the sources, you can execute "setWindowsSearchPaths.bat" in the dependencies directory.
58
!!WARNING!! when you execute the bat file using the mouse the current directory is wrong.
59
You need to start a DOS command line "cmd.exe" as administrator and go to the dependencies directory to start the bat file manually.
60
 
61
This will add needed environment variables and paths.
62
63 40 lpousse
Additionally, you need to add the folders where you installed Nasm and Yasm to your Path environment variable
64
65 1 arkeon
h3. Android
66
67 43 lpousse
Add these variables to the environment variables
68 1 arkeon
* ANDROID_HOME : path/to/sdk
69
* ANDROID_SDK_HOME : path/to/sdk
70
* ANDROID_SDK : path/to/sdk
71
* ANDROID_NDK : path/to/ndk
72
* CMAKE : path/to/cmake
73
74 7 brainsandwich
Then you should add these variables into the PATH:
75 20 brainsandwich
76 44 lpousse
@%ANDROID_NDK%;%ANDROID_SDK%\tools;%ANDROID_SDK%\platform-tools;%CMAKE%;@
77 1 arkeon
78 36 arkeon
79
80 1 arkeon
81 36 arkeon
h2. Build needed dependencies
82
83 32 arkeon
h3. From Windows, for Windows
84 1 arkeon
85 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.
86 39 lpousse
87 1 arkeon
Launch cmake-gui from a Visual Studio command line (it configures the environment so you can build things correctly)
88 22 hector
# Specify the source folder to trunk/dependencies and the build to trunk/dependencies/build/windows/x86
89 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.
90 1 arkeon
91
You will see a list of categories, under which are variables to tweak build parameters.
92
The category SCOLDEPS contains CMake variables that enable/disable the build of individual SCOL dependencies.
93
Some of these dependencies depend on one or several others. Since CMake needs to detect these "sub-dependencies" when configuring,
94 21 hector
we need to make several build passes, in order to build said "sub-dependencies" before the dependencies that depend on them.
95
96
# Leave all variables at their default values.
97
# Keep hitting Configure until no variables are highlighted in red.
98 1 arkeon
# Hit Generate to generate a Visual Studio project.
99
# Build the project in Visual Studio (Build->Batch Build, check debug and release for "INSTALL" configuration).
100 39 lpousse
# When the build is done, in CMake, check HYDRAX and SKYX under SCOLDEPS (leave the other variables as they are).
101 21 hector
# Hit Configure again. When configuring is done, you will see new variables appear in red. Leave them at their default values.
102 1 arkeon
# Repeat steps 2 to 4.
103
# HYDRAX / SKYX build might fail due to header conflicts. To solve them, in Visual Studio :
104
## In the solution explorer, open the properties of the *RenderSystem_Direct3D11* project.
105
## In the properties window, Select *All configurations*.
106 25 hector
## Under *Configuration Properties* > *C/C++* > *General*, modify the *Other include directories* entry.
107 39 lpousse
## In the directories list, move the directory at the bottom all the way to the top.
108 38 aurelio
## Save the changes.
109 39 lpousse
## Repeat the same steps for the *RenderSystem_Direct3D9* project.
110
## Re-run the build.
111
# Optionnal: Check SCOLDEPS_BUILD_TUIO and SCOLDEPS_BUILD_TUIO, hit configure and repeat steps 2 to 4.
112
113 26 hector
Now every required dependency should be built. The ones that we left unchecked aren't needed.
114
115
h3. From Windows, for Android
116
117 39 lpousse
Supported ABIs : armeabi-v7a, arm64-v8a, x86, x86_64
118
Android API version : 19 (21 for 64 bits ABIs)
119
120 7 brainsandwich
Do the same as for Windows target, but
121 39 lpousse
* If you did not already make a Windows build, run trunk/dependencies/boost/bootstrap.bat from a Visual Studio command line
122 1 arkeon
* 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>")
123
* Specify the generator : "NMake"
124
* The toolchain for crosscompile : trunk/dependencies/CMake/toolchain/android.<target ABI>.toolchain.cmake
125 20 brainsandwich
* When building the Scol dependencies uncheck CAUDIO_ENABLE_REROUTE_STL_ALLOCATIONS
126 39 lpousse
* Build dependencies with "nmake install" command from a Visual Studio command line.
127
128
129
130 13 brainsandwich
131
h2. Build the Scol project
132 19 brainsandwich
133 20 brainsandwich
As for the dependencies:
134 1 arkeon
135 40 lpousse
h3. Windows target
136 20 brainsandwich
137
* Set source folder to trunk/scol and build folder to trunk/scol/build/windows/x86
138
* Hit configure and provide the toolchain, the same as for the dependencies
139
* Generate and build from Visual Studio
140
141
h3. Android target
142
143 42 lpousse
* Open the project in trunk/scol/android with Android Studio
144
* Sync Gradle files (Files > Sync Project with Gradle Files)
145
* Launch the build with Build > Make Project
146 1 arkeon
147
h1. Start your new plugin
148
149
h2. Source paths
150
151
Start by creating a directory with your new plugin name in the trunk/scol/plugins folder.
152
For example trunk/scol/plugins/myPlugin
153 4 arkeon
154
Usually we prefer to separate the sources and the includes.
155 1 arkeon
So creates a "src" and "include" directory in your plugin folder.
156
157
Creates the empty files you will need for your project, usually :
158
- include/myplugin.h for your classes declaration
159
- src/myplugin.cpp for your classes definition
160
- src/scolplugin.cpp for the Scol binding functions
161
162
h2. Dependencies
163
164
If your project need an external SDK or dependencies, add then in the trunk/dependencies directory.
165
Then create a findMydepname.cmake file in trunk\scol\CMake\Packages.
166
You can copy and change an existing Find.cmake file to make yours.
167
Start from a simple one like FindMyo.cmake for example.
168
169
h2. Cmake files
170
171
It's time to creates the CMAKE script for your plugin.
172
173
Create a "CMakeLists.txt" file in the plugin directory.
174
trunk/scol/plugins/myPlugin/CMakeLists.txt
175
176
And edit the file with a text editor.
177
178
<pre>
179
#-------------------------------------------------------------------
180
# This file is part of the CMake build system for Scol
181
#
182
# The contents of this file are placed in the public domain. Feel
183
# free to make use of it in any way you like.
184
#-------------------------------------------------------------------
185
186
############################################################
187
# CmakeList file for Myplugin
188
############################################################
189
190
#Your project name
191
PROJECT(myPLugin)
192
193
# define header and source files for the library
194
set (MYPLUGIN_HEADER_FILES
195
  include/myplugin.h
196
)
197
198
set (MYPLUGIN_SOURCE_FILES
199
  src/myplugin.cpp
200
  src/scolplugin.cpp
201
)
202
203
# Add includes directories from dependencies
204
#  include_directories(include ${MYDEP_INCLUDE_DIRS})
205
206
# Add definition for P4 optimizations, warnings removal.
207
add_definitions(-DOPTI_P4 -D_CRT_SECURE_NO_WARNINGS -D)
208
209
# Add dependencies libraries
210
#  set(LIBRARIES
211
#    ${MYDEP_LIBRARIES}
212
#    ${ZLIB_LIBRARIES}
213
#    ${PNG_LIBRARIES}
214
#  )
215
216
# setup Scol plugin target
217
add_library(myPLugin
218
  ${Scol_LIB_TYPE}
219
  ${MYPLUGIN_HEADER_FILES}
220
  ${MYPLUGIN_SOURCE_FILES}
221
)
222
add_dependencies(myPLugin kernel)
223
224
# set the dll version.
225
set_target_properties(myPLugin PROPERTIES VERSION ${Scol_VERSION} SOVERSION ${Scol_VERSION_MAJOR})
226
target_link_libraries(myPLugin ${LIBRARIES})
227
228
# install Scol
229
scol_config_plugin(myPLugin)
230
install(FILES ${MYPLUGIN_HEADER_FILES} DESTINATION include/SCOL/plugins/myPLugin)
231
</pre>
232
233
Now we need to declare this new plugin in the common Scol cmake files.
234
Edit the trunk/scol/CMakeLists.txt file and add your plugin definition like the following.
235
236
If you don't have dependencies.
237
<pre>
238
option(Scol_BUILD_MYPLUGIN "Build myPluginplugin, my library" TRUE)
239
</pre>
240
241
If you have depencies
242
<pre>
243
cmake_dependent_option(Scol_BUILD_MYPLUGIN "Build myPlugin, my library." TRUE "MYDEP_FOUND;ZLIB_FOUND;PNG_FOUND" FALSE)
244
</pre>
245
246
Now edit the trunk/scol/plugin/CMakeLists.txt file and add the following.
247
<pre>
248
# Configure myPlugin plugin build
249
if (Scol_BUILD_MYPLUGIN)
250
  add_subdirectory(myPlugin)
251
endif ()
252
</pre>
253
254
Only if you have dependencies, edit the trunk/scol/CMake/ScolDependencies.cmake file and add the dependencies resolution as the following
255
256
<pre>
257
# Find MyDep
258
find_package(MYDEP)
259
macro_log_feature(MYDEP_FOUND "Mydep" "MydepLibrary" "http://Mydep.org/" FALSE "" "")
260
</pre>
261
262
h2. Almost done
263
264
Open the CMAKE-gui again.
265
Hit the "Configure button" and check if you found your plugin in the scol group.
266
Then hit the generate button, and open the scol.sln project again.
267
268
You should have the project added in Visual Studio.