Project

General

Profile

Start to build Scol using CMAKE » History » Version 5

arkeon, 12/30/2014 05:14 PM

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