forked from gottagofaster236/pbtetris
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
88 lines (70 loc) · 3.39 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# To choose target architecture, variable TARGET_TYPE has to be set to
# an according value:
# - Linux (default)
# - ARM
#
# For example: cmake -DCMAKE_BUILD_TYPE=Debug -DTARGET_TYPE=Linux -DPLATFORM=FC
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
PROJECT (inkdemo)
# will work with lower versions, but I set to the most recent at time of creation
cmake_minimum_required(VERSION 3.25)
SET (PLATFORM FC)
# I cloned the SDK via git to a directory I created called PBSDK on my PC
SET (TOOLCHAIN_PATH "../../PBSDK/SDK_6.3.0/SDK-B288/usr")
SET (TOOLCHAIN_PREFIX "arm-obreey-linux-gnueabi")
SET (TOOLCHAIN_INSTALL "sysroot/usr")
ADD_DEFINITIONS(-DPLATFORM_FC)
#SET (CMAKE_VERBOSE_MAKEFILE ON)
# building for ARM
SET (TARGET_TYPE ARM)
SET (CMAKE_BUILD_TYPE Release)
# change install prefix
SET(CMAKE_INSTALL_PREFIX "${TOOLCHAIN_PATH}/${TOOLCHAIN_PREFIX}/${TOOLCHAIN_INSTALL}" CACHE PATH "Install path prefix" FORCE)
# let's add the compiler for ARM
SET (CMAKE_C_COMPILER ${CMAKE_CURRENT_SOURCE_DIR}/${TOOLCHAIN_PATH}/bin/${TOOLCHAIN_PREFIX}-gcc)
SET (CMAKE_CXX_COMPILER ${CMAKE_CURRENT_SOURCE_DIR}/${TOOLCHAIN_PATH}/bin/${TOOLCHAIN_PREFIX}-g++)
SET (CMAKE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/${TOOLCHAIN_PATH}/bin/${TOOLCHAIN_PREFIX}-g++)
SET (CMAKE_ARR ${CMAKE_CURRENT_SOURCE_DIR}/${TOOLCHAIN_PATH}/bin/${TOOLCHAIN_PREFIX}-arr)
SET (CMAKE_STRIP ${CMAKE_CURRENT_SOURCE_DIR}/${TOOLCHAIN_PATH}/bin/${TOOLCHAIN_PREFIX}-strip)
SET (TARGET_INCLUDE "")
SET (TARGET_LIB pthread inkview freetype z)
# set needed compilation flags
MESSAGE (STATUS "Build for ARM Release")
SET (CMAKE_C_FLAGS_RELEASE "-DNDEBUG -s -fsigned-char -Wall -O2 -Wno-format-y2k -fomit-frame-pointer")
SET (CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -s -fsigned-char -Wall -O2 -Wno-format-y2k -fomit-frame-pointer")
# generate cimages/images.c
# !!! You have rebuild the project, if you add new images!!!
#SET (IMAGES_DIR ${CMAKE_SOURCE_DIR}/images)
#file(GLOB RESULT IMAGES_DIR)
#list(LENGTH RESULT IMAGES_COUNT)
#if(NOT IMAGES_COUNT EQUAL 0)
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_SOURCE_DIR}/cimages/images.c
COMMAND ${CMAKE_SOURCE_DIR}/${TOOLCHAIN_PATH}/bin/pbres -c ${CMAKE_SOURCE_DIR}/cimages/images.c ${CMAKE_SOURCE_DIR}/images/*.bmp)
#endif()
SET (SRC_LIST
${CMAKE_SOURCE_DIR}/src/main.cpp
${CMAKE_SOURCE_DIR}/src/tetris.hpp
${CMAKE_SOURCE_DIR}/src/tetris.cpp
${CMAKE_SOURCE_DIR}/src/game.hpp
${CMAKE_SOURCE_DIR}/src/game.cpp
${CMAKE_SOURCE_DIR}/src/buttons.hpp
${CMAKE_SOURCE_DIR}/src/buttons.cpp
${CMAKE_SOURCE_DIR}/src/highscore.hpp
${CMAKE_SOURCE_DIR}/src/highscore.cpp
${CMAKE_SOURCE_DIR}/src/debug.hpp
${CMAKE_SOURCE_DIR}/src/debug.cpp)
# output executable is "inkdemo" - rename the outputted executable with a .app ext if not using the "copy to pocketbook" section below
ADD_EXECUTABLE (inkdemo
${SRC_LIST}
${CMAKE_SOURCE_DIR}/cimages/images.c)
INCLUDE_DIRECTORIES(${TARGET_INCLUDE})
TARGET_LINK_LIBRARIES (inkdemo ${TARGET_LIB})
# copying to pocketbook after build (change path if needed - or delete?)
# targetfile is the path to the pocketbook over wifi
SET (targetfile "/run/user/1000/gvfs/ftp:host=10.42.0.165/mnt/ext1/applications")
add_custom_command(TARGET inkdemo POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:inkdemo> ${targetfile}/pbtetris_test.app >/dev/null || :
)
# end of copy to pocketbook section
INSTALL (TARGETS inkdemo DESTINATION bin)