forked from cpp3ds/cpp3ds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
93 lines (77 loc) · 2.84 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
88
89
90
91
92
93
cmake_minimum_required(VERSION 2.8.11)
project(cpp3ds)
set(CPP3DS ${PROJECT_SOURCE_DIR})
set(CMAKE_MODULE_PATH "${CPP3DS}/cmake" ${CMAKE_MODULE_PATH})
include(cpp3ds)
option(BUILD_EMULATOR "Build cpp3ds emulator (Qt5 required)" ON)
option(BUILD_EXAMPLES "Build all cpp3ds example projects" ON)
option(BUILD_DOCS "Build doxygen documentation" OFF)
option(BUILD_TESTS "Build unit tests" OFF)
option(ENABLE_OGG "Include OGG decoder classes" ON)
option(ENABLE_AAC "Include AAC decoder classes" OFF)
option(ENABLE_FLAC "Include FLAC encoder/decoder classes" OFF)
option(ENABLE_MP3 "Include MP3 decoder class" OFF)
if(ENABLE_OGG)
add_definitions(-DCPP3DS_ENABLE_OGG)
endif()
if(ENABLE_AAC)
add_definitions(-DCPP3DS_ENABLE_AAC)
endif()
if(ENABLE_FLAC)
add_definitions(-DCPP3DS_ENABLE_FLAC)
endif()
if(ENABLE_MP3)
add_definitions(-DCPP3DS_ENABLE_MP3)
endif()
# C++11 support
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
# Fetch all core_resources bundled with all software using cpp3ds.
# Shaders are defined separately because they need compiling first.
set(SHADER_FILES ${PROJECT_SOURCE_DIR}/res/core_resource/default_shader.vsh)
set(RESOURCE_FILES ${PROJECT_SOURCE_DIR}/res/core_resource/opensans.ttf)
set(RESOURCE_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/core_resource.cpp)
set(SHADER_AS nihstro)
compile_core_shaders(SHADER_OUTPUT ${PROJECT_SOURCE_DIR}/res/core_resource/ ${SHADER_FILES})
compile_resources(
"core_resources"
"${PROJECT_SOURCE_DIR}/res/core_resource"
${RESOURCE_OUTPUT}
${RESOURCE_FILES} ${SHADER_OUTPUT}
)
add_custom_target(cpp3ds-res ALL DEPENDS ${RESOURCE_OUTPUT} ${SHADER_OUTPUT})
# uninstall target
configure_file(
"cmake/cmake_uninstall.cmake.in"
"cmake/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake)
# disable the rpath stuff
set(CMAKE_SKIP_BUILD_RPATH TRUE)
# set the output directory for cpp3ds libraries and binaries
set(LIBRARY_OUTPUT_PATH "${PROJECT_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin")
# compile flags
set(ARCH "-march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft")
set(CPP3DS_ARM_FLAGS "-g -O3 ${ARCH} -ffunction-sections -fdata-sections")
set(CPP3DS_TEST_FLAGS "-g -O3 -coverage")
set(CPP3DS_EMU_FLAGS "-g -O3")
add_subdirectory(src)
if(BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
if(BUILD_DOCS)
add_subdirectory(doc)
endif()
if(BUILD_TESTS)
add_subdirectory(test)
endif()