Merge branch 'cmake-large-files' of https://github.com/MaartenBent/wxWidgets

CMake: Enable large file support and other fixes.

See #23336.
This commit is contained in:
Vadim Zeitlin 2023-03-12 14:01:39 +01:00
commit 19100f63ca
6 changed files with 33 additions and 10 deletions

View file

@ -177,6 +177,9 @@ function(wx_write_config)
foreach(flag IN LISTS wxTOOLKIT_DEFINITIONS)
wx_string_append(WXCONFIG_CPPFLAGS " -D${flag}")
endforeach()
if(wxBUILD_LARGEFILE_SUPPORT)
wx_string_append(WXCONFIG_CPPFLAGS " -D_FILE_OFFSET_BITS=64")
endif()
string(STRIP "${WXCONFIG_CPPFLAGS}" WXCONFIG_CPPFLAGS)
set(WXCONFIG_CXXFLAGS ${WXCONFIG_CFLAGS})
set(WXCONFIG_LDFLAGS_GUI)

View file

@ -160,6 +160,19 @@ function(wx_set_common_target_properties target_name)
)
endif()
if(wxUSE_NO_RTTI)
if(MSVC)
target_compile_options(${target_name} PRIVATE "/GR-")
elseif(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang"))
target_compile_options(${target_name} PRIVATE "-fno-rtti")
endif()
target_compile_definitions(${target_name} PRIVATE "-DwxNO_RTTI")
endif()
if(wxBUILD_LARGEFILE_SUPPORT)
target_compile_definitions(${target_name} PUBLIC "-D_FILE_OFFSET_BITS=64")
endif()
if(CMAKE_USE_PTHREADS_INIT)
target_compile_options(${target_name} PRIVATE "-pthread")
# clang++.exe: warning: argument unused during compilation: '-pthread' [-Wunused-command-line-argument]

View file

@ -101,15 +101,6 @@ if(NOT wxBUILD_COMPATIBILITY STREQUAL "NONE")
endif()
endif()
if(wxUSE_NO_RTTI)
if(MSVC)
add_compile_options("/GR-")
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()
# Build wxBUILD_FILE_ID used for config and setup path
#TODO: build different id for WIN32
set(wxBUILD_FILE_ID "${wxBUILD_TOOLKIT}${wxBUILD_WIDGETSET}-")
@ -341,6 +332,10 @@ if(UNIX)
wx_option_force_value(wxUSE_LIBICONV OFF)
endif()
endif()
if(wxBUILD_LARGEFILE_SUPPORT)
set(HAVE_LARGEFILE_SUPPORT ON)
endif()
endif(UNIX)
if(wxUSE_GUI)

View file

@ -56,6 +56,11 @@ if(NOT MSVC OR MSVC_VERSION GREATER 1800)
${wxCXX_STANDARD_DEFAULT} STRINGS COMPILER_DEFAULT 11 14 17 20)
endif()
if(UNIX)
wx_option(wxBUILD_LARGEFILE_SUPPORT "support for large files")
mark_as_advanced(wxBUILD_LARGEFILE_SUPPORT)
endif()
if(WIN32)
set(wxBUILD_VENDOR "custom" CACHE STRING "Short string identifying your company (used in DLL name)")
endif()

View file

@ -45,6 +45,7 @@ endif()
if(UNIX)
wx_setup_definition(wxUSE_UNIX)
wx_setup_definition(__UNIX__)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_FILE_OFFSET_BITS=64)
endif()
if(UNIX AND NOT APPLE)
@ -346,6 +347,10 @@ if(UNIX)
wx_check_funcs(fdopen)
if(wxBUILD_LARGEFILE_SUPPORT)
wx_check_funcs(fseeko)
endif()
if(wxUSE_TARSTREAM)
wx_check_funcs(sysconf)

View file

@ -114,7 +114,9 @@ Your *CMakeLists.txt* would look like this:
...
find_package(wxWidgets REQUIRED COMPONENTS net core base)
include(${wxWidgets_USE_FILE})
if(wxWidgets_USE_FILE) # not defined in CONFIG mode
include(${wxWidgets_USE_FILE})
endif()
add_executable(myapp myapp.cpp)
target_link_libraries(myapp ${wxWidgets_LIBRARIES})
~~~