Skip to content

Commit 0f1502d

Browse files
committed
switch to the generated MyGUI_Config.h to propagate defines to non-CMake users
1 parent 35e627d commit 0f1502d

4 files changed

Lines changed: 55 additions & 6 deletions

File tree

ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
- Add Ogre builds
3838
- Fix build with fetched msdfgen on Windows
3939
- Fix wrapper build with CMake
40+
- Generate a public MyGUI_Config.h with the build options as defines, so non-CMake users get the correct settings (MYGUI_STATIC, MYGUI_USE_FREETYPE, MYGUI_MSDF_FONTS, MYGUI_DONT_USE_OBSOLETE)
4041

4142
## MyGUI v3.5.0
4243

MyGUIEngine/CMakeLists.txt

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,27 @@ project(${PROJECTNAME})
44

55
include(${PROJECTNAME}.list)
66

7+
# Generate MyGUI_Config.h from template so non-CMake users have the correct defines
8+
set(MYGUI_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}/include")
9+
set(MYGUI_STATIC OFF)
10+
if(NOT BUILD_SHARED_LIBS)
11+
set(MYGUI_STATIC ON)
12+
endif()
13+
configure_file(
14+
"${CMAKE_CURRENT_SOURCE_DIR}/include/MyGUI_Config.h.in"
15+
"${MYGUI_CONFIG_DIR}/MyGUI_Config.h"
16+
@ONLY
17+
)
18+
719
add_library(${PROJECTNAME} ${HEADER_FILES} ${SOURCE_FILES})
820

921
target_include_directories(${PROJECTNAME} PUBLIC
1022
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
23+
$<BUILD_INTERFACE:${MYGUI_CONFIG_DIR}>
1124
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/MYGUI>
1225
)
1326

1427
target_compile_definitions(${PROJECTNAME}
15-
PUBLIC
16-
$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:MYGUI_STATIC>
17-
$<$<BOOL:${MYGUI_DONT_USE_OBSOLETE}>:MYGUI_DONT_USE_OBSOLETE>
18-
$<$<BOOL:${MYGUI_USE_FREETYPE}>:MYGUI_USE_FREETYPE>
19-
$<$<BOOL:${MYGUI_MSDF_FONTS}>:MYGUI_MSDF_FONTS>
2028
PRIVATE
2129
MYGUI_BUILD
2230
)
@@ -47,7 +55,12 @@ mygui_install_target(${PROJECTNAME})
4755

4856
# install MyGUIEngine headers
4957
install(FILES ${HEADER_FILES}
50-
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/MYGUI"
58+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/MYGUI"
59+
)
60+
61+
# install generated configuration header
62+
install(FILES "${MYGUI_CONFIG_DIR}/MyGUI_Config.h"
63+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/MYGUI"
5164
)
5265

5366
set_target_properties(MyGUIEngine PROPERTIES EXPORT_NAME MyGUI)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* This source file is part of MyGUI. For the latest info, see http://mygui.info/
3+
* Distributed under the MIT License
4+
* (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5+
*
6+
* THIS IS A GENERATED FILE. DO NOT EDIT.
7+
* Generated by CMake from MyGUI_Config.h.in. The defines below reflect the
8+
* options used when building this copy of MyGUIEngine.
9+
*/
10+
11+
#ifndef MYGUI_CONFIG_H_
12+
#define MYGUI_CONFIG_H_
13+
14+
// MYGUI_STATIC:
15+
// Define when building or using MyGUIEngine as a static library.
16+
// Disables dllimport/dllexport / visibility attributes.
17+
#cmakedefine MYGUI_STATIC
18+
19+
// MYGUI_DONT_USE_OBSOLETE:
20+
// When defined, deprecated APIs are excluded from the library.
21+
// Otherwise those are [[deprecated]]
22+
#cmakedefine MYGUI_DONT_USE_OBSOLETE
23+
24+
// MYGUI_USE_FREETYPE:
25+
// When defined, TrueType font support via FreeType is enabled.
26+
// Requires linking against Freetype.
27+
#cmakedefine MYGUI_USE_FREETYPE
28+
29+
// MYGUI_MSDF_FONTS:
30+
// When defined, Multi-channel Signed Distance Field font rendering is enabled.
31+
// Implies MYGUI_USE_FREETYPE. Requires msdfgen linkage.
32+
#cmakedefine MYGUI_MSDF_FONTS
33+
34+
#endif // MYGUI_CONFIG_H_

MyGUIEngine/include/MyGUI_Prerequest.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#ifndef MYGUI_PREREQUEST_H_
88
#define MYGUI_PREREQUEST_H_
99

10+
#include "MyGUI_Config.h"
1011
#include "MyGUI_Platform.h"
1112

1213
#define MYGUI_DEFINE_VERSION(major, minor, patch) ((major << 16) | (minor << 8) | patch)

0 commit comments

Comments
 (0)