Project

General

Profile

Start to build Scol using CMAKE » History » Revision 20

Revision 19 (brainsandwich, 06/29/2015 03:03 PM) → Revision 20/45 (brainsandwich, 06/29/2015 04:44 PM)

h1. Start to build Scol using CMAKE 


 

 h2. Tools 

 h3. Common to Prepare all platforms the necessary tools 

 * "CMake":http://www.cmake.org/download/ 
 * Visual Studio (not free) 
 * "Tortoise SVN":http://tortoisesvn.net/ (or Before going any SVN client) 
 * "Tortoise git":https://code.google.com/p/tortoisegit/ (or any Git client too) further, you should take care of having everything ready for the builds. 

 h3. Windows target 

 The minimum compiler supported On Windows, the Scol project is the one in built with CMake and Visual Studio 2010. 
 

 * You can try with get CMake freely at http://www.cmake.org/download/ 
 * However Visual Studio 2010 is not free. If you don't have it you can still get Visual Studio 2010 express at https://www.visualstudio.com/downloads/download-visual-studio-vs (there is VS 2010 express down the page) or the complete edition by -getting the torrent- having a good friend who still has the software at home. Because as far as I know you can't even buy it anymore. Hopefully the express edition should suffice. Eventually the build will migrate to a newer version at your own risks ! VS edition (like VS 2013 community edition, which is free as soon as you are not doing commercial products). 

 It should be about it. 

 h3. Android target 

 _With standard tools_ 

 i.e. free tools found on On Android you need to download more stuff. The configurator is also CMake but you can build the web or final project with almost anything. 
 At I-Maginer we're using Visual Studio 2013 community edition with some Nvidia plugins, and NMake (which is provided by Google any version of Visual Studio). 

 First thing is then to download CMake and a version of Visual Studio that suits you. 

 When it's done, you have got 2 options : either you want to rely on Visual Studio or only on NMake manual commands. 

 * "Java If you opted for the first choice, it's quite simple, just go to https://developer.nvidia.com/gameworksdownload and download the Tegra Android Development Kit (JDK)":http://www.oracle.com/technetwork/java/javase/downloads Pack (TADP). It contains all you need to develop for android targets, available on Windows, Linux and Mac OS platforms. It will add the Visual Studio "Nsight Tegra" plugin, the android SDK and NDK and all the environment variables you'll need. 
 * "Android SDK":https://developer.android.com/sdk/installing If you chosed the second choice, well, it's the way of the hero. 
 * "Native ¤ Download the JDK (Java Development Kit (NDK)":https://developer.android.com/tools/sdk/ndk Kit) at http://www.oracle.com/technetwork/java/javase/downloads 
 * "Apache ANT":http://ant.apache.org/ 

 _With Tegra ¤ Fetch the Android SDK (Software Development Pack_ 

 A package provided by Nvidia to build applications Kit) at https://developer.android.com/sdk/installing and go for Android. The download process requires authentication to "Stand-Alone SDK tools" -- when it's done, extract the Nvidia Developper Network (it's free content and not too spammy though) 

 * "TADP":https://developer.nvidia.com/gameworksdownload 
 * On setup, let put it download everything or at least the tools described in some memorable folder where you keep your dev SDK 
 ¤ Same for the previous section. 

 _SDK preparation_ 

 You should launch Android NDK (Native Development Kit) at https://developer.android.com/tools/sdk/ndk 
 ¤ Finally get the SDK ANT (Another Neat Tool) build system at http://ant.apache.org/ 
 Now everything is downloaded, there's one last thing to download other tools like emulators for each API you want to target. do : 
 (Our target API is 17 so you ¤ Launch the Android SDK (you can get any emulator above). 

 h3. Linux target 

 Not supported yet. 

 h3. Mac OS target 

 Not supported yet. 


 find it in your Android SDK folder) and let it download all the things it wants. 

 h2. Get the Scol sources 

 Scol uses Subversion for source control and you can use your SVN client "Tortoise SVN":http://tortoisesvn.net/ to get the source code. 

 So first retrieve the sources from "https://svn.scolring.org/trunk/", accept the certificate and go take some coffee. 
 The source directories contains most of the dependencies, and since some of them are modified they are provided in the sources. 

 Some The curl sources like curl use Git as source control and are downloaded when building, so make sure it's installed before building via git however. You can use "Tortoise git":https://code.google.com/p/tortoisegit/ or the project 



 "git":https://git-scm.com/ utility itself. 
 When you have your tool ready, go to the dependencies folder and clone the "Curl Repository":https://github.com/bagder/curl into a "curl" folder. 

 h2. Dependencies search paths 

 h3. Windows 

 Once you get the sources, you can execute "setWindowsSearchPaths.bat" in the dependencies directory. 
 !!WARNING!! when you execute the bat file using the mouse the current directory is wrong. 
 You need to start a DOS command line "cmd.exe" as administrator and go to the dependencies directory to start the bat file manually. 
 
 This will add needed environment variables and paths. 

 h3. Android 

 If (Don't take care about this if you downloaded the TADP, TADP thing) 
 For Android build on Windows, there's no such bat file for the following variables are likely moment (sorry). You will have to be defined already (or they should look alike). 
 If not, add these to put the environment variables 
 yourself. Right click on Computer -> Properties (in file explorer for example) -> System Parameters -> Environment Variables 
 Then add these entries (into "system variables") : 
 * ANDROID_HOME : path/to/sdk 
 * ANDROID_SDK_HOME : path/to/sdk 
 * ANDROID_SDK : path/to/sdk 
 * ANDROID_NDK : path/to/ndk 
 * ANT_HOME : path/to/ant 
 * JAVA_HOME : path/to/jdk -- should be something like "C:\Progra~1\Java\<jdkfolder>" 
 * CMAKE : path/to/cmake 

 Then you should add these variables into the PATH: PATH one (you can copy pasta the following) : 

 @%ANDROID_NDK%;%ANT_HOME%\bin;%ANDROID_SDK%\tools;%ANDROID_SDK%\platform-tools;%CMAKE%;%JAVA_HOME%\bin;@ 




 

 h2. Build needed dependencies 

 h3. From Windows, for Windows Most of the configure/build process is automated, but there is little manual actions to do. 

 1. Launch First either launch cmake-gui from a Visual Studio command line (it configures (very important, Visual Studio command line adds environment so variables important for a correct configuration) or prepare to run cmake from a command line if you can build things correctly) 
 2. Specify are on Linux (or just a command-line masochist -- as I am but not enough for this huge project). 

 In cmake-gui, set the source folder sources directory to trunk/dependencies and the build to trunk/dependencies/build/windows/x86 
 3. Hit configure, specifying no toolchain, using your Visual Studio version as generator. 
 4. Wait for things trunk/dependencies/build/<target OS>/<target platform> and hit the "configure" button. Then you're asked to set up 
 5. Configure again 
 6. Generate 
 7. Build the project in Visual Studio (Build->Batch Build, check debug generator to build the project, set "NMake makefiles" and release select "specify toolchain for "INSTALL" configuration) 
 8. Wait for completion 
 9. Read cross-compiling". Then set the start toolchain path to "~/trunk/dependencies/CMake/toolchain/android.toolchain.cmake" if you're building with standard tools, "~/trunk/dependencies/CMake/toolchain/android.nsight.toolchain.cmake" if you're using the TADP. 

 After a moment, there should be lots of red variables on the output of "CMake configure" gui. Don't change anything, hit configure again and do as it says (it says you have finally "generate". Now go to check/uncheck some "SCOL_" configuration variables) 
 10. Repeat steps 4 the build folder and open the SCOLDEPS.sln if your on windows or take your terminal window, go to 8 until everything's built the build folder and run @nmake install@. If you're not doing the build on an IBM supercluster, you should go take another coffee. 

 h3. From Windows, for Android When it's done, come check back on cmake-gui. Now look into "SCOLDEPS" variables and turn on libPng, curl, OpenAL and Ogre. Same as before, build the newly generated project and -seriously make us a call if you're doing this with a supercomputer and tell us how Scol's doing on that beast.- 

 Do Finally, check once again the same as for Windows target, but 
 * Set source folder cmake-gui and tell it to trunk/dependencies build SkyX, HydraX and build folder to trunk/scol/build/android/<target abi> 
 * Specify CAUDIO. Now it's okay, the generator : "NMake" 
 * The toolchain for crosscompile : trunk/dependencies/CMake/toolchain/android.toolchain.cmake 
 * Build dependencies with "nmake install" command from a command line. 




 are ready. 

 h2. Build the Scol project 

 As for >But wait, there's more ! 

 Now you can do the dependencies: 

 h3. Windows target 

 * thing with Scol itself. Set source folder the sources directory of cmake-gui to trunk/scol and build folder the output to trunk/scol/build/windows/x86 
 * Configure, generate trunk/build/<target OS>/<target platform> and hit configure + generate. Build the project using nmake in the build from Visual Studio 

 h3. Android target 

 * Set source folder to trunk/scol and build folder to trunk/scol/build/android/<target abi> 
 * If you're using Nsight with Visual Studio (TADP), folder. You can go bake some build paramaters should be modified for each build if you want to install and test pie until it's done (just prepare the project on a device : 
   - Open ScolLauncher subproject -> properties 
   - Configuration Properties -> General -> Configuration Type -> Make Application (ndk-build -> .apk|.so|.a) 
   - Configuration Properties -> Deployment -> Fast Deploy -> No 
   - Configuration Properties -> Ant Build -> Skip Ant Step -> No 
 * Without TADP, after it's build, go to trunk/scol/build/android/<target abi>/App/bin, and run "ant debug install" recipy in your head if you wish to install you've got the project on an emulator supercomputer). 

 The compiled binaries are exported under trunk/scol_sdk/bin/Release or your device   

 Debug. 

 h1. Start your new plugin 

 h2. Source paths 

 Start by creating a directory with your new plugin name in the trunk/scol/plugins folder. 
 For example trunk/scol/plugins/myPlugin 

 Usually we prefer to separate the sources and the includes. 
 So creates a "src" and "include" directory in your plugin folder. 

 Creates the empty files you will need for your project, usually : 
 - include/myplugin.h for your classes declaration 
 - src/myplugin.cpp for your classes definition 
 - src/scolplugin.cpp for the Scol binding functions 

 h2. Dependencies 

 If your project need an external SDK or dependencies, add then in the trunk/dependencies directory. 
 Then create a findMydepname.cmake file in trunk\scol\CMake\Packages. 
 You can copy and change an existing Find.cmake file to make yours. 
 Start from a simple one like FindMyo.cmake for example. 

 h2. Cmake files 

 It's time to creates the CMAKE script for your plugin. 

 Create a "CMakeLists.txt" file in the plugin directory. 
 trunk/scol/plugins/myPlugin/CMakeLists.txt 

 And edit the file with a text editor. 

 <pre> 
 #------------------------------------------------------------------- 
 # This file is part of the CMake build system for Scol 
 # 
 # The contents of this file are placed in the public domain. Feel 
 # free to make use of it in any way you like. 
 #------------------------------------------------------------------- 

 ############################################################ 
 # CmakeList file for Myplugin 
 ############################################################ 

 #Your project name 
 PROJECT(myPLugin) 

 # define header and source files for the library 
 set (MYPLUGIN_HEADER_FILES 
   include/myplugin.h 
 ) 

 set (MYPLUGIN_SOURCE_FILES 
   src/myplugin.cpp 
   src/scolplugin.cpp 
 ) 

 # Add includes directories from dependencies 
 #    include_directories(include ${MYDEP_INCLUDE_DIRS}) 

 # Add definition for P4 optimizations, warnings removal. 
 add_definitions(-DOPTI_P4 -D_CRT_SECURE_NO_WARNINGS -D) 

 # Add dependencies libraries 
 #    set(LIBRARIES 
 #      ${MYDEP_LIBRARIES} 
 #      ${ZLIB_LIBRARIES} 
 #      ${PNG_LIBRARIES} 
 #    ) 

 # setup Scol plugin target 
 add_library(myPLugin 
   ${Scol_LIB_TYPE} 
   ${MYPLUGIN_HEADER_FILES} 
   ${MYPLUGIN_SOURCE_FILES} 
 ) 
 add_dependencies(myPLugin kernel) 

 # set the dll version. 
 set_target_properties(myPLugin PROPERTIES VERSION ${Scol_VERSION} SOVERSION ${Scol_VERSION_MAJOR}) 
 target_link_libraries(myPLugin ${LIBRARIES}) 

 # install Scol 
 scol_config_plugin(myPLugin) 
 install(FILES ${MYPLUGIN_HEADER_FILES} DESTINATION include/SCOL/plugins/myPLugin) 
 </pre> 

 Now we need to declare this new plugin in the common Scol cmake files. 
 Edit the trunk/scol/CMakeLists.txt file and add your plugin definition like the following. 

 If you don't have dependencies. 
 <pre> 
 option(Scol_BUILD_MYPLUGIN "Build myPluginplugin, my library" TRUE) 
 </pre> 

 If you have depencies 
 <pre> 
 cmake_dependent_option(Scol_BUILD_MYPLUGIN "Build myPlugin, my library." TRUE "MYDEP_FOUND;ZLIB_FOUND;PNG_FOUND" FALSE) 
 </pre> 

 Now edit the trunk/scol/plugin/CMakeLists.txt file and add the following. 
 <pre> 
 # Configure myPlugin plugin build 
 if (Scol_BUILD_MYPLUGIN) 
   add_subdirectory(myPlugin) 
 endif () 
 </pre> 

 Only if you have dependencies, edit the trunk/scol/CMake/ScolDependencies.cmake file and add the dependencies resolution as the following 

 <pre> 
 # Find MyDep 
 find_package(MYDEP) 
 macro_log_feature(MYDEP_FOUND "Mydep" "MydepLibrary" "http://Mydep.org/" FALSE "" "") 
 </pre> 

 h2. Almost done 

 Open the CMAKE-gui again. 
 Hit the "Configure button" and check if you found your plugin in the scol group. 
 Then hit the generate button, and open the scol.sln project again. 

 You should have the project added in Visual Studio.