Project

General

Profile

Start to build Scol using CMAKE » History » Version 1

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