forked from g-truc/gli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
139 lines (109 loc) · 3.63 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
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
cmake_policy(VERSION 2.6)
if (NOT CMAKE_VERSION VERSION_LESS "3.1")
cmake_policy(SET CMP0054 NEW)
endif()
project(gli)
set(GLI_VERSION "0.8.1")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
enable_testing()
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-DSOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
include_directories(".")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# To generate .asm files: /FAs
add_definitions(/Za)
endif()
if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") AND UNIX))
set(CMAKE_CXX_FLAGS "-std=c++0x")
add_definitions(-Wall)
endif()
################################
# Add source files
file(GLOB ROOT_SOURCE ./gli/*.cpp)
file(GLOB ROOT_INLINE ./gli/*.inl)
file(GLOB ROOT_HEADER ./gli/*.hpp)
file(GLOB ROOT_TEXT ./*.txt)
file(GLOB ROOT_MD ../*.md)
file(GLOB ROOT_KMG ./doc/spec/*.html)
file(GLOB_RECURSE CORE_SOURCE ./gli/core/*.cpp)
file(GLOB_RECURSE CORE_INLINE ./gli/core/*.inl)
file(GLOB_RECURSE CORE_HEADER ./gli/core/*.hpp)
file(GLOB_RECURSE GTX_SOURCE ./gli/gtx/*.cpp)
file(GLOB_RECURSE GTX_INLINE ./gli/gtx/*.inl)
file(GLOB_RECURSE GTX_HEADER ./gli/gtx/*.hpp)
source_group("KMG Spec" FILES ${ROOT_KMG})
source_group("Text Files" FILES ${ROOT_TEXT} ${ROOT_MD})
source_group("Core Files" FILES ${CORE_SOURCE})
source_group("Core Files" FILES ${CORE_INLINE})
source_group("Core Files" FILES ${CORE_HEADER})
source_group("GTX Files" FILES ${GTX_SOURCE})
source_group("GTX Files" FILES ${GTX_INLINE})
source_group("GTX Files" FILES ${GTX_HEADER})
################################
# Add package
macro(addExternalPackageGTC NAME DIRECTORY)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/external/${DIRECTORY}/util)
set(${NAME}_PACKAGE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/${DIRECTORY})
find_package(${NAME})
if(NOT ${NAME}_FOUND)
message("ERROR: ${NAME} not found")
endif(NOT ${NAME}_FOUND)
endmacro(addExternalPackageGTC)
################################
# Add GLM
set(GLM_DIRECTORY glm)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/external/${GLM_DIRECTORY})
################################
# Add subdirectory
add_subdirectory(gli)
add_subdirectory(test)
#add_subdirectory(doc)
################################
# Add installer
set(GLI_INSTALL_CONFIGDIR "${CMAKE_INSTALL_LIBDIR}/cmake/gli")
install(DIRECTORY gli DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/gliVersion.cmake"
VERSION ${GLI_VERSION}
COMPATIBILITY AnyNewerVersion
)
# build tree package config
configure_file(
cmake/gliBuildConfig.cmake.in
gliConfig.cmake
@ONLY
)
# install tree package config
configure_package_config_file(
cmake/gliConfig.cmake.in
${GLI_INSTALL_CONFIGDIR}/gliConfig.cmake
INSTALL_DESTINATION ${GLI_INSTALL_CONFIGDIR}
PATH_VARS CMAKE_INSTALL_INCLUDEDIR
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/${GLI_INSTALL_CONFIGDIR}/gliConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/gliVersion.cmake"
DESTINATION ${GLI_INSTALL_CONFIGDIR}
)
if (NOT CMAKE_VERSION VERSION_LESS "3.0")
add_library(gli INTERFACE)
target_include_directories(gli INTERFACE
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
)
install(TARGETS gli EXPORT gliTargets)
export(
EXPORT gliTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/gliTargets.cmake"
)
install(
EXPORT gliTargets FILE gliTargets.cmake
DESTINATION ${GLI_INSTALL_CONFIGDIR}
)
endif()
export(PACKAGE gli)