Start to build Scol using CMAKE » History » Revision 20
« Previous |
Revision 20/45
(diff)
| Next »
brainsandwich, 06/29/2015 04:44 PM
Start to build Scol using CMAKE¶
Tools¶
Common to all platforms¶
- CMake
- Visual Studio (not free)
- Tortoise SVN (or any SVN client)
- Tortoise git (or any Git client too)
Windows target¶
The minimum compiler supported is the one in Visual Studio 2010.
You can try with a newer version at your own risks !
Android target¶
With standard tools
i.e. free tools found on the web or provided by Google
With Tegra Android Development Pack
A package provided by Nvidia to build applications for Android. The download process requires authentication to the Nvidia Developper Network (it's free and not too spammy though)
- TADP
- On setup, let it download everything or at least the tools described in the previous section.
SDK preparation
You should launch the SDK to download other tools like emulators for each API you want to target.
(Our target API is 17 so you can get any emulator above).
Linux target¶
Not supported yet.
Mac OS target¶
Not supported yet.
Get the Scol sources¶
Scol uses Subversion for source control and you can use your SVN client 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 sources like curl use Git as source control and are downloaded when building, so make sure it's installed before building the project
Dependencies search paths¶
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.
Android¶
If you downloaded the TADP, the following variables are likely to be defined already (or they should look alike).If not, add these to the environment 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:
%ANDROID_NDK%;%ANT_HOME%\bin;%ANDROID_SDK%\tools;%ANDROID_SDK%\platform-tools;%CMAKE%;%JAVA_HOME%\bin;
Build needed dependencies¶
From Windows, for Windows¶
1. Launch cmake-gui from a Visual Studio command line (it configures environment so you can build things correctly)
2. Specify the source folder 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 to set up
5. Configure again
6. Generate
7. Build the project in Visual Studio (Build->Batch Build, check debug and release for "INSTALL" configuration)
8. Wait for completion
9. Read the start of the output of "CMake configure" and do as it says (it says you have to check/uncheck some "SCOL_" configuration variables)
10. Repeat steps 4 to 8 until everything's built
From Windows, for Android¶
Do the same as for Windows target, but- Set source folder to trunk/dependencies and build folder to trunk/scol/build/android/<target abi>
- Specify the generator : "NMake"
- The toolchain for crosscompile : trunk/dependencies/CMake/toolchain/android.toolchain.cmake
- Build dependencies with "nmake install" command from a command line.
Build the Scol project¶
As for the dependencies:
Windows target¶
- Set source folder to trunk/scol and build folder to trunk/scol/build/windows/x86
- Configure, generate and build from Visual Studio
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), some build paramaters should be modified for each build if you want to install and test 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" if you wish to install the project on an emulator or your device
Start your new plugin¶
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
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.
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.
#------------------------------------------------------------------- # 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)
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.
option(Scol_BUILD_MYPLUGIN "Build myPluginplugin, my library" TRUE)
If you have depencies
cmake_dependent_option(Scol_BUILD_MYPLUGIN "Build myPlugin, my library." TRUE "MYDEP_FOUND;ZLIB_FOUND;PNG_FOUND" FALSE)
Now edit the trunk/scol/plugin/CMakeLists.txt file and add the following.
# Configure myPlugin plugin build if (Scol_BUILD_MYPLUGIN) add_subdirectory(myPlugin) endif ()
Only if you have dependencies, edit the trunk/scol/CMake/ScolDependencies.cmake file and add the dependencies resolution as the following
# Find MyDep find_package(MYDEP) macro_log_feature(MYDEP_FOUND "Mydep" "MydepLibrary" "http://Mydep.org/" FALSE "" "")
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.
Updated by brainsandwich over 9 years ago · 20 revisions