forked from ZahlGraf/IrrIMGUI
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
164 lines (137 loc) · 5.71 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
161
162
163
164
#
# The MIT License (MIT)
#
# Copyright (c) 2015 André Netzeband
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
cmake_minimum_required(VERSION 3.20)
cmake_policy(VERSION 3.20)
PROJECT(IrrIMGUI)
SET(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
${PROJECT_SOURCE_DIR}/CMake
${PROJECT_SOURCE_DIR}/CMake/Dependencies
${PROJECT_SOURCE_DIR}/CMake/Options
${PROJECT_SOURCE_DIR}/CMake/Compiler
${PROJECT_SOURCE_DIR}/CMake/Packages
${PROJECT_SOURCE_DIR}/CMake/OperationSystems
)
# Contains a list of source files...
INCLUDE(Version)
# Contains a list of source files...
INCLUDE(SourceFiles)
# Compiler dependent settings
INCLUDE(CompilerMSVCLikeSettings)
INCLUDE(CompilerGccLikeSettings)
# OS dependent settings
INCLUDE(WindowsSettings)
INCLUDE(UnixSettings)
# Option dependent settings
INCLUDE(OptionStaticLib)
INCLUDE(OptionBuildExamples)
INCLUDE(OptionInstallMediaFiles)
INCLUDE(OptionIrrlichtDirectIncludes)
INCLUDE(OptionNativeOpenGL)
INCLUDE(OptionUnitTests)
# Dependency related settings
INCLUDE(DependencyIMGUI)
if (TARGET IrrlichtMt)
SET (IRRLICHT_FOUND TRUE)
set(IRRIMGUI_DEPENDENCY_LIBRARIES IrrlichtMt)
else()
message(SEND_ERROR "Target IrrlichtMt not created")
SET (IRRLICHT_FOUND FALSE)
endif()
INCLUDE(DependencyOpenGL)
INCLUDE(DependencyDirectX9)
INCLUDE(DependencyDoxygen)
INCLUDE(DependencyX11)
# Print all settings
INCLUDE(PrintSettings)
# Collect all source files
SET(ALL_HEADER_FILES
${IRRIMGUI_PRIVATE_HEADER_FILES}
${IRRIMGUI_PUBLIC_HEADER_FILES}
${IMGUI_PUBLIC_HEADER_FILES}
${IMGUI_PRIVATE_HEADER_FILES}
)
SET(ALL_SOURCE_FILES
${IRRIMGUI_SOURCE_FILES}
${IMGUI_SOURCE_FILES}
)
# Target settings
SET_SOURCE_FILES_PROPERTIES(ALL_HEADER_FILES
PROPERTIES HEADER_FILE_ONLY TRUE)
LIST(APPEND ALL_SOURCE_FILES ${ALL_HEADER_FILES})
# Cache back the flags (seems to be an error of cmake for msys makefile generator)
if (NOT CFLAG_WRITE_BACK)
SET(CFLAG_WRITE_BACK TRUE CACHE BOOL "(do not change!)" FORCE)
mark_as_advanced(FORCE CFLAG_WRITE_BACK)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "compile flags" FORCE)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "compile flags" FORCE)
endif ()
# Create targets
if (IRRIMGUI_STATIC_LIBRARY)
ADD_LIBRARY (IrrIMGUI ${ALL_SOURCE_FILES} )
else ()
ADD_LIBRARY (IrrIMGUI SHARED ${ALL_SOURCE_FILES} )
SET_TARGET_PROPERTIES(IrrIMGUI PROPERTIES COMPILE_DEFINITIONS "_IRRIMGUI_EXPORTS_;${IMGUI_API_VALUE};IRRLICHT_EXPORTS=1" )
endif ()
SET_TARGET_PROPERTIES(IrrIMGUI PROPERTIES VERSION ${VERSION_STRING} SOVERSION ${SOVERSION_STRING})
file(WRITE "${PROJECT_BINARY_DIR}/version.txt" "${VERSION_STRING}")
TARGET_LINK_LIBRARIES(IrrIMGUI ${IRRIMGUI_DEPENDENCY_LIBRARIES} ${OS_DEPENDENT_LIBRARIES})
target_include_directories(IrrIMGUI PUBLIC "includes")
target_include_directories(IrrIMGUI PUBLIC "${IMGUI_SOURCE_DIR}/..")
INSTALL(TARGETS IrrIMGUI
ARCHIVE DESTINATION "lib" CONFIGURATIONS Debug Release MinSizeRel RelWithDebInfo
LIBRARY DESTINATION "lib" CONFIGURATIONS Debug Release MinSizeRel RelWithDebInfo
RUNTIME DESTINATION "bin" CONFIGURATIONS Debug Release MinSizeRel RelWithDebInfo
)
INSTALL(DIRECTORY "includes" DESTINATION ".")
INSTALL(DIRECTORY "source/private" DESTINATION "tests/includes")
INSTALL(FILES ${IMGUI_PUBLIC_HEADER_FILES} DESTINATION "includes/IMGUI")
INSTALL(FILES ${PROJECT_BINARY_DIR}/version.txt DESTINATION ".")
if (IRRIMGUI_INSTALL_MEDIA_FILES)
INSTALL(DIRECTORY ${IRRIMGUI_MEDIA_DIR} DESTINATION ".")
INSTALL(FILES ${IMGUI_FONTFILES} DESTINATION "media")
endif ()
if ((IRRIMGUI_BUILD_EXAMPLES) OR (IRRIMGUI_BUILD_UNITTESTS))
SET(IRRIMGUI_LIB_FILE $<TARGET_LINKER_FILE_NAME:IrrIMGUI>)
SET(IRRIMGUI_SHARED_FILE $<TARGET_FILE_NAME:IrrIMGUI>)
SET(ZZZ_EXAMPLE_SINGLE_COMPILE OFF CACHE BOOL "(Do not set!) If this is enabled, cmake assumes that an example should be compiled for itself (This variable is set automatically, so do not set!).")
mark_as_advanced(FORCE ZZZ_EXAMPLE_SINGLE_COMPILE)
SET(IRRIMGUI_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/include" CACHE PATH "The include directory for IrrIMGUI headers.")
mark_as_advanced(FORCE IRRIMGUI_INCLUDE_DIR)
SET(IRRIMGUI_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/${IRRIMGUI_LIB_FILE}" CACHE FILEPATH "The path to the IrrIMGUI library.")
mark_as_advanced(FORCE IRRIMGUI_LIBRARY)
if (NOT IRRIMGUI_STATIC_LIBRARY)
SET(IRRIMGUI_SHARED_BIN "${CMAKE_CURRENT_BINARY_DIR}/${IRRIMGUI_SHARED_FILE}" CACHE FILEPATH "The path to the IrrIMGUI shared library.")
mark_as_advanced(FORCE IRRIMGUI_SHARED_BIN)
endif ()
if (IRRIMGUI_BUILD_EXAMPLES)
ADD_SUBDIRECTORY(examples)
endif()
if (IRRIMGUI_BUILD_UNITTESTS)
ADD_SUBDIRECTORY(unittests)
endif()
if (ZZZ_EXAMPLE_SINGLE_COMPILE)
message(SEND_ERROR "The variable ZZZ_EXAMPLE_SINGLE_COMPILE must not be set when compiling the IrrIMGUI library!")
endif ()
endif ()