cmake

Got something cool to help make the toolchains better? Post it here.
Post Reply
yatagarasu
Posts: 7
Joined: Mon Mar 15, 2010 12:16 pm

cmake

Post by yatagarasu » Wed Mar 17, 2010 3:26 pm

Hi everybody.

Here are some cmake scripts for devkitPro development. If you don't know, cmake is cross compiler build system much easier to use than make or auto-tools.

Here you can download simple Nintendo ds cmake project http://rghost.net/1182556
Just extract it somewhere.
Install latest cmake for your system from http://www.cmake.org/cmake/resources/software.html direct link for win32 installer http://www.cmake.org/files/v2.8/cmake-2 ... 32-x86.exe

than open command line in projects root and run

Code: Select all

#>prepare.bat Nitro Debug
#>cd build.Nitro.Debug
#>make
if everything is right you should see following output

Code: Select all

#>prepare.bat Nitro Debug

C:\devkitPro\projects\nitro>mkdir build.Nitro.Debug 

C:\devkitPro\projects\nitro>cd build.Nitro.Debug 

C:\devkitPro\projects\nitro\build.Nitro.Debug>cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=../cmake/Modules/Toolchain/Nitro.cmake -DCMAKE_BUILD_TYPE=Debug .. 
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Looking for arm-eabi-as
-- Looking for arm-eabi-as -- C:/devkitPro/devkitARM/bin/arm-eabi-as.exe
-- Looking for bin2s
-- Looking for bin2s -- C:/devkitPro/devkitARM/bin/bin2s.exe
-- Looking for arm-eabi-objcopy
-- Looking for arm-eabi-objcopy -- C:/devkitPro/devkitARM/bin/arm-eabi-objcopy.exe
-- Looking for ndstool
-- Looking for ndstool -- C:/devkitPro/devkitARM/bin/ndstool.exe
-- Check for working C compiler: c:/devkitPro/devkitARM/bin/arm-eabi-gcc.exe
-- Check for working C compiler: c:/devkitPro/devkitARM/bin/arm-eabi-gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: c:/devkitPro/devkitARM/bin/arm-eabi-g++.exe
-- Check for working CXX compiler: c:/devkitPro/devkitARM/bin/arm-eabi-g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/devkitPro/projects/nitro/build.Nitro.Debug

#>cd build.Nitro.Debug
#>make
[ 20%] Generating drunkenlogo_pcx.h
[ 40%] Generating drunkenlogo_pcx.o
Scanning dependencies of target nitro-arm9-data
Linking C static library libnitro-arm9-data.a
[ 40%] Built target nitro-arm9-data
Scanning dependencies of target nitro-arm9
[ 60%] Building CXX object CMakeFiles/nitro-arm9.dir/source/nehe6.cpp.obj
Linking CXX executable nitro-arm9
[ 60%] Built target nitro-arm9
Scanning dependencies of target nitro-nds
[ 60%] Generating nitro-arm9.o
[ 60%] Generating nitro.nds
Nintendo DS rom tool 1.47 - Feb 21 2010
by Rafael Vuijk, Dave Murphy, Alexei Karpenko
[100%] Built target nitro-nds
resulting rom file is generated in build.Nitro.Debug\nitro.nds

You can use prepare.bat [Nitro|PSP] [Debug|Release] to prepare build directory. It should be run only once. Next you can just run make in build directory. All CMakeLists.txt should be updated automatically.

Features: =)
1) Now only arm9 build is supported.
2) binary resources linkage is supported. (but no grit yet.)
3) devkitPSP is also supported.

CMakeLists.txt - is main cmake project file.

Code: Select all

cmake_minimum_required(VERSION 2.6)

# must be here so custom cmake scripts should be available.
set(SANDBOX_MODULE_DIR "${CMAKE_SOURCE_DIR}/cmake/modules")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${SANDBOX_MODULE_DIR}")

# must be here for generated resource .h files will be visible.
include_directories(${CMAKE_CURRENT_BINARY_DIR})

# project name.
project(nitro)

# generated rom name
set(ROM_NAME nitro)

# data files
set(DATA
    data/drunkenlogo.pcx
    )

#common source files
set(SOURCES
    source/nehe6.cpp
    )

#nitro source files
set(NITRO_SOURCES
    )

#psp source files
set(PSP_SOURCES
    )


