forked from wxFormBuilder/wxFormBuilder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
112 lines (98 loc) · 4.41 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
cmake_minimum_required(VERSION 3.21)
# Do not change the format of this line! It must stay as-is up to and including the keyword LANGUAGES.
# External tools parse the version number from this line.
project(wxFormBuilder VERSION 4.2.1 LANGUAGES CXX)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
include(cmake/functions.cmake)
wxfb_set_default_build_type()
wxfb_set_default_compiler_options()
wxfb_set_language_standard(CXX_STANDARD 17)
if(PROJECT_IS_TOP_LEVEL)
set_property(GLOBAL PROPERTY USE_FOLDERS YES)
endif()
option(WXFB_WXWIDGETS_ENABLE_30 "Allow using wxWidgets version 3.0.x. Not recommended, only for platforms without wxWidgets version 3.2.x." OFF)
option(WXFB_TINYXML2_SHARED "Use shared variant of TinyXML-2." OFF)
option(WXFB_BUILD_PLUGIN_HOST "Build as plugin host. Disables build steps that must be performed by the toplevel project." OFF)
if(PROJECT_IS_TOP_LEVEL OR WXFB_BUILD_PLUGIN_HOST)
set(stageBuildDefault ON)
else()
# TODO: Maybe check if the required variables are all unset and enable by default in that case
set(stageBuildDefault OFF)
endif()
option(WXFB_STAGE_BUILD "Use stage directory to build directly executable variant that doesn't need to be installed." ${stageBuildDefault})
unset(stageBuildDefault)
option(WXFB_ENABLE_EXTRA_CHECKS "Enable additional static code analysis." OFF)
# TODO: Currently generator languages cannot be configured
set(WXFB_GENERATOR_LANGUAGES cpp python lua php CACHE INTERNAL "")
# Adjust paths to match wxStandardPaths implementation, use own cache variables to share across CMake scopes
include(GNUInstallDirs)
if(WIN32)
set(WXFB_INSTALL_BINDIR . CACHE INTERNAL "")
set(WXFB_INSTALL_LIBDIR . CACHE INTERNAL "")
set(WXFB_INSTALL_DATADIR . CACHE INTERNAL "")
elseif(APPLE)
set(WXFB_INSTALL_BINDIR . CACHE INTERNAL "")
set(WXFB_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR} CACHE INTERNAL "")
set(WXFB_INSTALL_DATADIR wxFormBuilder.app/Contents/SharedSupport CACHE INTERNAL "")
else()
set(WXFB_INSTALL_BINDIR ${CMAKE_INSTALL_BINDIR} CACHE INTERNAL "")
set(WXFB_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR} CACHE INTERNAL "")
set(WXFB_INSTALL_DATADIR ${CMAKE_INSTALL_DATADIR}/wxformbuilder CACHE INTERNAL "")
endif()
# Define internal stage directory only if enabled
if(WXFB_STAGE_BUILD)
get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
set(WXFB_STAGE_DIR "${CMAKE_CURRENT_BINARY_DIR}/stage$<$<BOOL:${isMultiConfig}>:/$<CONFIG>>" CACHE INTERNAL "")
unset(isMultiConfig)
else()
unset(WXFB_STAGE_DIR CACHE)
endif()
if(WXFB_ENABLE_EXTRA_CHECKS)
set(extraOptions "")
if(WIN32 AND NOT MSYS)
list(APPEND extraOptions PATH_SUFFIXES LLVM/bin)
endif()
find_program(clang-tidy_cmd NAMES clang-tidy ${extraOptions} REQUIRED)
mark_as_advanced(clang-tidy_cmd)
unset(extraOptions)
set(CMAKE_CXX_CLANG_TIDY "${clang-tidy_cmd}")
endif()
include(cmake/variable.cmake)
# BUILD_SHARED_LIBS does only affect win32 search style, wxWidgets_USE_STATIC does only affect unix search style
stash_variable(BUILD_SHARED_LIBS VALUE ON)
set(wxWidgets_USE_STATIC OFF)
if(NOT WXFB_WXWIDGETS_ENABLE_30)
set(wxWidgetsVersion 3.2)
else()
set(wxWidgetsVersion 3.0)
endif()
# TODO: OPTIONAL_COMPONENTS seems to be broken currently (at least on Linux), so make media a required component
set(wxWidgetsComponentsRequired media xrc richtext propgrid ribbon stc html aui core net xml base)
if(WXFB_WXWIDGETS_ENABLE_30)
list(PREPEND wxWidgetsComponentsRequired adv)
endif()
find_package(wxWidgets ${wxWidgetsVersion} CONFIG COMPONENTS ${wxWidgetsComponentsRequired})
if(NOT wxWidgets_FOUND)
find_package(wxWidgets ${wxWidgetsVersion} MODULE REQUIRED ${wxWidgetsComponentsRequired})
endif()
wxfb_create_target_wxwidgets(COMPONENTS ${wxWidgetsComponentsRequired})
unset(wxWidgetsVersion)
unset(wxWidgetsComponentsRequired)
restore_variable(BUILD_SHARED_LIBS)
# TODO: Some Boost packages do not include the CMake config files so config mode with the headers component can't be used
find_package(Boost 1.71.0 REQUIRED)
include(cmake/macros.cmake)
include(cmake/revision.cmake)
include(cmake/version.cmake)
wxfb_configure_prebuild()
add_subdirectory(src)
add_subdirectory(plugins)
add_subdirectory(sdk)
add_subdirectory(third_party/md5)
add_subdirectory(third_party/stack_trace)
stash_variable(BUILD_SHARED_LIBS ${WXFB_TINYXML2_SHARED})
add_subdirectory(third_party/tinyxml2 EXCLUDE_FROM_ALL)
restore_variable(BUILD_SHARED_LIBS)
if(NOT WXFB_BUILD_PLUGIN_HOST)
wxfb_configure_postbuild()
endif()