-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
64 lines (63 loc) · 2.16 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
cmake_minimum_required(VERSION 2.8)
##############################################
# Prevent cmake generated files in root directory
##############################################
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "Please run inside of a build folder.")
endif()
##############################################
# Set project name
##############################################
project(sdl2_es2)
option(BUILD_GCW0 "Build for the GCW0" OFF)
##############################################
# Set GCW0 toolchain
##############################################
if(UNIX)
if(BUILD_GCW0)
message(STATUS "Building for GCW0")
include(/opt/gcw0-toolchain/usr/share/buildroot/toolchainfile.cmake)
add_definitions(-DUSE_GCW0)
endif(BUILD_GCW0)
message(STATUS "Setting Complier options")
add_definitions(-std=c++11 -g -Wall -Wextra)
endif(UNIX)
##############################################
# Find library dependencies
##############################################
find_package(PkgConfig REQUIRED)
pkg_search_module(SDL2 REQUIRED sdl2)
if(BUILD_GCW0)
pkg_search_module(GLESv2 REQUIRED glesv2)
else()
pkg_search_module(OpenGL REQUIRED gl)
endif(BUILD_GCW0)
##############################################
# Set Source
##############################################
set(SRC
sdl2_es2_main.cc
)
##############################################
# Create GCW0 opk script
##############################################
if(BUILD_GCW0)
file(COPY images DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/data)
configure_file( opk/default.gcw0.desktop ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/create_opk.sh "/opt/gcw0-toolchain/usr/bin/mksquashfs ./data/* ${PROJECT_NAME}.bin default.gcw0.desktop ${PROJECT_NAME}.opk -all-root -noappend -no-exports -no-xattrs")
endif(BUILD_GCW0)
##############################################
# Build Binary
##############################################
add_executable(${PROJECT_NAME}.bin ${SRC})
if(BUILD_GCW0)
target_link_libraries(${PROJECT_NAME}.bin
${SDL2_LIBRARIES}
${GLESv2_LIBRARIES}
)
else()
target_link_libraries(${PROJECT_NAME}.bin
${SDL2_LIBRARIES}
${OpenGL_LIBRARIES}
)
endif(BUILD_GCW0)