if (${CMAKE_SYSTEM_NAME} STREQUAL Nitro) # could be used to determin Nitro build
# compiles arm9 core binary
nitro_add_executable(${ROM_NAME}-arm9 ${SOURCES} ${NITRO_SOURCES})
# compiles arm9 library
#nitro_add_library(${ROM_NAME}-arm9 STATIC ${SOURCES} ${NITRO_SOURCES})

# link your libraries here - before nitro libraries
target_link_libraries(${ROM_NAME}-arm9 nds9)

nitro_build_rom(${ROM_NAME} ${ROM_NAME}-arm9 ${DATA})
endif()

if (${CMAKE_SYSTEM_NAME} STREQUAL PSP) # could be used to determin PSP build
# compiles psp binary
psp_add_executable(${ROM_NAME}-psp ${SOURCES} ${PSP_SOURCES})
# compiles psp library
#psp_add_library(${ROM_NAME}-psp STATIC ${SOURCES} ${PSP_SOURCES})

# link your libraries here - before psp libraries
target_link_psp_libraries(${ROM_NAME}-psp)

psp_build_rom(${ROM_NAME} ${ROM_NAME}-psp ${DATA})
endif()
everything else should be obvious.
think it would be useful.
comments are welcome.

PS. cmake output is colored =)))

PPS. I'd like to mention Richard Quirks article http://quirkygba.blogspot.com/2008/09/a ... art-1.html which inspired my work.

StevenH
Posts: 133
Joined: Sun Feb 22, 2009 7:59 pm

Re: cmake

Post by StevenH » Thu Mar 18, 2010 1:56 am

Just one question for you...


WHY?????

WinterMute
Site Admin
Posts: 1986
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: cmake

Post by WinterMute » Thu Mar 18, 2010 2:05 am

Really don't see the need. Very, very few people move away from the templates provided by devkitPro for DS code and, honestly, I have yet to see the gnu make replacement that's worth the bother.

You might think cmake is easier but really, most of our users don't actually have to do anything other than copy a template. Using .bat files is also ridiculous, we have a large number of OSX & linux users.
Help keep devkitPro toolchains free, Donate today

Personal Blog

StevenH
Posts: 133
Joined: Sun Feb 22, 2009 7:59 pm

Re: cmake

Post by StevenH » Thu Mar 18, 2010 2:11 am

WinterMute wrote:we have a large number of OSX & linux users.
I'm one :), well I'm running linux under a VM and I should be ordering my Mac next month, I hope

yatagarasu
Posts: 7
Joined: Mon Mar 15, 2010 12:16 pm

Re: cmake

Post by yatagarasu » Thu Mar 18, 2010 8:31 am

The appealing side of cmake is that it is make file generator. It easily can generate make file for any gnu toolchain and even msvc. I personally use this scripts to build my project on win32, nitro, psp and linux platform. All you need is to switch Toolchain files or use none for native toolchain. So i just wanted to share them with those who possibly need them =)

So just don't compare cmake with make? because cmake uses make )

And bat file aren't ridiculous - they just reduce amoun of typing. And can be converted to shell scripts with all eyes shut ) And cmake works great under linux.

ps. i guess topic should be moved to user contributions.

WinterMute
Site Admin
Posts: 1986
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: cmake

Post by WinterMute » Thu Mar 18, 2010 10:04 am

Yeah but ... bat files don't work under linux or OSX and the devkitPro installer gives you a bash shell under windows. Your bat file needs arguments ...

From the average devkitARM user's perspective this is way more complex than what already exists and doesn't seem to come close to what the template makefiles do.
Help keep devkitPro toolchains free, Donate today

Personal Blog

yatagarasu
Posts: 7
Joined: Mon Mar 15, 2010 12:16 pm

Re: cmake

Post by yatagarasu » Thu Mar 18, 2010 3:10 pm

and the devkitPro installer gives you a bash shell under windows.
ok. never used it, because I program in Far Manager. and forgot that devkitPro have it.
Bash script even simpler to make user friendly =)

Code: Select all

#!/bin/sh

usage="Usage: $0 [Nitro|PSP] [Debug|Release]"

if [ $# -eq 2 ]; then
    mkdir build.$1.$2
    cd build.$1.$2
    cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=../cmake/Modules/Toolchain/$1.cmake -DCMAKE_BUILD_TYPE=$2 ..
else
    echo "$usage"; exit 1;
fi
From the average devkitARM user's perspective this is way more complex than what already exists and doesn't seem to come close to what the template makefiles do.
I like libnds makefile templates. They are simple and clear. CMake can be useful in far more complex projects (which may consist of multiple separate projects and libraries).

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests