2016-09-25 16:19:39 -04:00
|
|
|
#############################################################################
|
|
|
|
# Name: build/cmake/init.cmake
|
|
|
|
# Purpose: Initialize variables based on user selection and system
|
|
|
|
# information before creating build targets
|
|
|
|
# Author: Tobias Taschner
|
|
|
|
# Created: 2016-09-24
|
|
|
|
# Copyright: (c) 2016 wxWidgets development team
|
|
|
|
# Licence: wxWindows licence
|
|
|
|
#############################################################################
|
|
|
|
|
|
|
|
if(DEFINED wxBUILD_USE_STATIC_RUNTIME AND wxBUILD_USE_STATIC_RUNTIME)
|
|
|
|
# Set MSVC runtime flags for all configurations
|
|
|
|
foreach(cfg "" ${CMAKE_CONFIGURATION_TYPES})
|
|
|
|
set(flag_var CMAKE_CXX_FLAGS)
|
|
|
|
if(cfg)
|
|
|
|
string(TOUPPER ${cfg} cfg_upper)
|
|
|
|
wx_string_append(flag_var "_${cfg_upper}")
|
|
|
|
endif()
|
|
|
|
if(${flag_var} MATCHES "/MD")
|
|
|
|
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
2018-02-08 15:13:44 -05:00
|
|
|
if(wxBUILD_MSVC_MULTIPROC)
|
|
|
|
wx_string_append(CMAKE_C_FLAGS " /MP")
|
|
|
|
wx_string_append(CMAKE_CXX_FLAGS " /MP")
|
|
|
|
endif()
|
|
|
|
|
2016-09-25 16:19:39 -04:00
|
|
|
if(wxBUILD_COMPATIBILITY VERSION_LESS 3.0)
|
|
|
|
set(WXWIN_COMPATIBILITY_2_8 ON)
|
|
|
|
endif()
|
|
|
|
if(wxBUILD_COMPATIBILITY VERSION_LESS 3.1)
|
|
|
|
set(WXWIN_COMPATIBILITY_3_0 ON)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Build wxBUILD_FILE_ID used for config and setup path
|
|
|
|
#TODO: build different id for WIN32
|
|
|
|
set(wxBUILD_FILE_ID "${wxBUILD_TOOLKIT}${wxBUILD_WIDGETSET}-")
|
|
|
|
if(wxUSE_UNICODE)
|
|
|
|
wx_string_append(wxBUILD_FILE_ID "unicode")
|
|
|
|
else()
|
|
|
|
wx_string_append(wxBUILD_FILE_ID "ansi")
|
|
|
|
endif()
|
|
|
|
if(NOT wxBUILD_SHARED)
|
|
|
|
wx_string_append(wxBUILD_FILE_ID "-static")
|
|
|
|
endif()
|
|
|
|
wx_string_append(wxBUILD_FILE_ID "-${wxMAJOR_VERSION}.${wxMINOR_VERSION}")
|
|
|
|
|
|
|
|
set(wxARCH_SUFFIX)
|
|
|
|
|
|
|
|
# TODO: include compiler version in wxCOMPILER_PREFIX ?
|
|
|
|
if(WIN32)
|
2018-08-16 14:12:44 -04:00
|
|
|
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
2016-09-25 16:19:39 -04:00
|
|
|
set(wxCOMPILER_PREFIX "vc")
|
2018-08-16 14:12:44 -04:00
|
|
|
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
2016-09-25 16:19:39 -04:00
|
|
|
set(wxCOMPILER_PREFIX "gcc")
|
2018-08-16 14:12:44 -04:00
|
|
|
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
|
|
|
set(wxCOMPILER_PREFIX "clang")
|
2016-09-25 16:19:39 -04:00
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Unknown WIN32 compiler type")
|
|
|
|
endif()
|
|
|
|
|
2018-05-17 13:30:59 -04:00
|
|
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
2016-09-25 16:19:39 -04:00
|
|
|
set(wxARCH_SUFFIX "_x64")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(wxCOMPILER_PREFIX)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(MSVC OR MINGW)
|
|
|
|
if(wxBUILD_SHARED)
|
|
|
|
set(lib_suffix "dll")
|
|
|
|
else()
|
|
|
|
set(lib_suffix "lib")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(MSVC)
|
2018-08-17 13:15:08 -04:00
|
|
|
# Include generator expression to suppress default Debug/Release pair
|
2016-09-25 16:19:39 -04:00
|
|
|
set(wxPLATFORM_LIB_DIR "$<1:/>${wxCOMPILER_PREFIX}${wxARCH_SUFFIX}_${lib_suffix}")
|
|
|
|
else()
|
|
|
|
set(wxPLATFORM_LIB_DIR "/${wxCOMPILER_PREFIX}${wxARCH_SUFFIX}_${lib_suffix}")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(wxPLATFORM_LIB_DIR)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(wxBUILD_CUSTOM_SETUP_HEADER_PATH)
|
|
|
|
if(NOT EXISTS "${wxBUILD_CUSTOM_SETUP_HEADER_PATH}/wx/setup.h")
|
|
|
|
message(FATAL_ERROR "wxBUILD_CUSTOM_SETUP_HEADER_PATH needs to contain a wx/setup.h file")
|
|
|
|
endif()
|
|
|
|
set(wxSETUP_HEADER_PATH ${wxBUILD_CUSTOM_SETUP_HEADER_PATH})
|
|
|
|
else()
|
|
|
|
# Set path where setup.h will be created
|
|
|
|
if(MSVC OR MINGW)
|
|
|
|
if(wxUSE_UNICODE)
|
|
|
|
set(lib_unicode u)
|
|
|
|
else()
|
|
|
|
set(lib_unicode)
|
|
|
|
endif()
|
|
|
|
set(wxSETUP_HEADER_PATH
|
|
|
|
${wxOUTPUT_DIR}/${wxCOMPILER_PREFIX}${wxARCH_SUFFIX}_${lib_suffix}/${wxBUILD_TOOLKIT}${lib_unicode})
|
|
|
|
file(MAKE_DIRECTORY ${wxSETUP_HEADER_PATH}/wx)
|
|
|
|
file(MAKE_DIRECTORY ${wxSETUP_HEADER_PATH}d/wx)
|
|
|
|
set(wxSETUP_HEADER_FILE_DEBUG ${wxSETUP_HEADER_PATH}d/wx/setup.h)
|
|
|
|
else()
|
|
|
|
set(wxSETUP_HEADER_PATH
|
|
|
|
${wxOUTPUT_DIR}/wx/include/${wxBUILD_FILE_ID})
|
|
|
|
file(MAKE_DIRECTORY ${wxSETUP_HEADER_PATH}/wx)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
set(wxSETUP_HEADER_FILE ${wxSETUP_HEADER_PATH}/wx/setup.h)
|
|
|
|
|
2018-05-17 13:33:19 -04:00
|
|
|
if(DEFINED wxSETUP_HEADER_FILE_DEBUG)
|
2016-09-25 16:19:39 -04:00
|
|
|
# Append configuration specific suffix to setup header path
|
|
|
|
wx_string_append(wxSETUP_HEADER_PATH "$<$<CONFIG:Debug>:d>")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(wxUSE_ON_FATAL_EXCEPTION AND MSVC AND (MSVC_VERSION GREATER 1800) )
|
|
|
|
# see include/wx/msw/seh.h for more details
|
|
|
|
add_compile_options("/EHa")
|
|
|
|
endif()
|
|
|
|
|
2018-10-24 13:47:18 -04:00
|
|
|
if(NOT wxBUILD_DEBUG_LEVEL STREQUAL "Default")
|
|
|
|
add_compile_options("-DwxDEBUG_LEVEL=${wxBUILD_DEBUG_LEVEL}")
|
|
|
|
endif()
|
|
|
|
|
2016-09-25 16:19:39 -04:00
|
|
|
# Constants for setup.h creation
|
|
|
|
set(wxUSE_STD_DEFAULT ON)
|
|
|
|
if(wxUSE_UNICODE)
|
|
|
|
set(wxUSE_WCHAR_T ON)
|
|
|
|
endif()
|
2018-01-27 08:28:23 -05:00
|
|
|
if(NOT wxUSE_EXPAT)
|
|
|
|
set(wxUSE_XRC OFF)
|
2016-09-25 16:19:39 -04:00
|
|
|
endif()
|
2018-01-27 08:28:23 -05:00
|
|
|
set(wxUSE_XML ${wxUSE_XRC})
|
2016-09-25 16:19:39 -04:00
|
|
|
if(wxUSE_CONFIG)
|
|
|
|
set(wxUSE_CONFIG_NATIVE ON)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(DEFINED wxUSE_OLE AND wxUSE_OLE)
|
|
|
|
set(wxUSE_OLE_AUTOMATION ON)
|
2018-01-27 08:28:23 -05:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(wxUSE_OPENGL)
|
|
|
|
set(wxUSE_GLCANVAS ON)
|
2016-09-25 16:19:39 -04:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(wxUSE_THREADS)
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
2018-11-04 10:10:23 -05:00
|
|
|
if(wxUSE_LIBLZMA)
|
|
|
|
find_package(LibLZMA REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(UNIX AND wxUSE_SECRETSTORE)
|
|
|
|
# The required APIs are always available under MSW and OS X but we must
|
|
|
|
# have GNOME libsecret under Unix to be able to compile this class.
|
|
|
|
find_package(Libsecret REQUIRED)
|
|
|
|
if(NOT LIBSECRET_FOUND)
|
|
|
|
message(WARNING "libsecret not found, wxSecretStore won't be available")
|
|
|
|
wx_option_force_value(wxUSE_SECRETSTORE OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2016-09-25 16:19:39 -04:00
|
|
|
if(wxUSE_GUI)
|
2018-09-25 13:41:17 -04:00
|
|
|
if(WXMSW AND wxUSE_METAFILE)
|
2016-09-25 16:19:39 -04:00
|
|
|
# this one should probably be made separately configurable
|
|
|
|
set(wxUSE_ENH_METAFILE ON)
|
|
|
|
endif()
|
|
|
|
|
2018-11-04 10:30:20 -05:00
|
|
|
# Direct2D check
|
|
|
|
if(WIN32 AND wxUSE_GRAPHICS_DIRECT2D)
|
|
|
|
check_include_file(d2d1.h HAVE_D2D1_H)
|
|
|
|
if (NOT HAVE_D2D1_H)
|
|
|
|
wx_option_force_value(wxUSE_GRAPHICS_DIRECT2D OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
if(MSVC) # match setup.h
|
|
|
|
if(MSVC_VERSION LESS 1600)
|
|
|
|
wx_option_force_value(wxUSE_GRAPHICS_DIRECT2D OFF)
|
|
|
|
else()
|
|
|
|
wx_option_force_value(wxUSE_GRAPHICS_DIRECT2D ${wxUSE_GRAPHICS_CONTEXT})
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2018-09-25 13:41:17 -04:00
|
|
|
# WXQT checks
|
|
|
|
if(WXQT)
|
|
|
|
wx_option_force_value(wxUSE_WEBVIEW OFF)
|
|
|
|
wx_option_force_value(wxUSE_METAFILE OFF)
|
|
|
|
if(WIN32)
|
|
|
|
wx_option_force_value(wxUSE_ACCESSIBILITY OFF)
|
2018-10-01 15:43:19 -04:00
|
|
|
wx_option_force_value(wxUSE_OWNER_DRAWN OFF)
|
2018-09-25 13:41:17 -04:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2018-09-30 13:49:54 -04:00
|
|
|
# WXGTK checks, match include/wx/gtk/chkconf.h
|
|
|
|
if(WXGTK)
|
|
|
|
wx_option_force_value(wxUSE_METAFILE OFF)
|
|
|
|
|
|
|
|
if(WIN32)
|
|
|
|
wx_option_force_value(wxUSE_CAIRO ON)
|
|
|
|
wx_option_force_value(wxUSE_ACCESSIBILITY OFF)
|
|
|
|
wx_option_force_value(wxUSE_OWNER_DRAWN OFF)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT UNIX)
|
|
|
|
wx_option_force_value(wxUSE_WEBVIEW OFF)
|
|
|
|
wx_option_force_value(wxUSE_MEDIACTRL OFF)
|
|
|
|
wx_option_force_value(wxUSE_UIACTIONSIMULATOR OFF)
|
|
|
|
wx_option_force_value(wxUSE_OPENGL OFF)
|
|
|
|
set(wxUSE_GLCANVAS OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2018-09-25 13:41:17 -04:00
|
|
|
# extra dependencies
|
2016-09-25 16:19:39 -04:00
|
|
|
if(wxUSE_OPENGL)
|
|
|
|
find_package(OpenGL)
|
|
|
|
if(NOT OPENGL_FOUND)
|
|
|
|
message(WARNING "opengl not found, wxGLCanvas won't be available")
|
|
|
|
wx_option_force_value(wxUSE_OPENGL OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(wxUSE_WEBVIEW AND WXGTK)
|
|
|
|
find_package(LibSoup)
|
2018-12-01 07:38:43 -05:00
|
|
|
if(WXGTK2)
|
|
|
|
find_package(Webkit 1.0)
|
|
|
|
elseif(WXGTK3)
|
|
|
|
find_package(Webkit 3.0)
|
|
|
|
find_package(Webkit2)
|
|
|
|
if(NOT WEBKIT2_FOUND)
|
|
|
|
wx_option_force_value(wxUSE_WEBVIEW_WEBKIT2 OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
if(NOT WEBKIT_FOUND)
|
|
|
|
wx_option_force_value(wxUSE_WEBVIEW_WEBKIT OFF)
|
|
|
|
endif()
|
|
|
|
if((NOT WEBKIT_FOUND AND NOT WEBKIT2_FOUND) OR NOT LIBSOUP_FOUND)
|
2016-09-25 16:19:39 -04:00
|
|
|
message(WARNING "webkit not found, wxWebview won't be available")
|
|
|
|
wx_option_force_value(wxUSE_WEBVIEW OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2018-09-30 13:49:54 -04:00
|
|
|
if(wxUSE_PRIVATE_FONTS AND WXGTK)
|
|
|
|
find_package(Fontconfig)
|
|
|
|
if(NOT FONTCONFIG_FOUND)
|
|
|
|
message(WARNING "Fontconfig not found, Private fonts won't be available")
|
|
|
|
wx_option_force_value(wxUSE_PRIVATE_FONTS OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2016-09-25 16:19:39 -04:00
|
|
|
if(wxUSE_MEDIACTRL AND UNIX AND NOT APPLE AND NOT WIN32)
|
2018-11-04 10:03:59 -05:00
|
|
|
find_package(GStreamer 1.0 COMPONENTS video)
|
|
|
|
if(NOT GSTREAMER_FOUND)
|
|
|
|
find_package(GStreamer 0.10 COMPONENTS interfaces)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(wxUSE_GSTREAMER ${GSTREAMER_FOUND})
|
|
|
|
set(wxUSE_GSTREAMER_PLAYER OFF)
|
|
|
|
if(GSTREAMER_PLAYER_INCLUDE_DIRS)
|
|
|
|
set(wxUSE_GSTREAMER_PLAYER ON)
|
|
|
|
endif()
|
|
|
|
|
2016-09-25 16:19:39 -04:00
|
|
|
if(NOT GSTREAMER_FOUND)
|
|
|
|
message(WARNING "GStreamer not found, wxMediaCtrl won't be available")
|
|
|
|
wx_option_force_value(wxUSE_MEDIACTRL OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|