-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
130 lines (113 loc) · 4.06 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
cmake_minimum_required(VERSION 2.8)
project(proj)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/config)
include_directories(${CMAKE_SOURCE_DIR}/include)
# Fix for Qt Creator to list the hxx files.
file(GLOB HEADERS "include/*.hxx" "include/*/*.hxx")
add_custom_target(headerfiles SOURCES ${HEADERS})
# Choose Release build by default
if(CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE Release)
endif()
# C++11
if(MSVC)
if ("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 17.0)
message(FATAL_ERROR "The visual studio version is ${CMAKE_CXX_COMPILER_VERSION}, but you need at least 17.0.")
endif()
else()
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(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 4.6)
message(FATAL_ERROR "The gcc version is ${CMAKE_CXX_COMPILER_VERSION}, but you need at least 4.6.")
endif()
endif()
endif()
# SFML
find_package(SFML REQUIRED system window graphics audio)
include_directories(${SFML_INCLUDE_DIR})
# Use dynamic linking for SFML
add_definitions(-DSFML_DYNAMIC)
# Use static linking for SFML
#add_definitions(-DSFML_STATIC)
# OpenNI
find_package(OpenNI)
if(OPENNI_FOUND)
include_directories(${OPENNI_INCLUDE_DIRS})
add_definitions(-DOPENNI_FOUND)
endif()
## NITE
#find_package(NITE REQUIRED)
#include_directories(${NITE_INCLUDE_DIRS})
# The target for copying files.
add_custom_target(copy)
add_custom_command(TARGET copy PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/fonts ${CMAKE_BINARY_DIR}/fonts)
add_custom_command(TARGET copy PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/images ${CMAKE_BINARY_DIR}/images)
add_custom_command(TARGET copy PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/animations ${CMAKE_BINARY_DIR}/animations)
add_custom_command(TARGET copy PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/sounds ${CMAKE_BINARY_DIR}/sounds)
#add_custom_command(TARGET copy PRE_BUILD
# COMMAND ${CMAKE_COMMAND} -E copy_directory
# ${CMAKE_SOURCE_DIR}/highscore ${CMAKE_BINARY_DIR}/highscore)
add_custom_command(TARGET copy PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/menu.xml ${CMAKE_BINARY_DIR}/menu.xml)
add_custom_command(TARGET copy PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/menu_small.xml ${CMAKE_BINARY_DIR}/menu_small.xml)
# Library: tinyxml2
add_library(tinyxml2 STATIC tinyxml2.cpp)
# Executable: The kinect menu.
if(OPENNI_FOUND)
add_executable(proj proj.cxx)
target_link_libraries(proj
${SFML_LIBRARIES}
${OPENNI_LIBRARIES}
# ${NITE_LIBRARIES}
tinyxml2
)
add_dependencies(proj copy)
endif()
# Executable: The test menu.
add_executable(testmenu testmenu.cxx)
target_link_libraries(testmenu
${SFML_LIBRARIES}
tinyxml2
)
add_dependencies(testmenu copy)
# Executable: The game.
add_executable(hdm hdm.cxx)
target_link_libraries(hdm
${SFML_LIBRARIES}
)
add_dependencies(hdm copy)
# Executable: The game with kinect.
if (OPENNI_FOUND)
add_executable(hdm_kinect hdm_kinect.cxx)
target_link_libraries(hdm_kinect
${SFML_LIBRARIES}
${OPENNI_LIBRARIES}
)
add_dependencies(hdm_kinect copy)
endif()
# Executable: The widget test.
add_executable(test_widgets test_widgets.cxx)
target_link_libraries(test_widgets
${SFML_LIBRARIES}
)
add_dependencies(test_widgets copy)