Advertising (This ad goes away for registered users. You can Login or Register)

CMAKE Q

Open discussions on programming specifically for the PS Vita.
Forum rules
Forum rule Nº 15 is strictly enforced in this subforum.
Locked
ivo2376
Posts: 31
Joined: Wed Jan 14, 2015 10:17 pm

CMAKE Q

Post by ivo2376 »

Hello,
ive got a cmake question regarding vitasdk
from a snippet on the web i found

now the question is about the cmake chapter
lets say the library or project is not yaml but adrenaline6 or some other

how do i change or in what do i change the following line if the option is not set so i can still
say the cmake configure not to test cc and cxx
so do iadd option(adrenaline_CPP_BUILD_TOOLS "..." OFF or on ON or really how ...
thanks in advance

We will use yaml-cpp for the example.
Let's open CMakeLists.txt in an editor. Under Project Options, there are two interesting lines:

option(YAML_CPP_BUILD_TOOLS "Enable testing and parse tools" ON)
option(YAML_CPP_BUILD_CONTRIB "Enable contrib stuff in library" ON)

We don't need these tools, and the less you build, the less it is likely to fail. So we will disable the two options when compiling the library.
Let's create a build folder and enter it:
mkdir build
cd build
Now it is time to prepare the build files:

cmake -DCMAKE_TOOLCHAIN_FILE=$VITASDK/share/vita.toolchain.cmake -DYAML_CPP_BUILD_TOOLS=OFF -DYAML_CPP_BUILD_CONTRIB=OFF ../






Compiling a library and using it in your project
devnoname120 edited this page on Jan 25 · 2 revisions
Pages 3

Home
Compiling a library and using it in your project
Merge checklist

Clone this wiki locally

This page explains how to compile and install an unsupported library so that you can use it in a Vita homebrew project. If the library that you are willing to use does not have too many dependencies, it should be pretty straightforward.

There exists multiple build systems, here is how to do it with the principal ones:
CMake

Files: CMakeLists.txt

We will use yaml-cpp for the example.

Let's open CMakeLists.txt in an editor. Under Project Options, there are two interesting lines:

option(YAML_CPP_BUILD_TOOLS "Enable testing and parse tools" ON)
option(YAML_CPP_BUILD_CONTRIB "Enable contrib stuff in library" ON)

We don't need these tools, and the less you build, the less it is likely to fail. So we will disable the two options when compiling the library.

Let's create a build folder and enter it:

mkdir build
cd build

Now it is time to prepare the build files:

cmake -DCMAKE_TOOLCHAIN_FILE=$VITASDK/share/vita.toolchain.cmake -DYAML_CPP_BUILD_TOOLS=OFF -DYAML_CPP_BUILD_CONTRIB=OFF ../

The first argument lets CMake know about the Vita compiler, and the two other options allow to disable the unneeded options that we saw above.

Now we can build the library:

make

And install it:

make install

The library is now installed, you can use it in your Vita projects.
GNU Autotools

Files: configure.ac, Makefile.am, configure

We will use Onigmo for the example.

First we tell the autoconfig tool that we want to compile the library for the PS Vita:

./configure --host arm-vita-eabi --disable-shared --enable-static

Now we can compile it:

make

And finally install it:

make install

You can now use this library in your Vita projects.
GNU Make

Files: Makefile

GNU Make is the basic building system, and most build systems actually produce a Makefile and execute this tool.

We will use JSMN for the example. Note that if you are looking for a JSON library in C, Jansson or cJSON is probably a better choice.

Let's open the file Makefile.

On the top of the file it is written that we need to set our build configuration here. Let's add some variables that tell about the various Vita compilation tools:

PREFIX = arm-vita-eabi
CC = $(PREFIX)-gcc
CFLAGS = -Wl,-q -Wall -O3 -Wno-unused-variable
ASFLAGS = $(CFLAGS)

Now save this file, close it, and run this:

make

The library is now compiled. Usually you would issue a make install to install the library to the vitasdk, but this particular library does not have an install recipe. We will install it manually:

cp libjsmn.a $VITASDK/arm-vita-eabi/lib/
cp jsmn.h $VITASDK/arm-vita-eabi/include/

You should now be able to use this library in your homebrew.

If you have any question about this article or another one, don't hesitate to contact us on our IRC channel: #vitasdk at Freenode. Be patient, we are not permanently checking the channel.
Advertising
Locked

Return to “Programming and Security”