-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathCMakeLists.txt
160 lines (130 loc) · 6.29 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
150
151
152
153
154
155
156
157
158
159
160
######################################################################
# PagedGeometry BUILD SYSTEM
# Welcome to the CMake build system for PagedGeometry.
# This is the main file where we prepare the general build environment
# and provide build configuration options.
######################################################################
# cmake system for PagedGeometry updated on 2-9-2021 by Edgar{at}AnotherFoxGuy{DOT}com
cmake_minimum_required(VERSION 3.1)
# define the project
project(
PagedGeometry
HOMEPAGE_URL https://ogrecave.github.io/ogre-pagedgeometry/
DESCRIPTION "PagedGeometry is a library that helps you to add grass and trees to your Ogre3D scene"
VERSION 1.3.0
)
# add some functions we use that are shipped with cmake
include(CheckLibraryExists)
include(CheckIncludeFile)
include(CheckIncludeFileCXX)
include(CheckCCompilerFlag)
include(CheckCSourceCompiles)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
# build static libs by default
SET(BUILD_SHARED_LIBS OFF)
SET(CMAKE_USE_RELATIVE_PATHS OFF)
# setup paths
SET(RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/")
SET(LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib/")
SET(ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib/")
SET(EXECUTABLE_OUTPUT_PATH ${RUNTIME_OUTPUT_DIRECTORY})
SET(LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_DIRECTORY})
SET(CMAKEFILES_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/PagedGeometry")
# fix executable paths for windows
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${RUNTIME_OUTPUT_DIRECTORY})
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${RUNTIME_OUTPUT_DIRECTORY})
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${RUNTIME_OUTPUT_DIRECTORY})
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${RUNTIME_OUTPUT_DIRECTORY})
# some optimization flags
if (MSVC)
# add multi processor compilation flags
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MP /GL /Ox /Ob2 /Oi /Ot /Oy /fp:fast /GS- /MP /Zi")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MP /Zi")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MP /Od /Zi")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MP /Od /Zi")
# some general flags
add_definitions("-D_CRT_SECURE_NO_WARNINGS")
include_directories(${DirectX_INCLUDE_DIR})
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /DEBUG /SUBSYSTEM:WINDOWS")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /SUBSYSTEM:WINDOWS /LTCG /OPT:REF")
set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} /DEBUG /SUBSYSTEM:WINDOWS /LTCG /OPT:REF")
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /DEBUG /SUBSYSTEM:WINDOWS /LTCG /OPT:REF")
elseif ()
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -mfpmath=sse -msse2 -mmmx -msse -msse3 -m3dnow -O2 -fomit-frame-pointer -fstrict-aliasing -ffast-math -ftracer")
set(CMAKE_EXE_LINKER_FLAGS_RelWithDebug "${CMAKE_EXE_LINKER_FLAGS_RelWithDebug} -O0")
endif ()
# some PG build options
set(PAGEDGEOMETRY_BUILD_SAMPLES "FALSE" CACHE BOOL "build the examples")
set(PAGEDGEOMETRY_ALTERNATE_COORDSYSTEM "FALSE" CACHE BOOL "alternate coordinate system, do not use unless you are very sure about it")
set(PAGEDGEOMETRY_USER_DATA "FALSE" CACHE BOOL "ability to attach user data to entities")
# configuration of the config.h
CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/include/PagedGeometryConfig.h.in" "${CMAKE_BINARY_DIR}/include/PagedGeometryConfig.h")
# some additional compiler flags
if (NOT WIN32)
ADD_DEFINITIONS(-Wall -Wno-unused-parameter)
CHECK_C_COMPILER_FLAG(-Wextra HAVE_W_EXTRA)
if (HAVE_W_EXTRA)
ADD_DEFINITIONS(-Wextra)
endif ()
endif ()
# Set visibility options if available
IF (NOT WIN32)
CHECK_C_SOURCE_COMPILES("int foo() __attribute__((destructor));
int main() {return 0;}" HAVE_GCC_DESTRUCTOR)
CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAVE_VISIBILITY_SWITCH)
IF (HAVE_VISIBILITY_SWITCH)
CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"default\")));
int main() {return 0;}" HAVE_GCC_VISIBILITY)
IF (HAVE_GCC_VISIBILITY)
ADD_DEFINITIONS(-fvisibility=hidden -DHAVE_GCC_VISIBILITY)
ENDIF ()
ENDIF ()
ENDIF ()
# --- Ogre 3D graphics engine ---
find_package(OGRE REQUIRED CONFIG)
# now add the directories
add_subdirectory(source)
if (PAGEDGEOMETRY_BUILD_SAMPLES)
add_subdirectory(examples)
endif (PAGEDGEOMETRY_BUILD_SAMPLES)
# doxygen stuff
find_package(Doxygen)
if (DOXYGEN_FOUND)
message("found doxygen, generating documentation")
# prepare doxygen configuration file
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in ${CMAKE_BINARY_DIR}/Doxyfile)
add_custom_target(
doc_doxygen
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Generating documentation with Doxygen."
VERBATIM
)
# cleanup $build/docs on "make clean"
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES docs)
#install(DIRECTORY ${CMAKE_BINARY_DIR}/docs/html/ DESTINATION ${CMAKE_INSTALL_DOCDIR}/api)
# install man pages into packages, scope is now project root..
#install(DIRECTORY ${CMAKE_BINARY_DIR}/docs/man/man3 DESTINATION share/man/man3/ )
endif (DOXYGEN_FOUND)
# other doc files
set(DOC_FILES Contributors.txt zlib.txt README.md Todo.txt)
install(FILES ${DOC_FILES} DESTINATION TYPE DOC)
# install the PkgConfig file
configure_file("${CMAKE_SOURCE_DIR}/PagedGeometry.pc.in" "${CMAKE_BINARY_DIR}/PagedGeometry.pc" @ONLY)
install(FILES "${CMAKE_BINARY_DIR}/PagedGeometry.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
configure_package_config_file(
PagedGeometryConfig.cmake.in
${CMAKE_BINARY_DIR}/PagedGeometryConfig.cmake
INSTALL_DESTINATION ${CMAKEFILES_INSTALL_DIR}
)
write_basic_package_version_file(
${CMAKE_BINARY_DIR}/PagedGeometryConfigVersion.cmake
VERSION "${CMAKE_PROJECT_VERSION}"
COMPATIBILITY SameMajorVersion
)
install(
FILES ${CMAKE_BINARY_DIR}/PagedGeometryConfig.cmake
${CMAKE_BINARY_DIR}/PagedGeometryConfigVersion.cmake
DESTINATION ${CMAKEFILES_INSTALL_DIR}
)