-
Notifications
You must be signed in to change notification settings - Fork 7.4k
[wxwidgets] Fix usage, add cmake options #17111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
825972a
97887a7
b3f72ef
18603ea
0c86e2e
c6a89eb
b433f84
b371ba8
d31aee1
73a7c25
c46a7ed
a4d51f5
0781b5e
306721a
aeb13f4
6bc3ea5
f4e41de
aa14b27
ee14116
77d7a1b
2916414
86322ea
eb44d59
d37218d
78ec6ad
d7c223a
3dea1fa
07edc7a
8185348
8b34467
f8d98d3
1242197
9cc7939
95d3ad8
82e8f97
c8f9956
2f22c40
9f9b55a
877de69
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,223 @@ | ||
| diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
| index 4063020..6dfe09c 100644 | ||
| --- a/CMakeLists.txt | ||
| +++ b/CMakeLists.txt | ||
| @@ -78,3 +78,51 @@ include(build/cmake/main.cmake) | ||
| if(wxBUILD_SAMPLES AND wxUSE_GUI) | ||
| set_directory_properties(PROPERTIES VS_STARTUP_PROJECT minimal) | ||
| endif() | ||
| + | ||
| +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/unofficial-wxwidgets-config.cmake.in" | ||
| +[[include(CMakeFindDependencyMacro) | ||
| +if (@wxUSE_ZLIB@ STREQUAL "sys") | ||
| + find_dependency(ZLIB) | ||
| +endif() | ||
| +if (@wxUSE_EXPAT@ STREQUAL "sys") | ||
| + find_dependency(EXPAT) | ||
| +endif() | ||
| +if (@wxUSE_LIBJPEG@ STREQUAL "sys") | ||
| + find_dependency(JPEG) | ||
| +endif() | ||
| +if (@wxUSE_LIBPNG@ STREQUAL "sys") | ||
| + find_dependency(PNG) | ||
| +endif() | ||
| +if (@wxUSE_LIBTIFF@ STREQUAL "sys") | ||
| + find_dependency(TIFF) | ||
| +endif() | ||
| + | ||
| +list(APPEND TARGET_FILES wxregex wxscintilla wxbase wxcore) | ||
| +if (@wxUSE_OPENGL@) | ||
| + list(APPEND TARGET_FILES wxgl) | ||
| +endif() | ||
| +if (@wxUSE_XML@) | ||
| + list(APPEND TARGET_FILES wxxml) | ||
| +endif() | ||
| +list(APPEND TARGET_FILES wxhtml wxxrc wxstc wxwebview) | ||
| +if (@wxUSE_SOCKETS@) | ||
| + list(APPEND TARGET_FILES wxnet) | ||
| +endif() | ||
| +list(APPEND TARGET_FILES wxpropgrid) | ||
| +if (@wxUSE_DEBUGREPORT@) | ||
| + list(APPEND TARGET_FILES wxqa) | ||
| +endif() | ||
| +list(APPEND TARGET_FILES wxribbon wxrichtext) | ||
| +if (@wxUSE_MEDIACTRL@) | ||
| + list(APPEND TARGET_FILES wxmedia) | ||
| +endif() | ||
| +list(APPEND TARGET_FILES wxadv wxaui) | ||
| + | ||
| +foreach (TARGET_FILE ${TARGET_FILES}) | ||
| + include("${CMAKE_CURRENT_LIST_DIR}/unofficial-${TARGET_FILE}Targets.cmake") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does this rename the target to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's not
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand. This breaks one of the major selling points of vcpkg IMO. I like vcpkg because it doesn't require special case handling in the application's CMakeLists.txt to use vcpkg versus any other package manager or building packages manually. Without vcpkg I can simply use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Be-ing It doesn't matter, we can add cmake wrapper to use |
||
| +endforeach() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add a |
||
| + | ||
| +set(wxWidgets_CONFIG_EXECUTABLE "${CMAKE_CURRENT_LIST_DIR}/../../tools/wxwidgets/wx-config") | ||
| +]]) | ||
| +configure_file(${CMAKE_CURRENT_BINARY_DIR}/unofficial-wxwidgets-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/unofficial-wxwidgets-config.cmake @ONLY) | ||
| +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unofficial-wxwidgets-config.cmake DESTINATION share/unofficial-wxwidgets) | ||
| \ No newline at end of file | ||
| diff --git a/build/cmake/functions.cmake b/build/cmake/functions.cmake | ||
| index e99555e..468426e 100644 | ||
| --- a/build/cmake/functions.cmake | ||
| +++ b/build/cmake/functions.cmake | ||
| @@ -257,13 +257,20 @@ function(wx_set_target_properties target_name is_base) | ||
| target_include_directories(${target_name} | ||
| BEFORE | ||
| PUBLIC | ||
| - ${wxSETUP_HEADER_PATH} | ||
| - ${wxSOURCE_DIR}/include | ||
| + "$<BUILD_INTERFACE:${wxSETUP_HEADER_PATH}>" | ||
| + "$<BUILD_INTERFACE:${wxSOURCE_DIR}/include>" | ||
| + $<INSTALL_INTERFACE:include> | ||
| ) | ||
|
|
||
| + if (NOT MSVC) | ||
| + target_include_directories(${target_name} | ||
| + PUBLIC $<INSTALL_INTERFACE:include/wx-${wxMAJOR_VERSION}.${wxMINOR_VERSION}> | ||
| + ) | ||
| + endif() | ||
| + | ||
| if(wxTOOLKIT_INCLUDE_DIRS) | ||
| target_include_directories(${target_name} | ||
| - PUBLIC ${wxTOOLKIT_INCLUDE_DIRS}) | ||
| + PUBLIC "$<BUILD_INTERFACE:${wxTOOLKIT_INCLUDE_DIRS}>") | ||
| endif() | ||
|
|
||
| if (WIN32) | ||
| @@ -371,12 +378,14 @@ macro(wx_add_library name) | ||
| set_target_properties(${name} PROPERTIES PROJECT_LABEL ${name_short}) | ||
|
|
||
| # Setup install | ||
| - wx_install(TARGETS ${name} | ||
| + wx_install(TARGETS ${name} EXPORT unofficial-${name}Targets | ||
| LIBRARY DESTINATION "lib${wxPLATFORM_LIB_DIR}" | ||
| ARCHIVE DESTINATION "lib${wxPLATFORM_LIB_DIR}" | ||
| RUNTIME DESTINATION "bin${wxPLATFORM_LIB_DIR}" | ||
| BUNDLE DESTINATION Applications/wxWidgets | ||
| ) | ||
| + | ||
| + install(EXPORT unofficial-${name}Targets NAMESPACE wx:: DESTINATION share/unofficial-wxwidgets) | ||
| endif() | ||
| endmacro() | ||
|
|
||
| @@ -453,7 +462,18 @@ macro(wx_lib_include_directories name) | ||
| if (_LIB_INCLUDE_DIRS_PRIVATE) | ||
| set(INCLUDE_POS BEFORE) | ||
| endif() | ||
| - target_include_directories(${name};${INCLUDE_POS};${ARGN}) | ||
| + if (_LIB_INCLUDE_DIRS_PUBLIC) | ||
| + foreach (PUBLIC_DIR ${_LIB_INCLUDE_DIRS_PUBLIC}) | ||
| + target_include_directories(${name};${INCLUDE_POS};PUBLIC;$<BUILD_INTERFACE:${PUBLIC_DIR}>) | ||
| + endforeach() | ||
| + endif() | ||
| + if (_LIB_INCLUDE_DIRS_PRIVATE) | ||
| + target_include_directories(${name};${INCLUDE_POS};PRIVATE;${_LIB_INCLUDE_DIRS_PRIVATE}) | ||
| + endif() | ||
| + target_include_directories(${name};PUBLIC;$<INSTALL_INTERFACE:include>) | ||
| + if (NOT MSVC) | ||
| + target_include_directories(${name};PUBLIC;$<INSTALL_INTERFACE:include/wx-${wxMAJOR_VERSION}.${wxMINOR_VERSION}>) | ||
| + endif() | ||
| endif() | ||
| endmacro() | ||
|
|
||
| @@ -514,8 +534,14 @@ function(wx_set_builtin_target_properties target_name) | ||
| target_include_directories(${target_name} | ||
| BEFORE | ||
| PUBLIC | ||
| - ${wxSETUP_HEADER_PATH} | ||
| + "$<BUILD_INTERFACE:${wxSETUP_HEADER_PATH}>" | ||
| + $<INSTALL_INTERFACE:include> | ||
| ) | ||
| + if (NOT MSVC) | ||
| + target_include_directories(${target_name} | ||
| + PUBLIC $<INSTALL_INTERFACE:include/wx-${wxMAJOR_VERSION}.${wxMINOR_VERSION}> | ||
| + ) | ||
| + endif() | ||
|
|
||
| set_target_properties(${target_name} PROPERTIES FOLDER "Third Party Libraries") | ||
|
|
||
| @@ -789,10 +815,10 @@ function(wx_add name group) | ||
| endif() | ||
|
|
||
| if(group STREQUAL Samples) | ||
| - target_include_directories(${target_name} PRIVATE ${wxSOURCE_DIR}/samples) | ||
| + target_include_directories(${target_name} PRIVATE "$<BUILD_INTERFACE:${wxSOURCE_DIR}/samples>") | ||
| elseif(group STREQUAL Tests) | ||
| - target_include_directories(${target_name} PRIVATE ${wxSOURCE_DIR}/tests) | ||
| - target_include_directories(${target_name} PRIVATE ${wxSOURCE_DIR}/3rdparty/catch/include) | ||
| + target_include_directories(${target_name} PRIVATE "$<BUILD_INTERFACE:${wxSOURCE_DIR}/tests>") | ||
| + target_include_directories(${target_name} PRIVATE "$<BUILD_INTERFACE:${wxSOURCE_DIR}/3rdparty/catch/include>") | ||
| endif() | ||
|
|
||
| if(APP_DATA) | ||
| diff --git a/build/cmake/lib/CMakeLists.txt b/build/cmake/lib/CMakeLists.txt | ||
| index 5c574c7..5497605 100644 | ||
| --- a/build/cmake/lib/CMakeLists.txt | ||
| +++ b/build/cmake/lib/CMakeLists.txt | ||
| @@ -86,11 +86,11 @@ if(wxBUILD_MONOLITHIC) | ||
| target_link_libraries(wxmono ${vis} ${wxMONO_LIBS_${vis}}) | ||
| endif() | ||
| if(wxMONO_INCLUDE_DIRS_${vis}) | ||
| - set(INCLUDE_POS) | ||
| if (vis STREQUAL PRIVATE) | ||
| - set(INCLUDE_POS BEFORE) | ||
| + target_include_directories(wxmono BEFORE ${vis} ${wxMONO_INCLUDE_DIRS_${vis}}) | ||
| + else() | ||
| + target_include_directories(wxmono ${vis} "$<BUILD_INTERFACE:${wxMONO_INCLUDE_DIRS_${vis}}>") | ||
| endif() | ||
| - target_include_directories(wxmono ${INCLUDE_POS} ${vis} ${wxMONO_INCLUDE_DIRS_${vis}}) | ||
| endif() | ||
| if(wxMONO_DEFINITIONS_${vis}) | ||
| target_compile_definitions(wxmono ${vis} ${wxMONO_DEFINITIONS_${vis}}) | ||
| diff --git a/build/cmake/lib/regex.cmake b/build/cmake/lib/regex.cmake | ||
| index b28fc2c..a78c2da 100644 | ||
| --- a/build/cmake/lib/regex.cmake | ||
| +++ b/build/cmake/lib/regex.cmake | ||
| @@ -18,4 +18,13 @@ if(wxUSE_REGEX) | ||
| target_include_directories(wxregex PRIVATE ${wxSETUP_HEADER_PATH} ${wxSOURCE_DIR}/include) | ||
| set(REGEX_LIBRARIES wxregex) | ||
| set(REGEX_INCLUDE_DIRS ${wxSOURCE_DIR}/src/regex) | ||
| + | ||
| + install(TARGETS wxregex EXPORT unofficial-wxregexTargets | ||
| + LIBRARY DESTINATION "lib${wxPLATFORM_LIB_DIR}" | ||
| + ARCHIVE DESTINATION "lib${wxPLATFORM_LIB_DIR}" | ||
| + RUNTIME DESTINATION "bin${wxPLATFORM_LIB_DIR}" | ||
| + BUNDLE DESTINATION Applications/wxWidgets | ||
| + ) | ||
| + | ||
| + install(EXPORT unofficial-wxregexTargets NAMESPACE wx:: DESTINATION share/unofficial-wxwidgets) | ||
| endif() | ||
| diff --git a/build/cmake/lib/stc/CMakeLists.txt b/build/cmake/lib/stc/CMakeLists.txt | ||
| index bd6acd8..c8c5ff5 100644 | ||
| --- a/build/cmake/lib/stc/CMakeLists.txt | ||
| +++ b/build/cmake/lib/stc/CMakeLists.txt | ||
| @@ -182,6 +182,15 @@ if(wxBUILD_PRECOMP) | ||
| wx_target_enable_precomp(wxscintilla ${wxSCINTILLA_PREC_HEADER}) | ||
| endif() | ||
|
|
||
| +install(TARGETS wxscintilla EXPORT unofficial-wxscintillaTargets | ||
| + LIBRARY DESTINATION "lib${wxPLATFORM_LIB_DIR}" | ||
| + ARCHIVE DESTINATION "lib${wxPLATFORM_LIB_DIR}" | ||
| + RUNTIME DESTINATION "bin${wxPLATFORM_LIB_DIR}" | ||
| + BUNDLE DESTINATION Applications/wxWidgets | ||
| + ) | ||
| + | ||
| +install(EXPORT unofficial-wxscintillaTargets NAMESPACE wx:: DESTINATION share/unofficial-wxwidgets) | ||
| + | ||
| wx_add_library(wxstc ${STC_FILES}) | ||
| wx_lib_include_directories(wxstc PRIVATE | ||
| ${wxSOURCE_DIR}/src/stc/scintilla/include | ||
| diff --git a/build/cmake/lib/webview/CMakeLists.txt b/build/cmake/lib/webview/CMakeLists.txt | ||
| index cc3298f..1d47e56 100644 | ||
| --- a/build/cmake/lib/webview/CMakeLists.txt | ||
| +++ b/build/cmake/lib/webview/CMakeLists.txt | ||
| @@ -132,8 +132,8 @@ if(WXGTK AND wxUSE_WEBVIEW_WEBKIT2) | ||
| ) | ||
|
|
||
| target_include_directories(wxwebkit2_ext PUBLIC | ||
| - ${LIBSOUP_INCLUDE_DIRS} | ||
| - ${WEBKIT2_INCLUDE_DIR} | ||
| + "$<BUILD_INTERFACE:${LIBSOUP_INCLUDE_DIRS}>" | ||
| + "$<BUILD_INTERFACE:${WEBKIT2_INCLUDE_DIR}>" | ||
| ) | ||
| target_link_libraries(wxwebkit2_ext PUBLIC | ||
| ${LIBSOUP_LIBRARIES} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| diff --git a/build/cmake/modules/cotire.cmake b/build/cmake/modules/cotire.cmake | ||
| index bb69643..99b0cb6 100644 | ||
| --- a/build/cmake/modules/cotire.cmake | ||
| +++ b/build/cmake/modules/cotire.cmake | ||
| @@ -2371,7 +2371,7 @@ function (cotire_generate_target_script _language _configurations _target _targe | ||
| # use file(GENERATE ...) to expand generator expressions in the target script at CMake generate-time | ||
| set (_configNameOrNoneGeneratorExpression "$<$<CONFIG:>:None>$<$<NOT:$<CONFIG:>>:$<CONFIGURATION>>") | ||
| set (_targetCotireConfigScript "${CMAKE_CURRENT_BINARY_DIR}/${_target}_${_language}_${_configNameOrNoneGeneratorExpression}_${_moduleName}") | ||
| - file (GENERATE OUTPUT "${_targetCotireConfigScript}" INPUT "${_targetCotireScript}") | ||
| + file (GENERATE OUTPUT "${_targetCotireConfigScript}" INPUT "${_targetCotireScript}" TARGET "${_target}") | ||
| else() | ||
| set (_targetCotireConfigScript "${_targetCotireScript}") | ||
| endif() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| diff --git a/build/cmake/functions.cmake b/build/cmake/functions.cmake | ||
| index 902b7c5..e99555e 100644 | ||
| --- a/build/cmake/functions.cmake | ||
| +++ b/build/cmake/functions.cmake | ||
| @@ -374,7 +374,7 @@ macro(wx_add_library name) | ||
| wx_install(TARGETS ${name} | ||
| LIBRARY DESTINATION "lib${wxPLATFORM_LIB_DIR}" | ||
| ARCHIVE DESTINATION "lib${wxPLATFORM_LIB_DIR}" | ||
| - RUNTIME DESTINATION "lib${wxPLATFORM_LIB_DIR}" | ||
| + RUNTIME DESTINATION "bin${wxPLATFORM_LIB_DIR}" | ||
| BUNDLE DESTINATION Applications/wxWidgets | ||
| ) | ||
| endif() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| diff --git a/build/cmake/install.cmake b/build/cmake/install.cmake | ||
| index 968dff8..4699f63 100644 | ||
| --- a/build/cmake/install.cmake | ||
| +++ b/build/cmake/install.cmake | ||
| @@ -44,10 +44,12 @@ else() | ||
| ) | ||
|
|
||
| install(DIRECTORY DESTINATION "bin") | ||
| + install(FILES ${CMAKE_INSTALL_PREFIX}/lib/wx/config/${wxBUILD_FILE_ID} | ||
| + DESTINATION ${CMAKE_INSTALL_PREFIX}/bin RENAME wx-config | ||
| + ) | ||
| install(CODE "execute_process( \ | ||
| - COMMAND ${CMAKE_COMMAND} -E create_symlink \ | ||
| - ${CMAKE_INSTALL_PREFIX}/lib/wx/config/${wxBUILD_FILE_ID} \ | ||
| - ${CMAKE_INSTALL_PREFIX}/bin/wx-config \ | ||
| + COMMAND sh -c \"chmod u+x \ | ||
| + ${CMAKE_INSTALL_PREFIX}/bin/wx-config\" \ | ||
| )" | ||
| ) | ||
| endif() | ||
| diff --git a/wx-config.in b/wx-config.in | ||
| index 441f88c..ca68a80 100644 | ||
| --- a/wx-config.in | ||
| +++ b/wx-config.in | ||
| @@ -402,7 +402,12 @@ is_cross() { [ "x@cross_compiling@" = "xyes" ]; } | ||
|
|
||
|
|
||
| # Determine the base directories we require. | ||
| -prefix=${input_option_prefix-${this_prefix:-@prefix@}} | ||
| +base_folder=$(dirname $(readlink -f "$0")) | ||
| +if [ "@CMAKE_BUILD_TYPE@" = "Debug" ]; then | ||
| + prefix=${input_option_prefix-${this_prefix:-${base_folder}/../../..}} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Other than in my PR, this doesn't add the |
||
| +else | ||
| + prefix=${input_option_prefix-${this_prefix:-${base_folder}/../..}} | ||
| +fi | ||
| exec_prefix=${input_option_exec_prefix-${input_option_prefix-${this_exec_prefix:-@exec_prefix@}}} | ||
| wxconfdir="@libdir@/wx/config" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| diff --git a/build/cmake/config.cmake b/build/cmake/config.cmake | ||
| index 91d11ac..4e22ee9 100644 | ||
| --- a/build/cmake/config.cmake | ||
| +++ b/build/cmake/config.cmake | ||
| @@ -41,7 +41,40 @@ macro(wx_get_dependencies var lib) | ||
| endif() | ||
| set(dep_name "-l${dep_name}") | ||
| else() | ||
| - get_filename_component(dep_name ${dep} NAME) | ||
| + if (CMAKE_BUILD_TYPE STREQUAL "Release") | ||
| + # For "$<$<CONFIG:DEBUG>:" | ||
| + set(CONFIG_TYPE_INVERT "CONFIG:DEBUG>:") | ||
| + else() | ||
| + # For "$<$<NOT:$<CONFIG:DEBUG>>:" | ||
| + set(CONFIG_TYPE_INVERT "CONFIG:DEBUG>>:") | ||
| + endif() | ||
| + if (dep MATCHES "${CONFIG_TYPE_INVERT}") | ||
| + continue() | ||
| + endif() | ||
| + string(REGEX REPLACE "^.+>:(.+)>$" "\\1" dep_path ${dep}) | ||
| + if (NOT dep_path) | ||
| + set(dep_name ${dep}) | ||
| + else() | ||
| + string(REGEX MATCH "^-.*$" ADDED_PREFIX ${dep_path}) | ||
| + if (ADDED_PREFIX) | ||
| + set(dep_name ${dep_path}) | ||
| + else() | ||
| + get_filename_component(abs_path ${dep_path} PATH) | ||
| + if (NOT abs_path) | ||
| + string(REGEX MATCH "^lib(.*).a$" CURR_STATIC_NAME ${dep_path}) | ||
| + string(REGEX MATCH "^lib(.*).so$" CURR_DYNAMIC_NAME ${dep_path}) | ||
| + if (CURR_STATIC_NAME) | ||
| + set(dep_name "-l${CURR_STATIC_NAME}") | ||
| + elseif (CURR_DYNAMIC_NAME) | ||
| + set(dep_name "-l${CURR_DYNAMIC_NAME}") | ||
| + else() | ||
| + set(dep_name "-l${dep_path}") | ||
| + endif() | ||
| + else() | ||
| + set(dep_name ${dep_path}) | ||
| + endif() | ||
| + endif() | ||
| + endif() | ||
| endif() | ||
| wx_string_append(${var} "${dep_name} ") | ||
| endforeach() |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing wxwebview from this line solves my first issue, but then wxWidgets headers are not included:
I tried adding
${wxWidgets_INCLUDES}to the list of include directories but that did not work. I do not have this issue doingfind_package(wxWidgets)with upstream wxWidgets 3.1.5 build from source manually. However I can reproduce it with my manual build of wxWidgets if I comment out this line from the application's CMakeLists.txt:If I try to use that line with this port, it fails because
wxWidgets_USE_FILEis empty:outputs:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured out the issue with wxwebview. On Linux, wxwebview is only built if WebKitGTK is installed. But on Windows it is always built. So the wxwebview target needs to be exported only when it is actually built.