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