Project

General

Profile

Start to build Scol using CMAKE » History » Version 9

brainsandwich, 05/20/2015 02:50 PM

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