Project

General

Profile

Start to build Scol using CMAKE » History » Version 6

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