This repository has been archived by the owner on Nov 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
149 lines (98 loc) · 4.31 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
cmake_minimum_required(VERSION 2.8.9 FATAL_ERROR)
# PROJECT CONFIG
set(META_PROJECT_NAME "CGSee")
set(META_VERSION_MAJOR "0")
set(META_VERSION_MINOR "0")
set(META_AUTHOR_ORGANIZATION "CGSee Group")
set(META_AUTHOR_DOMAIN "https://github.com/cgcostume/cgsee/")
option(OPTION_LIMIT_CONFIGS "Generate limited configs (Release; Debug)" ON)
option(OPTION_LOCAL_INSTALL "Install to local directory instead of system" OFF)
if(OPTION_LIMIT_CONFIGS)
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Limited Configs" FORCE)
endif()
set(PROJECT_NAME ${META_PROJECT_NAME})
project(${PROJECT_NAME} C CXX)
# check if x64 and provide this information
set(X64 OFF)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(X64 ON)
endif()
# check for linux
if(UNIX AND NOT APPLE)
set(LINUX 1)
endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# root the bin and lib dirs to the project dir
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/install)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# RETRIEVE REPOSITORY VERSION AND GENERATE META HEADER
# add a revision file containing the git-head tag for cpack and install
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
# generate a shorter, googlelike variation for rev
string(SUBSTRING ${GIT_SHA1} 0 12 GIT_REV)
file(WRITE ${CMAKE_BINARY_DIR}/revision ${GIT_REV})
install(FILES ${CMAKE_BINARY_DIR}/revision DESTINATION .)
# THIRD PARTIES
find_package(OpenGL REQUIRED)
find_package(GLM REQUIRED)
find_package(GLEW REQUIRED)
set(CMAKE_AUTOMOC ON)
set(AUTOMOC_MOC_OPTIONS PROPERTIES FOLDER CMakeAutomocTargets)
# Probably works in the next cmake release -> http://www.cmake.org/Bug/view.php?id=13788
# What we do not want is automocs beside the project -> http://www.cmake.org/Bug/view.php?id=13688
set_property(GLOBAL PROPERTY AUTOMOC_FOLDER CMakeAutomocTargets)
# try to find qt5
# good resource: http://www.kdab.com/using-cmake-with-qt-5/
find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(Qt5Widgets REQUIRED) # this is important in order to get uic workin
# SOURCES AND INCLUDES
include_directories(
${CMAKE_BINARY_DIR} # for Meta.h
${OPENGL_INCLUDE_DIR}
${GLM_INCLUDE_PATH}
${GLEW_INCLUDE_PATH}
${CMAKE_SOURCE_DIR}/libs)
set(CGSEE_LIB_FOLDER "CGSee Libs")
set(CGSEE_APP_FOLDER "CGsee Apps")
set(CGSEE_HEADER_GROUP "Header Files (API)")
set(CGSEE_SOURCE_GROUP "Source Files")
set(CGSEE_UIWRAP_GROUP "Ui-Wrap Files")
# setup platform specifics (compile flags, etc., ...)
if(MSVC)
message(STATUS "Configuring for platform Windows/MSVC.")
include(${CMAKE_SOURCE_DIR}/cmake/PlatformWindowsMSVC.cmake)
elseif(WIN32 AND CMAKE_COMPILER_IS_GNUCXX)
message(STATUS "Configuring for platform Windows/GCC.")
include(${CMAKE_SOURCE_DIR}/cmake/PlatformWindowsGCC.cmake)
elseif(LINUX AND CMAKE_COMPILER_IS_GNUCXX)
message(STATUS "Configuring for platform Linux/GCC.")
include(${CMAKE_SOURCE_DIR}/cmake/PlatformLinuxGCC.cmake)
else()
# TODO configure for apple
message(WARNING "No Platform configuration for APPLE yet: TODO")
endif()
include(cmake/Custom.cmake)
add_subdirectory("libs")
add_subdirectory("apps")
# CPACK DEPLOY
set(CPACK_GENERATOR "ZIP")
set(CPACK_SOURCE_GENERATOR "ZIP")
set(CPACK_PACKAGE_VERSION_MAJOR ${META_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${META_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${GIT_REV})
set(CPACK_INSTALL_DIRECTORIES ${CMAKE_BINARY_DIR}/install)
set(CPACK_IGNORE_FILES "/.pdb/;/.ilk/;/.svn/;/.hg/;/.git/;.swp$;.#;/#")
set(CPACK_OUTPUT_FILE_PREFIX ${CMAKE_BINARY_DIR}/install)
include(CPack)