Enable using PIC by default even for static libraries and several other
build-related fixes (warning fixes etc).

See https://github.com/wxWidgets/wxWidgets/pull/2008
This commit is contained in:
Vadim Zeitlin
2020-08-08 02:01:06 +02:00
19 changed files with 119 additions and 44 deletions

View File

@@ -83,6 +83,10 @@ function(wx_set_common_target_properties target_name)
RUNTIME_OUTPUT_DIRECTORY "${wxOUTPUT_DIR}${wxPLATFORM_LIB_DIR}"
)
if(wxBUILD_PIC)
set_target_properties(${target_name} PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
endif()
if(MSVC)
if(wxCOMMON_TARGET_PROPS_DEFAULT_WARNINGS)
set(MSVC_WARNING_LEVEL "/W3")
@@ -340,7 +344,7 @@ macro(wx_add_library name)
add_library(${name} ${wxBUILD_LIB_TYPE} ${src_files})
add_library(wx::${name_short} ALIAS ${name})
wx_set_target_properties(${name} ${wxADD_LIBRARY_IS_BASE})
set_property(TARGET ${name} PROPERTY PROJECT_LABEL ${name_short})
set_target_properties(${name} PROPERTIES PROJECT_LABEL ${name_short})
# Setup install
wx_install(TARGETS ${name}
@@ -498,6 +502,10 @@ function(wx_set_builtin_target_properties target_name)
set_target_properties(${target_name} PROPERTIES FOLDER "Third Party Libraries")
if(wxBUILD_SHARED OR wxBUILD_PIC)
set_target_properties(${target_name} PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
endif()
wx_set_common_target_properties(${target_name} DEFAULT_WARNINGS)
if(NOT wxBUILD_SHARED)
wx_install(TARGETS ${name} ARCHIVE DESTINATION "lib${wxPLATFORM_LIB_DIR}")
@@ -517,10 +525,7 @@ function(wx_add_builtin_library name)
add_library(${name} STATIC ${src_list})
add_library(wx::${name_short} ALIAS ${name})
wx_set_builtin_target_properties(${name})
set_property(TARGET ${name} PROPERTY PROJECT_LABEL ${name_short})
if(wxBUILD_SHARED)
set_target_properties(${name} PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
endif()
set_target_properties(${name} PROPERTIES PROJECT_LABEL ${name_short})
endfunction()
# List of third party libraries added via wx_add_thirdparty_library()

View File

@@ -8,6 +8,8 @@
#############################################################################
if(wxUSE_EXPAT STREQUAL "builtin")
# TODO: implement building expat via its CMake file, using
# add_subdirectory or ExternalProject_Add
wx_add_builtin_library(wxexpat
src/expat/expat/lib/xmlparse.c
src/expat/expat/lib/xmlrole.c

View File

@@ -8,6 +8,8 @@
#############################################################################
if(wxUSE_LIBPNG STREQUAL "builtin")
# TODO: implement building libpng via its CMake file, using
# add_subdirectory or ExternalProject_Add
if(NOT MSVC)
set(PNG_EXTRA_SOURCES
src/png/mips/filter_msa_intrinsics.c

View File

@@ -8,7 +8,6 @@
#############################################################################
if(wxUSE_REGEX)
# TODO: Forcing builtin until sys is implemented
set(wxUSE_REGEX builtin)
wx_add_builtin_library(wxregex
src/regex/regcomp.c
@@ -20,5 +19,3 @@ if(wxUSE_REGEX)
set(REGEX_LIBRARIES wxregex)
set(REGEX_INCLUDE_DIRS ${wxSOURCE_DIR}/src/regex)
endif()
#TODO: find external lib and include dir

View File

@@ -8,13 +8,8 @@
#############################################################################
if(wxUSE_LIBTIFF STREQUAL "builtin")
# TODO: implement building libtiff via ExternalProject_Add()
if(UNIX AND NOT APPLE)
message(WARNING "Builtin libtiff on unix is currently not supported")
wx_option_force_value(wxUSE_LIBTIFF OFF)
return()
endif()
# TODO: implement building libtiff via its CMake file, using
# add_subdirectory or ExternalProject_Add
if(WIN32)
set(TIFF_PLATFORM_SRC src/tiff/libtiff/tif_win32.c)
elseif(UNIX)

View File

@@ -8,6 +8,8 @@
#############################################################################
if(wxUSE_ZLIB STREQUAL "builtin")
# TODO: implement building zlib via its CMake file, using
# add_subdirectory or ExternalProject_Add
wx_add_builtin_library(wxzlib
src/zlib/adler32.c
src/zlib/compress.c

View File

@@ -9,6 +9,7 @@ SET( WEBKIT2_VERSION 4.0)
set(WEBKIT2_INCLUDE_DIR WEBKIT2_INCLUDE_DIR-NOTFOUND)
set(WEBKIT2_LIBRARY WEBKIT2_LIBRARY-NOTFOUND)
set(WEBKIT2_JS_LIBRARY WEBKIT2_JS_LIBRARY-NOTFOUND)
set(WEBKIT2_LIBRARIES WEBKIT2_LIBRARIES-NOTFOUND)
FIND_PATH(WEBKIT2_INCLUDE_DIR webkit2/webkit2.h
@@ -20,6 +21,11 @@ FIND_LIBRARY(WEBKIT2_LIBRARY
NAMES ${WEBKIT2_NAMES}
)
SET(WEBKIT2_JS_NAMES "javascriptcoregtk-${WEBKIT2_VERSION}")
FIND_LIBRARY(WEBKIT2_JS_LIBRARY
NAMES ${WEBKIT2_JS_NAMES}
)
# Handle the QUIETLY and REQUIRED arguments and set WEBKIT2_FOUND to
# TRUE if all listed variables are TRUE.
INCLUDE(FindPackageHandleStandardArgs)
@@ -29,7 +35,7 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(
)
IF(WEBKIT2_FOUND)
SET( WEBKIT2_LIBRARIES ${WEBKIT2_LIBRARY} )
SET( WEBKIT2_LIBRARIES ${WEBKIT2_LIBRARY} ${WEBKIT2_JS_LIBRARY} )
ELSE(WEBKIT2_FOUND)
SET( WEBKIT2_LIBRARIES )
ENDIF(WEBKIT2_FOUND)

View File

@@ -64,6 +64,8 @@ else()
endif()
wx_option(wxBUILD_STRIPPED_RELEASE "remove debug symbols in release build" ${wxBUILD_STRIPPED_RELEASE_DEFAULT})
mark_as_advanced(wxBUILD_STRIPPED_RELEASE)
wx_option(wxBUILD_PIC "Enable position independent code (PIC)." ON)
mark_as_advanced(wxBUILD_PIC)
wx_option(wxUSE_NO_RTTI "disable RTTI support" OFF)
# STL options

View File

@@ -42,7 +42,7 @@ wx_add_sample(docview docview.cpp doc.cpp view.cpp docview.h doc.h view.h
wx_add_sample(dragimag dragimag.cpp dragimag.h RES dragimag.rc
DATA backgrnd.png shape01.png shape02.png shape03.png
DEPENDS wxUSE_DRAGIMAGE)
wx_add_sample(drawing DATA pat4.bmp pat35.bmp pat36.bmp image.bmp mask.bmp)
wx_add_sample(drawing DATA pat4.bmp pat35.bmp pat36.bmp image.bmp mask.bmp NAME drawingsample)
wx_add_sample(erase)
wx_add_sample(event event.cpp gestures.cpp gestures.h chessboard.cpp chessboard.h)
wx_add_sample(except DEPENDS wxUSE_EXCEPTIONS)
@@ -71,7 +71,7 @@ wx_add_sample(image image.cpp canvas.cpp canvas.h cursor_png.c RES image.rc
DATA horse.png horse.jpg horse.bmp horse.gif horse.pcx horse.pnm
horse_ag.pnm horse_rg.pnm horse.tif horse.tga horse.xpm horse.cur
horse.ico horse3.ani smile.xbm toucan.png cmyk.jpg cursor.png
DEPENDS wxUSE_IMAGE)
NAME imagesample DEPENDS wxUSE_IMAGE)
foreach(lang ar bg cs de fr it ka pl ru sv ja ja_JP.EUC-JP)
list(APPEND INTERNAT_DATA_FILES ${lang}/internat.po ${lang}/internat.mo)
endforeach()

View File

@@ -587,14 +587,11 @@ foreach(func
endforeach()
# Check various functions
foreach(func
fsync
snprintf vsnprintf strnlen strtoull
setpriority
)
string(TOUPPER ${func} func_upper)
check_function_exists(${func} HAVE_${func_upper})
endforeach()
wx_check_funcs(fsync
snprintf vsnprintf strnlen strtoull
setpriority
gettimeofday
)
if(MSVC)
check_symbol_exists(vsscanf stdio.h HAVE_VSSCANF)
@@ -643,7 +640,6 @@ cmake_pop_check_state()
if(HAVE_DLOPEN)
check_symbol_exists(dladdr dlfcn.h HAVE_DLADDR)
endif()
check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
if(APPLE)
set(wxUSE_EPOLL_DISPATCHER OFF)