Merge branch 'cmake-fixes' of https://github.com/MaartenBent/wxWidgets
Miscellaneous fixes to CMake build system: fix some warnings, make it more consistent with configure and more. See https://github.com/wxWidgets/wxWidgets/pull/1430 See #18438.
This commit is contained in:
@@ -17,16 +17,25 @@ if(NOT CMAKE_CONFIGURATION_TYPES)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# https://blog.kitware.com/cmake-and-the-default-build-type/
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
set(default_build_type "Debug")
|
||||
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
|
||||
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE)
|
||||
# Set the possible values of build type for cmake-gui
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release")
|
||||
endif()
|
||||
|
||||
if(APPLE AND NOT CMAKE_OSX_DEPLOYMENT_TARGET)
|
||||
# If no deployment target has been set default to the minimum supported
|
||||
# OS X version (this has to be set before the first project() call)
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.9 CACHE STRING "OS X Deployment Target")
|
||||
endif()
|
||||
|
||||
project(wxWidgets)
|
||||
|
||||
include(build/cmake/policies.cmake NO_POLICY_SCOPE)
|
||||
|
||||
project(wxWidgets)
|
||||
|
||||
# Initialize variables for quick access to wx root dir in sub dirs
|
||||
set(wxSOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set(wxBINARY_DIR ${CMAKE_BINARY_DIR})
|
||||
|
@@ -98,11 +98,15 @@ function(wx_set_common_target_properties target_name)
|
||||
ARCHIVE_OUTPUT_DIRECTORY "${wxOUTPUT_DIR}${wxPLATFORM_LIB_DIR}"
|
||||
RUNTIME_OUTPUT_DIRECTORY "${wxOUTPUT_DIR}${wxPLATFORM_LIB_DIR}"
|
||||
)
|
||||
if(NOT wxCOMMON_TARGET_PROPS_DEFAULT_WARNINGS)
|
||||
# Enable higher warnings for most compilers/IDEs
|
||||
if(MSVC)
|
||||
target_compile_options(${target_name} PRIVATE /W4)
|
||||
|
||||
if(MSVC)
|
||||
if(wxCOMMON_TARGET_PROPS_DEFAULT_WARNINGS)
|
||||
set(MSVC_WARNING_LEVEL "/W3")
|
||||
else()
|
||||
set(MSVC_WARNING_LEVEL "/W4")
|
||||
endif()
|
||||
target_compile_options(${target_name} PRIVATE ${MSVC_WARNING_LEVEL})
|
||||
else()
|
||||
# TODO: add warning flags for other compilers
|
||||
endif()
|
||||
|
||||
|
@@ -57,7 +57,12 @@ if(MSVC)
|
||||
wx_string_append(CMAKE_C_FLAGS " /MP")
|
||||
wx_string_append(CMAKE_CXX_FLAGS " /MP")
|
||||
endif()
|
||||
elseif(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
|
||||
|
||||
if(NOT POLICY CMP0092)
|
||||
string(REGEX REPLACE "/W[0-4]" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
string(REGEX REPLACE "/W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
endif()
|
||||
elseif(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang"))
|
||||
if(wxBUILD_OPTIMISE)
|
||||
set(GCC_PREFERRED_RELEASE_FLAGS " -O2 -fomit-frame-pointer")
|
||||
wx_string_append(CMAKE_CXX_FLAGS_RELEASE "${GCC_PREFERRED_RELEASE_FLAGS}")
|
||||
@@ -95,8 +100,8 @@ endif()
|
||||
if(wxUSE_NO_RTTI)
|
||||
if(MSVC)
|
||||
add_compile_options("/GR-")
|
||||
elseif(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
|
||||
add_compile_options("-fno-rtti")
|
||||
elseif(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang"))
|
||||
wx_string_append(CMAKE_CXX_FLAGS " -fno-rtti")
|
||||
endif()
|
||||
add_definitions("-DwxNO_RTTI")
|
||||
endif()
|
||||
|
@@ -176,7 +176,7 @@ if(wxBUILD_PRECOMP)
|
||||
# standard c++ headers when using clang.
|
||||
# Do not disable precompiled headers entirely but use the main Scintilla
|
||||
# header as prefix header so there is at least a small speedup.
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
set(wxSCINTILLA_PREC_HEADER "${wxSOURCE_DIR}/src/stc/scintilla/include/Scintilla.h")
|
||||
endif()
|
||||
wx_target_enable_precomp(wxscintilla ${wxSCINTILLA_PREC_HEADER})
|
||||
|
@@ -285,7 +285,7 @@ wx_option(wxUSE_COMBOCTRL "use wxComboCtrl class")
|
||||
wx_option(wxUSE_COMMANDLINKBUTTON "use wxCommmandLinkButton class")
|
||||
wx_option(wxUSE_DATAVIEWCTRL "use wxDataViewCtrl class")
|
||||
wx_option(wxUSE_DATEPICKCTRL "use wxDatePickerCtrl class")
|
||||
wx_option(wxUSE_DETECT_SM "_sm use code to detect X11 session manager")
|
||||
wx_option(wxUSE_DETECT_SM "use code to detect X11 session manager" OFF)
|
||||
wx_option(wxUSE_DIRPICKERCTRL "use wxDirPickerCtrl class")
|
||||
wx_option(wxUSE_DISPLAY "use wxDisplay class")
|
||||
wx_option(wxUSE_EDITABLELISTBOX "use wxEditableListBox class")
|
||||
|
@@ -58,3 +58,8 @@ if(POLICY CMP0072)
|
||||
# FindOpenGL prefers GLVND by default when available.
|
||||
cmake_policy(SET CMP0072 NEW)
|
||||
endif()
|
||||
|
||||
if(POLICY CMP0092)
|
||||
# MSVC warning flags are not in CMAKE_<LANG>_FLAGS by default
|
||||
cmake_policy(SET CMP0092 NEW)
|
||||
endif()
|
||||
|
Reference in New Issue
Block a user