forked from libRocket/libRocket
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
741 lines (620 loc) · 22.9 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
#===================================
# Build script for RmlUi ===========
#===================================
cmake_minimum_required(VERSION 3.0)
if(APPLE)
# This has to be before most other options so CMake properly handles the
# compiler variables, it MUST bebefore the project() definition
if(IOS_PLATFORM)
set(CMAKE_TOOLCHAIN_FILE CMake/Platform/iOS.cmake)
endif(IOS_PLATFORM)
option(BUILD_UNIVERSAL_BINARIES "Build universal binaries for all architectures supported" ON)
if (NOT CMAKE_OSX_ARCHITECTURES AND BUILD_UNIVERSAL_BINARIES)
if(IOS)
# set the architecture for iOS
if (${IOS_PLATFORM} STREQUAL "OS")
set (IOS_ARCH armv6 armv7 armv7s arm64)
set (CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} CACHE STRING "Build architecture for iOS")
else (${IOS_PLATFORM} STREQUAL "OS")
set (IOS_ARCH x86_64)
set (CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} CACHE STRING "Build architecture for iOS Simulator")
endif (${IOS_PLATFORM} STREQUAL "OS")
else(IOS)
# set the architectures for OS X
set (OSXI_ARCH x86_64)
set (CMAKE_OSX_ARCHITECTURES ${OSXI_ARCH} CACHE STRING "Build architecture for OS X universal binaries")
endif(IOS)
endif (NOT CMAKE_OSX_ARCHITECTURES AND BUILD_UNIVERSAL_BINARIES)
endif(APPLE)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0015 NEW)
endif(COMMAND cmake_policy)
# Enable the use of MACOSX_RPATH by default for CMake v3.0+; this effectively
# allows plug 'n' play functionality, so to speak -- the resulting shared
# library files can simply be copied over into the end-user's application
# bundle or framework bundle. No mucking around with install_name_tool.
#
# See also:
# cmake --help-policy cmp0042
# http://www.kitware.com/blog/home/post/510
if(POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif(POLICY CMP0042)
if (POLICY CMP0072)
cmake_policy (SET CMP0072 NEW)
endif(POLICY CMP0072)
if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif(POLICY CMP0074)
project(RmlUi LANGUAGES C CXX VERSION 3.3)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(RMLUI_VERSION_RELEASE true)
if(RMLUI_VERSION_RELEASE)
set(RMLUI_VERSION_SUFFIX "")
else()
set(RMLUI_VERSION_SUFFIX "-dev")
endif()
set(RMLUI_VERSION_SHORT ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}${RMLUI_VERSION_SUFFIX})
# paths
include(GNUInstallDirs)
# Search in the 'cmake' directory for additional CMake modules.
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake;${PROJECT_SOURCE_DIR}/CMake/Modules)
#===================================
# Environment tests ================
#===================================
include(TestForANSIForScope)
include(TestForANSIStreamHeaders)
include(TestForSTDNamespace)
#===================================
# Provide hints as to where depends=
# might be found =
#===================================
if(NOT DEFINED ENV{FREETYPE_DIR})
set(ENV{FREETYPE_DIR} "${PROJECT_SOURCE_DIR}/Dependencies")
endif()
if(NOT DEFINED ENV{LUA_DIR})
set(ENV{LUA_DIR} "${PROJECT_SOURCE_DIR}/Dependencies")
endif()
if(NOT DEFINED ENV{SDL2DIR})
set(ENV{SDL2DIR} "${PROJECT_SOURCE_DIR}/Dependencies")
endif()
if(NOT DEFINED ENV{SDL2_IMAGE_DIR})
set(ENV{SDL2_IMAGE_DIR} "${PROJECT_SOURCE_DIR}/Dependencies")
endif()
if(NOT DEFINED ENV{SFML_ROOT})
set(ENV{SFML_ROOT} "${PROJECT_SOURCE_DIR}/Dependencies")
endif()
if(NOT DEFINED ENV{TRACY_DIR})
set(ENV{TRACY_DIR} "${PROJECT_SOURCE_DIR}/Dependencies")
endif()
#===================================
# Plaform specific global hacks ====
#===================================
if(APPLE)
# Disables naked builtins from AssertMacros.h which
# This prevents naming collisions such as those from the check()
# function macro with LuaType::check
add_definitions(-D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0)
endif(APPLE)
#===================================
# Build options ====================
#===================================
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif()
if(NOT IOS)
option(BUILD_SHARED_LIBS "Build shared (dynamic) libraries" ON)
endif(NOT IOS)
option(BUILD_LUA_BINDINGS "Build Lua bindings" OFF)
if(APPLE)
option(BUILD_FRAMEWORK "Build Framework bundle for OSX" OFF)
endif()
option(BUILD_SAMPLES "Build samples" OFF)
if(APPLE)
if(IOS)
if(BUILD_SHARED_LIBS)
message(FATAL_ERROR "BUILD_SHARED_LIBS must be OFF for iOS builds. iOS does not support shared libraries.")
endif(BUILD_SHARED_LIBS)
endif(IOS)
if(BUILD_FRAMEWORK)
if(NOT "${CMAKE_GENERATOR}" STREQUAL "Xcode")
message(FATAL_ERROR "You should use Xcode generator with BUILD_FRAMEWORK enabled")
endif()
if(NOT BUILD_SHARED_LIBS)
message(FATAL_ERROR "BUILD_SHARED_LIBS must be ON with BUILD_FRAMEWORK enabled")
endif()
endif()
else(APPLE)
if(BUILD_FRAMEWORK)
message(FATAL_ERROR "BUILD_FRAMEWORK is only supported on Mac OS X with the Xcode generator")
endif()
endif(APPLE)
option(NO_FONT_INTERFACE_DEFAULT "Do not include the default font engine in the build. Allows building without the FreeType dependency, but a custom font engine must be created and set." OFF)
if(NO_FONT_INTERFACE_DEFAULT)
add_definitions(-DRMLUI_NO_FONT_INTERFACE_DEFAULT)
endif()
if(NOT BUILD_SHARED_LIBS)
add_definitions(-DRMLUI_STATIC_LIB)
message("-- Building static libraries. Make sure to #define RMLUI_STATIC_LIB before including RmlUi in your project.")
endif()
option(NO_THIRDPARTY_CONTAINERS "Only use standard library containers." OFF)
if( NO_THIRDPARTY_CONTAINERS )
add_definitions(-DRMLUI_NO_THIRDPARTY_CONTAINERS)
message("-- No third-party containers will be used: Make sure to #define RMLUI_NO_THIRDPARTY_CONTAINERS before including RmlUi in your project.")
endif()
option(ENABLE_TRACY_PROFILING "Enable profiling with Tracy. It is recommended to place source files in Dependencies/tracy." OFF)
if( ENABLE_TRACY_PROFILING )
find_package(Tracy REQUIRED)
include_directories(${TRACY_INCLUDE_DIR})
if( CMAKE_CONFIGURATION_TYPES )
list(APPEND CMAKE_CONFIGURATION_TYPES Tracy)
list(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES)
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
"Add the configurations that we need"
FORCE)
set(CMAKE_C_FLAGS_TRACY "${CMAKE_CXX_FLAGS_RELEASE} -DRMLUI_ENABLE_PROFILING")
set(CMAKE_CXX_FLAGS_TRACY "${CMAKE_CXX_FLAGS_RELEASE} -DRMLUI_ENABLE_PROFILING")
set(CMAKE_EXE_LINKER_FLAGS_TRACY "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
set(CMAKE_SHARED_LINKER_FLAGS_TRACY "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
message("-- Tracy profiling enabled in configuration 'Tracy'.")
else()
message("-- Tracy profiling enabled.")
add_definitions(-DRMLUI_ENABLE_PROFILING)
endif()
elseif( CMAKE_CONFIGURATION_TYPES )
list(REMOVE_ITEM CMAKE_CONFIGURATION_TYPES Tracy)
endif()
option(DISABLE_RTTI_AND_EXCEPTIONS "Build with rtti and exceptions disabled." OFF)
if(DISABLE_RTTI_AND_EXCEPTIONS)
add_definitions(-DRMLUI_USE_CUSTOM_RTTI)
message("-- C++ RTTI and exceptions will be disabled: Make sure to #define RMLUI_USE_CUSTOM_RTTI before including RmlUi in your project.")
endif()
option(ENABLE_PRECOMPILED_HEADERS "Enable precompiled headers" ON)
set(PRECOMPILED_HEADERS_ENABLED OFF)
if (ENABLE_PRECOMPILED_HEADERS AND (CMAKE_VERSION VERSION_LESS 3.16.0))
message("-- Could not enable precompiled headers. Need CMake version 3.16.0 or greater.")
elseif (ENABLE_PRECOMPILED_HEADERS)
set(PRECOMPILED_HEADERS_ENABLED ON)
endif()
#===================================
# Find dependencies ================
#===================================
# FreeType
if(NOT NO_FONT_INTERFACE_DEFAULT)
find_package(Freetype REQUIRED)
if(FREETYPE_FOUND)
include_directories(${FREETYPE_INCLUDE_DIRS})
link_directories(${FREETYPE_LINK_DIRS})
list(APPEND CORE_LINK_LIBS ${FREETYPE_LIBRARY})
endif()
endif()
#Lua
if(BUILD_LUA_BINDINGS)
find_package(Lua)
if(LUA_FOUND)
include_directories(${LUA_INCLUDE_DIR})
list(APPEND LUA_BINDINGS_LINK_LIBS ${LUA_LIBRARIES})
endif()
endif()
#===================================
# Setup paths ======================
#===================================
include_directories(
${PROJECT_SOURCE_DIR}/Include
)
# Include list of source files
include(FileList)
if(NOT BUILD_FRAMEWORK)
#===================================
# Build libraries ==================
#===================================
set(LIBRARIES Core Controls Debugger)
foreach(library ${LIBRARIES})
set(NAME Rml${library})
add_library(${NAME}
${${library}_HDR_FILES}
${${library}_PUB_HDR_FILES}
${MASTER_${library}_PUB_HDR_FILES}
${${library}_SRC_FILES}
)
set_target_properties(${NAME} PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
)
if (MSVC)
target_compile_options(${NAME} PUBLIC "/MP")
endif(MSVC)
install(TARGETS ${NAME}
EXPORT RmlUiTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
set(RMLUI_EXPORTED_TARGETS ${RMLUI_EXPORTED_TARGETS} ${NAME})
endforeach(library)
target_compile_definitions(RmlCore PRIVATE RMLUI_VERSION="${RMLUI_VERSION_SHORT}")
if (PRECOMPILED_HEADERS_ENABLED)
target_precompile_headers(RmlCore PRIVATE ${PROJECT_SOURCE_DIR}/Source/Core/precompiled.h)
target_precompile_headers(RmlControls PRIVATE ${PROJECT_SOURCE_DIR}/Source/Controls/precompiled.h)
endif()
else(NOT BUILD_FRAMEWORK)
#===================================
# Build combined Framework =========
#===================================
set(NAME RmlUi)
set(MASTER_PUB_HDR_FILES
${MASTER_Core_PUB_HDR_FILES}
${MASTER_Controls_PUB_HDR_FILES}
${MASTER_Debugger_PUB_HDR_FILES}
)
add_library(${NAME}
${Core_HDR_FILES}
${MASTER_Core_PUB_HDR_FILES}
${Core_PUB_HDR_FILES}
${Core_SRC_FILES}
${Controls_HDR_FILES}
${MASTER_Controls_PUB_HDR_FILES}
${Controls_PUB_HDR_FILES}
${Controls_SRC_FILES}
${Debugger_HDR_FILES}
${MASTER_Debugger_PUB_HDR_FILES}
${Debugger_PUB_HDR_FILES}
${Debugger_SRC_FILES}
)
set_target_properties(${NAME} PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
)
set_property(SOURCE ${MASTER_PUB_HDR_FILES}
PROPERTY MACOSX_PACKAGE_LOCATION Headers
)
set_property(SOURCE ${Core_PUB_HDR_FILES}
PROPERTY MACOSX_PACKAGE_LOCATION Headers/Core
)
set_property(SOURCE ${Controls_PUB_HDR_FILES}
PROPERTY MACOSX_PACKAGE_LOCATION Headers/Controls
)
set_property(SOURCE ${Debugger_PUB_HDR_FILES}
PROPERTY MACOSX_PACKAGE_LOCATION Headers/Debugger
)
set_target_properties(${NAME} PROPERTIES
FRAMEWORK TRUE
FRAMEWORK_VERSION ${PROJECT_VERSION}
MACOSX_FRAMEWORK_IDENTIFIER com.rmlui.${NAME}
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${RMLUI_VERSION_SHORT}
MACOSX_FRAMEWORK_BUNDLE_VERSION ${PROJECT_VERSION}
XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
PUBLIC_HEADER ${MASTER_PUB_HDR_FILES}
)
install(TARGETS ${NAME}
EXPORT RmlUiTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
FRAMEWORK DESTINATION Library/Frameworks
)
set(RMLUI_EXPORTED_TARGETS ${RMLUI_EXPORTED_TARGETS} ${NAME})
endif(NOT BUILD_FRAMEWORK)
# Build Lua bindings
if(BUILD_LUA_BINDINGS)
set(LIBRARIES Core Controls)
foreach(library ${LIBRARIES})
set(NAME Rml${library}Lua)
add_library(${NAME} ${Lua${library}_SRC_FILES}
${Lua${library}_HDR_FILES}
${Lua${library}_PUB_HDR_FILES}
)
set_target_properties(${NAME} PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
)
install(TARGETS ${NAME}
EXPORT RmlUiTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
set(RMLUI_EXPORTED_TARGETS ${RMLUI_EXPORTED_TARGETS} ${NAME})
endforeach(library)
endif()
if(DISABLE_RTTI_AND_EXCEPTIONS)
if( CMAKE_COMPILER_IS_GNUCXX )
add_definitions( -fno-rtti -fno-exceptions )
elseif( MSVC )
add_definitions( -D_HAS_EXCEPTIONS=0 /GR- )
if(CMAKE_CXX_FLAGS MATCHES "/EHsc ")
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
message(STATUS "CMAKE_CXX_FLAGS matches /EHsc before end of string replaced...")
endif()
if(CMAKE_CXX_FLAGS MATCHES "/EHsc$")
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
message(STATUS "CMAKE_CXX_FLAGS matches /EHsc at end of string replaced...")
endif()
else()
message(STATUS "Could not create build configuration without rtti and exceptions...")
endif()
endif()
#===================================
# Link libraries ===================
#===================================
if(NOT BUILD_FRAMEWORK)
target_link_libraries(RmlCore ${CORE_LINK_LIBS})
target_link_libraries(RmlControls RmlCore)
target_link_libraries(RmlDebugger RmlCore)
else(NOT BUILD_FRAMEWORK)
target_link_libraries(RmlUi ${CORE_LINK_LIBS})
endif(NOT BUILD_FRAMEWORK)
if(BUILD_LUA_BINDINGS)
if(NOT BUILD_FRAMEWORK)
target_link_libraries(RmlCoreLua RmlCore ${LUA_BINDINGS_LINK_LIBS})
target_link_libraries(RmlControlsLua RmlControls RmlCoreLua ${LUA_BINDINGS_LINK_LIBS})
else(NOT BUILD_FRAMEWORK)
target_link_libraries(RmlCoreLua RmlUi ${LUA_BINDINGS_LINK_LIBS})
target_link_libraries(RmlControlsLua RmlUi RmlCoreLua ${LUA_BINDINGS_LINK_LIBS})
endif(NOT BUILD_FRAMEWORK)
endif()
#===================================
# Build samples ====================
#===================================
# Build and link the samples
macro(bl_sample NAME)
if (WIN32)
add_executable(${NAME} WIN32 ${${NAME}_SRC_FILES} ${${NAME}_HDR_FILES} )
elseif(APPLE)
add_executable(${NAME} MACOSX_BUNDLE ${${NAME}_SRC_FILES} ${${NAME}_HDR_FILES} )
# The first rpath is to the proper location where the framework/library SHOULD be, the second is to the location actually seen
# in the build environment
if(BUILD_FRAMEWORK)
set_target_properties(${NAME} PROPERTIES LINK_FLAGS "-rpath @executable_path/../Frameworks")
else()
set_target_properties(${NAME} PROPERTIES LINK_FLAGS "-rpath @executable_path/../lib")
endif()
else()
add_executable(${NAME} ${${NAME}_SRC_FILES} ${${NAME}_HDR_FILES} )
endif()
target_link_libraries(${NAME} ${ARGN})
endmacro()
if(BUILD_SAMPLES)
include(SampleFileList)
set(samples treeview customlog drag loaddocument transform bitmapfont animation benchmark demo)
set(tutorials template datagrid datagrid_tree drag)
if(NOT BUILD_FRAMEWORK)
set(sample_LIBRARIES
shell
RmlCore
RmlControls
RmlDebugger
)
else(NOT BUILD_FRAMEWORK)
set(sample_LIBRARIES
shell
RmlUi
)
endif(NOT BUILD_FRAMEWORK)
# Find OpenGL
find_package(OpenGL REQUIRED)
if(OPENGL_FOUND)
include_directories(${OPENGL_INCLUDE_DIR})
list(APPEND sample_LIBRARIES ${OPENGL_LIBRARIES})
endif()
# Set up required system libraries
if(APPLE)
include(FindCarbon)
find_package(Carbon REQUIRED)
if (Carbon_FOUND)
include_directories(${Carbon_INCLUDE_DIR})
list(APPEND sample_LIBRARIES ${Carbon_LIBRARIES})
endif()
else()
find_package(X11 REQUIRED)
if (X11_FOUND)
list(APPEND sample_LIBRARIES ${X11_LIBRARIES})
# shell/src/x11/InputX11.cpp:InitialiseX11Keymap uses Xkb if
# possible instead of XGetKeyboardMapping for performance
if(X11_Xkb_FOUND)
FIND_PACKAGE_MESSAGE(X11 "Found X11 KBlib: ${X11_X11_LIB}" "[${X11_X11_LIB}][${X11_XkbINCLUDE_DIR}]")
add_definitions(-DHAS_X11XKBLIB)
endif()
endif()
endif()
set(SAMPLES_DIR opt/RmlUi/Samples CACHE PATH "path to samples dir")
if(WIN32)
mark_as_advanced(SAMPLES_DIR)
endif()
# The samples and tutorials use the shell library
include_directories(${PROJECT_SOURCE_DIR}/Samples/shell/include)
# Build and install sample shell library
add_library(shell STATIC ${shell_SRC_FILES} ${shell_HDR_FILES})
if (PRECOMPILED_HEADERS_ENABLED)
target_precompile_headers(shell PRIVATE ${PROJECT_SOURCE_DIR}/Samples/shell/src/precompiled.h)
endif()
# Build and install the basic samples
foreach(sample ${samples})
bl_sample(${sample} ${sample_LIBRARIES})
# The samples always set this as their current working directory
install(DIRECTORY DESTINATION ${SAMPLES_DIR}/basic/${sample})
install(TARGETS ${sample}
RUNTIME DESTINATION ${SAMPLES_DIR}/${sample}
BUNDLE DESTINATION ${SAMPLES_DIR})
endforeach()
message("-- Can SDL2 sample be built")
find_package(SDL2)
if(SDL2_FOUND)
find_package(SDL2_image)
if(SDL2_IMAGE_FOUND)
find_package(GLEW)
if(GLEW_FOUND)
message("-- Can SDL2 sample be built - yes")
include_directories(${SDL2_INCLUDE_DIR} ${SDL2_IMAGE_INCLUDE_DIR} ${GLEW_INCLUDE_DIR})
bl_sample(sdl2 ${sample_LIBRARIES} ${SDL2_LIBRARY} ${SDL2_IMAGE_LIBRARY} ${GLEW_LIBRARIES})
# The samples always set this as their current working directory
install(DIRECTORY DESTINATION ${SAMPLES_DIR}/basic/sdl2)
install(TARGETS sdl2
RUNTIME DESTINATION ${SAMPLES_DIR}/sdl2
BUNDLE DESTINATION ${SAMPLES_DIR})
else()
message("-- Can SDL2 sample be built - GLEW not found")
endif()
else()
message("-- Can SDL2 sample be built - SDL2_image not found")
endif()
else()
message("-- Can SDL2 sample be built - SDL2 not found")
endif()
message("-- Can SFML 2.x sample be built")
if (WIN32)
find_package(SFML 2 COMPONENTS graphics window system main)
else()
find_package(SFML 2 COMPONENTS graphics window system)
endif()
if(NOT SFML_FOUND)
message("-- Can SFML 2.x sample be built - no")
else()
find_package(GLEW)
if(GLEW_FOUND)
message("-- Can SFML 2.x sample be built - yes: with GLEW")
include_directories(${SFML_INCLUDE_DIR} ${GLEW_INCLUDE_DIR})
add_definitions( -DENABLE_GLEW )
bl_sample(sfml2 ${sample_LIBRARIES} ${SFML_LIBRARIES} ${GLEW_LIBRARIES})
else()
message("-- Can SFML 2.x sample be built - yes: without GLEW")
include_directories(${SFML_INCLUDE_DIR})
bl_sample(sfml2 ${sample_LIBRARIES} ${SFML_LIBRARIES})
endif()
# The samples always set this as their current working directory
install(DIRECTORY DESTINATION ${SAMPLES_DIR}/basic/sfml2)
install(TARGETS sfml2
RUNTIME DESTINATION ${SAMPLES_DIR}/sfml2
BUNDLE DESTINATION ${SAMPLES_DIR})
endif()
# Build and install the tutorials
foreach(tutorial ${tutorials})
set(tutorial_fullname tutorial_${tutorial})
bl_sample(${tutorial_fullname} ${sample_LIBRARIES})
# The tutorials always set this as their current working directory
install(DIRECTORY DESTINATION ${SAMPLES_DIR}/tutorial/${tutorial})
install(TARGETS ${tutorial_fullname}
RUNTIME DESTINATION ${SAMPLES_DIR}/${tutorial}
BUNDLE DESTINATION ${SAMPLES_DIR})
endforeach()
# Build and install invaders sample
bl_sample(invaders ${sample_LIBRARIES})
install(DIRECTORY DESTINATION ${SAMPLES_DIR}/invaders)
install(TARGETS invaders
RUNTIME DESTINATION ${SAMPLES_DIR}/invaders
BUNDLE DESTINATION ${SAMPLES_DIR})
if(BUILD_LUA_BINDINGS)
bl_sample(luainvaders RmlCoreLua RmlControlsLua ${sample_LIBRARIES} ${LUA_BINDINGS_LINK_LIBS})
install(DIRECTORY DESTINATION ${SAMPLES_DIR}/luainvaders)
install(TARGETS luainvaders
RUNTIME DESTINATION ${SAMPLES_DIR}/luainvaders
BUNDLE DESTINATION ${SAMPLES_DIR})
endif()
endif()
#===================================
# Installation =====================
#===================================
if(BUILD_LUA_BINDINGS)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/Include/RmlUi
DESTINATION include
)
else()
install(DIRECTORY ${PROJECT_SOURCE_DIR}/Include/RmlUi
DESTINATION include
PATTERN "Lua" EXCLUDE
)
endif()
if(BUILD_SAMPLES)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/assets
DESTINATION ${SAMPLES_DIR}
)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/tutorial/template/data
DESTINATION ${SAMPLES_DIR}/tutorial/template
)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/tutorial/datagrid/data
DESTINATION ${SAMPLES_DIR}/tutorial/datagrid
)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/tutorial/datagrid_tree/data
DESTINATION ${SAMPLES_DIR}/tutorial/datagrid_tree
)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/tutorial/drag/data
DESTINATION ${SAMPLES_DIR}/tutorial/drag
)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/basic/animation/data
DESTINATION ${SAMPLES_DIR}/basic/animation
)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/basic/benchmark/data
DESTINATION ${SAMPLES_DIR}/basic/benchmark
)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/basic/bitmapfont/data
DESTINATION ${SAMPLES_DIR}/basic/bitmapfont
)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/basic/demo/data
DESTINATION ${SAMPLES_DIR}/basic/demo
)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/basic/transform/data
DESTINATION ${SAMPLES_DIR}/basic/transform
)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/basic/treeview/data
DESTINATION ${SAMPLES_DIR}/basic/treeview
)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/basic/drag/data
DESTINATION ${SAMPLES_DIR}/basic/drag
)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/invaders/data
DESTINATION ${SAMPLES_DIR}/invaders
)
if(BUILD_LUA_BINDINGS)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/luainvaders/data
DESTINATION ${SAMPLES_DIR}/luainvaders
)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/luainvaders/lua
DESTINATION ${SAMPLES_DIR}/luainvaders
)
endif()
endif()
#===================================
# Generate Config.cmake files ======
#===================================
# Try to include helper module
include(CMakePackageConfigHelpers OPTIONAL RESULT_VARIABLE PkgHelpers_AVAILABLE)
# guard against older versions of cmake which do not provide it
if(PkgHelpers_AVAILABLE)
set (INCLUDE_INSTALL_DIR "include")
set (LIB_INSTALL_DIR "lib")
set (INCLUDE_DIR "${PROJECT_SOURCE_DIR}/Include")
# generate configuration for install tree
configure_package_config_file(${PROJECT_SOURCE_DIR}/CMake/RmlUiConfig.cmake.install.in
${CMAKE_CURRENT_BINARY_DIR}/install/RmlUiConfig.cmake
INSTALL_DESTINATION ${LIB_INSTALL_DIR}/RmlUi/cmake
PATH_VARS INCLUDE_INSTALL_DIR LIB_INSTALL_DIR)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/install/RmlUiConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion )
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/install/RmlUiConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/install/RmlUiConfigVersion.cmake
DESTINATION ${LIB_INSTALL_DIR}/RmlUi/cmake )
install(EXPORT RmlUiTargets
DESTINATION ${LIB_INSTALL_DIR}/RmlUi/cmake)
# generate configuration for build tree
configure_package_config_file(${PROJECT_SOURCE_DIR}/CMake/RmlUiConfig.cmake.build.in
${CMAKE_CURRENT_BINARY_DIR}/RmlUiConfig.cmake
INSTALL_DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
PATH_VARS INCLUDE_DIR CMAKE_CURRENT_BINARY_DIR)
export(TARGETS ${RMLUI_EXPORTED_TARGETS}
FILE "${CMAKE_CURRENT_BINARY_DIR}/RmlUiTargets.cmake")
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/RmlUiConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion )
set(RmlUi_DIR "${CMAKE_CURRENT_BINARY_DIR}" CACHE PATH "The directory containing a CMake configuration file for RmlUi.")
else()
message("If you wish to use find_package(RmlUi) in your own project to find RmlUi library"
" please update cmake to version which provides CMakePackageConfighelpers module"
" or write generators for RmlUiConfig.cmake by yourself.")
endif()