CMake: add an option for using preferred release build flags
Add wxUSE_OPTIMISE build option. See #18436. Closes https://github.com/wxWidgets/wxWidgets/pull/1399
This commit is contained in:
parent
c219b53a2d
commit
0be2d94189
@ -37,11 +37,43 @@ if(MSVC)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(wxBUILD_OPTIMISE)
|
||||
set(MSVC_LINKER_RELEASE_FLAGS " /LTCG /OPT:REF /OPT:ICF")
|
||||
wx_string_append(CMAKE_EXE_LINKER_FLAGS_RELEASE "${MSVC_LINKER_RELEASE_FLAGS}")
|
||||
wx_string_append(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${MSVC_LINKER_RELEASE_FLAGS}")
|
||||
wx_string_append(CMAKE_STATIC_LINKER_FLAGS_RELEASE " /LTCG")
|
||||
set(MSVC_COMPILER_RELEASE_FLAGS " /Ox /Oi /Ot /Oy /GS- /Gy /GL /Gw")
|
||||
wx_string_append(CMAKE_CXX_FLAGS_RELEASE "${MSVC_COMPILER_RELEASE_FLAGS}")
|
||||
wx_string_append(CMAKE_C_FLAGS_RELEASE "${MSVC_COMPILER_RELEASE_FLAGS}")
|
||||
endif()
|
||||
|
||||
if(NOT wxBUILD_STRIPPED_RELEASE)
|
||||
set(MSVC_PDB_FLAG " /DEBUG")
|
||||
endif()
|
||||
wx_string_append(CMAKE_EXE_LINKER_FLAGS_RELEASE "${MSVC_PDB_FLAG}")
|
||||
wx_string_append(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${MSVC_PDB_FLAG}")
|
||||
|
||||
if(wxBUILD_MSVC_MULTIPROC)
|
||||
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(wxBUILD_OPTIMISE)
|
||||
set(GCC_PREFERRED_RELEASE_FLAGS " -O2 -fomit-frame-pointer")
|
||||
wx_string_append(CMAKE_CXX_FLAGS_RELEASE "${GCC_PREFERRED_RELEASE_FLAGS}")
|
||||
wx_string_append(CMAKE_C_FLAGS_RELEASE "${GCC_PREFERRED_RELEASE_FLAGS}")
|
||||
endif()
|
||||
|
||||
if(wxBUILD_STRIPPED_RELEASE)
|
||||
set(LD_STRIPPING_FLAG " -s")
|
||||
wx_string_append(CMAKE_EXE_LINKER_FLAGS_RELEASE "${LD_STRIPPING_FLAG}")
|
||||
wx_string_append(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${LD_STRIPPING_FLAG}")
|
||||
else()
|
||||
set(COMPILER_DBGSYM_FLAG " -g")
|
||||
wx_string_append(CMAKE_CXX_FLAGS_RELEASE "${COMPILER_DBGSYM_FLAG}")
|
||||
wx_string_append(CMAKE_C_FLAGS_RELEASE "${COMPILER_DBGSYM_FLAG}")
|
||||
endif()
|
||||
|
||||
if(wxBUILD_USE_STATIC_RUNTIME)
|
||||
if(MINGW)
|
||||
set(STATIC_LINKER_FLAGS " -static")
|
||||
|
@ -47,6 +47,13 @@ if(WIN32)
|
||||
set(wxBUILD_VENDOR "custom" CACHE STRING "Short string identifying your company (used in DLL name)")
|
||||
endif()
|
||||
|
||||
wx_option(wxBUILD_OPTIMISE "use speed-optimised C/C++ compiler flags for release build" OFF)
|
||||
if(MSVC)
|
||||
set(wxBUILD_STRIPPED_RELEASE_DEFAULT OFF)
|
||||
else()
|
||||
set(wxBUILD_STRIPPED_RELEASE_DEFAULT ON)
|
||||
endif()
|
||||
wx_option(wxBUILD_STRIPPED_RELEASE "remove debug symbols in release build" ${wxBUILD_STRIPPED_RELEASE_DEFAULT})
|
||||
wx_option(wxUSE_NO_RTTI "disable RTTI support" OFF)
|
||||
|
||||
# STL options
|
||||
|
Loading…
Reference in New Issue
Block a user