2016-09-25 16:19:39 -04:00
|
|
|
#############################################################################
|
|
|
|
# Name: build/cmake/config.cmake
|
|
|
|
# Purpose: Build wx-config script in build folder
|
|
|
|
# Author: Tobias Taschner
|
|
|
|
# Created: 2016-10-13
|
|
|
|
# Copyright: (c) 2016 wxWidgets development team
|
|
|
|
# Licence: wxWindows licence
|
|
|
|
#############################################################################
|
|
|
|
|
|
|
|
set(wxCONFIG_DIR ${wxOUTPUT_DIR}/wx/config)
|
|
|
|
file(MAKE_DIRECTORY ${wxCONFIG_DIR})
|
|
|
|
set(TOOLCHAIN_FULLNAME ${wxBUILD_FILE_ID})
|
|
|
|
|
|
|
|
macro(wx_configure_script input output)
|
|
|
|
configure_file(
|
2021-10-27 16:28:06 -04:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/${input}
|
2016-09-25 16:19:39 -04:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${output}
|
|
|
|
ESCAPE_QUOTES @ONLY NEWLINE_STYLE UNIX)
|
|
|
|
file(COPY
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${output}
|
|
|
|
DESTINATION ${wxCONFIG_DIR}
|
|
|
|
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
|
|
|
|
GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
|
|
|
)
|
|
|
|
endmacro()
|
|
|
|
|
2018-12-06 16:38:33 -05:00
|
|
|
macro(wx_get_dependencies var lib)
|
|
|
|
set(${var})
|
2020-05-17 13:41:44 -04:00
|
|
|
if(TARGET wx${lib})
|
|
|
|
get_target_property(deps wx${lib} LINK_LIBRARIES)
|
2018-12-06 16:38:33 -05:00
|
|
|
foreach(dep IN LISTS deps)
|
2019-01-21 05:46:24 -05:00
|
|
|
if(TARGET ${dep})
|
2020-09-25 04:33:59 -04:00
|
|
|
get_target_property(dep_type ${dep} TYPE)
|
|
|
|
if (dep_type STREQUAL "INTERFACE_LIBRARY")
|
|
|
|
get_target_property(dep_name ${dep} INTERFACE_OUTPUT_NAME)
|
|
|
|
else()
|
|
|
|
get_target_property(dep_name ${dep} OUTPUT_NAME)
|
|
|
|
endif()
|
2019-01-21 05:46:24 -05:00
|
|
|
else()
|
2021-06-23 04:14:01 -04:00
|
|
|
# For the value like $<$<CONFIG:DEBUG>:LIB_PATH>
|
|
|
|
# Or $<$<NOT:$<CONFIG:DEBUG>>:LIB_PATH>
|
|
|
|
string(REGEX REPLACE "^.+>:(.+)>$" "\\1" dep_name ${dep})
|
|
|
|
if (NOT dep_name)
|
|
|
|
set(dep_name ${dep})
|
|
|
|
endif()
|
2019-01-21 05:46:24 -05:00
|
|
|
endif()
|
2021-05-10 16:17:14 -04:00
|
|
|
if(dep_name STREQUAL "libc.so")
|
|
|
|
# don't include this library
|
2021-06-23 04:14:01 -04:00
|
|
|
elseif(dep_name MATCHES "^-(.*)$") # -l, -framework, -weak_framework
|
2021-05-04 15:30:29 -04:00
|
|
|
wx_string_append(${var} "${dep_name} ")
|
2021-06-23 04:14:01 -04:00
|
|
|
elseif(dep_name MATCHES "^lib(.*)(.so|.dylib|.tbd|.a)$")
|
2021-05-04 15:30:29 -04:00
|
|
|
wx_string_append(${var} "-l${CMAKE_MATCH_1} ")
|
|
|
|
elseif(dep_name)
|
2021-06-23 04:14:01 -04:00
|
|
|
get_filename_component(abs_path ${dep_name} PATH)
|
|
|
|
if (abs_path) # value contains path
|
|
|
|
wx_string_append(${var} "${dep_name} ")
|
|
|
|
else()
|
|
|
|
wx_string_append(${var} "-l${dep_name} ")
|
|
|
|
endif()
|
2021-05-04 15:30:29 -04:00
|
|
|
endif()
|
2018-12-06 16:38:33 -05:00
|
|
|
endforeach()
|
|
|
|
string(STRIP ${${var}} ${var})
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2016-09-25 16:19:39 -04:00
|
|
|
function(wx_write_config_inplace)
|
|
|
|
wx_configure_script(
|
2021-10-27 16:28:06 -04:00
|
|
|
"wx-config-inplace.in"
|
2016-09-25 16:19:39 -04:00
|
|
|
"inplace-${TOOLCHAIN_FULLNAME}"
|
|
|
|
)
|
2021-10-27 16:27:35 -04:00
|
|
|
if(WIN32_MSVC_NAMING)
|
|
|
|
set(COPY_CMD copy)
|
|
|
|
else()
|
|
|
|
set(COPY_CMD create_symlink)
|
|
|
|
endif()
|
2016-09-25 16:19:39 -04:00
|
|
|
execute_process(
|
|
|
|
COMMAND
|
2021-10-27 16:27:35 -04:00
|
|
|
${CMAKE_COMMAND} -E ${COPY_CMD}
|
2016-09-25 16:19:39 -04:00
|
|
|
"lib/wx/config/inplace-${TOOLCHAIN_FULLNAME}"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/wx-config"
|
|
|
|
)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(wx_write_config)
|
|
|
|
|
2018-12-06 16:32:44 -05:00
|
|
|
set(prefix ${CMAKE_INSTALL_PREFIX})
|
2018-12-06 16:36:57 -05:00
|
|
|
set(exec_prefix "\${prefix}")
|
|
|
|
set(includedir "\${prefix}/include")
|
|
|
|
set(libdir "\${exec_prefix}/lib")
|
|
|
|
set(bindir "\${exec_prefix}/bin")
|
2018-12-06 16:32:44 -05:00
|
|
|
|
2016-09-25 16:19:39 -04:00
|
|
|
find_program(EGREP egrep)
|
2018-11-04 10:08:07 -05:00
|
|
|
mark_as_advanced(EGREP)
|
2018-12-06 16:32:44 -05:00
|
|
|
|
2016-09-25 16:19:39 -04:00
|
|
|
if(wxBUILD_MONOLITHIC)
|
|
|
|
set(MONOLITHIC 1)
|
|
|
|
else()
|
|
|
|
set(MONOLITHIC 0)
|
|
|
|
endif()
|
|
|
|
if(wxBUILD_SHARED)
|
|
|
|
set(SHARED 1)
|
|
|
|
else()
|
|
|
|
set(SHARED 0)
|
|
|
|
endif()
|
|
|
|
if(wxUSE_UNICODE)
|
|
|
|
set(WX_CHARTYPE unicode)
|
2018-12-06 16:36:57 -05:00
|
|
|
set(lib_unicode_suffix u)
|
2016-09-25 16:19:39 -04:00
|
|
|
else()
|
|
|
|
set(WX_CHARTYPE ansi)
|
2018-12-06 16:36:57 -05:00
|
|
|
set(lib_unicode_suffix)
|
2016-09-25 16:19:39 -04:00
|
|
|
endif()
|
2021-04-05 15:26:04 -04:00
|
|
|
if(CMAKE_CROSSCOMPILING)
|
2018-12-06 16:32:44 -05:00
|
|
|
set(cross_compiling yes)
|
|
|
|
set(host_alias ${CMAKE_SYSTEM_NAME})
|
|
|
|
else()
|
|
|
|
set(cross_compiling no)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(BUILT_WX_LIBS)
|
|
|
|
set(STD_BASE_LIBS)
|
|
|
|
set(STD_GUI_LIBS)
|
2018-12-06 16:35:31 -05:00
|
|
|
set(STD_BASE_LIBS_ALL xml net base)
|
|
|
|
set(STD_GUI_LIBS_ALL xrc html qa adv core)
|
|
|
|
foreach(lib IN ITEMS xrc webview stc richtext ribbon propgrid aui gl media html qa adv core xml net base)
|
2020-05-17 13:41:44 -04:00
|
|
|
list(FIND wxLIB_TARGETS wx${lib} hasLib)
|
2018-12-28 13:26:39 -05:00
|
|
|
if (hasLib GREATER -1)
|
2018-12-06 16:35:31 -05:00
|
|
|
wx_string_append(BUILT_WX_LIBS "${lib} ")
|
|
|
|
list(FIND STD_BASE_LIBS_ALL ${lib} index)
|
|
|
|
if (index GREATER -1)
|
|
|
|
wx_string_append(STD_BASE_LIBS "${lib} ")
|
|
|
|
endif()
|
|
|
|
list(FIND STD_GUI_LIBS_ALL ${lib} index)
|
|
|
|
if (index GREATER -1)
|
|
|
|
wx_string_append(STD_GUI_LIBS "${lib} ")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2018-12-24 22:56:59 -05:00
|
|
|
string(STRIP "${BUILT_WX_LIBS}" BUILT_WX_LIBS)
|
|
|
|
string(STRIP "${STD_BASE_LIBS}" STD_BASE_LIBS)
|
|
|
|
string(STRIP "${STD_GUI_LIBS}" STD_GUI_LIBS)
|
2018-12-06 16:32:44 -05:00
|
|
|
|
|
|
|
set(WX_RELEASE ${wxMAJOR_VERSION}.${wxMINOR_VERSION})
|
|
|
|
set(WX_VERSION ${wxVERSION})
|
|
|
|
set(WX_SUBVERSION ${wxVERSION}.0)
|
2016-09-25 16:19:39 -04:00
|
|
|
set(WX_FLAVOUR)
|
2018-12-06 16:32:44 -05:00
|
|
|
set(TOOLKIT_DIR ${wxBUILD_TOOLKIT})
|
|
|
|
set(TOOLKIT_VERSION)
|
|
|
|
set(WIDGET_SET ${wxBUILD_WIDGETSET})
|
2018-12-06 16:36:57 -05:00
|
|
|
set(TOOLCHAIN_NAME "${TOOLKIT_DIR}${TOOLKIT_VERSION}${WIDGET_SET}${lib_unicode_suffix}-${WX_RELEASE}")
|
|
|
|
set(WX_LIBRARY_BASENAME_GUI "wx_${TOOLKIT_DIR}${TOOLKIT_VERSION}${WIDGET_SET}${lib_unicode_suffix}")
|
|
|
|
set(WX_LIBRARY_BASENAME_NOGUI "wx_base${lib_unicode_suffix}")
|
2018-12-06 16:32:44 -05:00
|
|
|
|
2018-12-06 16:38:33 -05:00
|
|
|
wx_get_dependencies(WXCONFIG_LIBS base)
|
|
|
|
wx_get_dependencies(EXTRALIBS_GUI core)
|
|
|
|
set(EXTRALIBS_SDL) # included in core libs when SDL is enabled
|
|
|
|
wx_get_dependencies(EXTRALIBS_HTML html)
|
|
|
|
wx_get_dependencies(EXTRALIBS_STC stc)
|
|
|
|
wx_get_dependencies(EXTRALIBS_WEBVIEW webview)
|
|
|
|
wx_get_dependencies(EXTRALIBS_XML xml)
|
|
|
|
wx_get_dependencies(EXTRALIBS_MEDIA media)
|
|
|
|
wx_get_dependencies(OPENGL_LIBS gl)
|
2018-12-06 16:32:44 -05:00
|
|
|
set(DMALLOC_LIBS)
|
2018-12-28 13:26:39 -05:00
|
|
|
if(wxBUILD_MONOLITHIC)
|
|
|
|
wx_get_dependencies(WXCONFIG_LIBS mono)
|
|
|
|
endif()
|
2018-12-06 16:32:44 -05:00
|
|
|
|
|
|
|
set(CC ${CMAKE_C_COMPILER})
|
|
|
|
set(CXX ${CMAKE_CXX_COMPILER})
|
2016-09-25 16:19:39 -04:00
|
|
|
set(WXCONFIG_CFLAGS)
|
2018-12-06 16:32:44 -05:00
|
|
|
set(WXCONFIG_LDFLAGS)
|
2018-12-06 16:38:33 -05:00
|
|
|
if(CMAKE_USE_PTHREADS_INIT)
|
|
|
|
set(WXCONFIG_CFLAGS "-pthread")
|
|
|
|
set(WXCONFIG_LDFLAGS "-pthread")
|
|
|
|
endif()
|
2021-04-29 15:39:15 -04:00
|
|
|
set(WXCONFIG_CPPFLAGS)
|
|
|
|
if(wxBUILD_SHARED)
|
|
|
|
wx_string_append(WXCONFIG_CPPFLAGS " -DWXUSINGDLL")
|
|
|
|
endif()
|
2018-12-06 16:38:33 -05:00
|
|
|
foreach(flag IN LISTS wxTOOLKIT_DEFINITIONS)
|
|
|
|
wx_string_append(WXCONFIG_CPPFLAGS " -D${flag}")
|
|
|
|
endforeach()
|
2021-04-29 15:39:15 -04:00
|
|
|
string(STRIP "${WXCONFIG_CPPFLAGS}" WXCONFIG_CPPFLAGS)
|
2018-12-06 16:38:33 -05:00
|
|
|
set(WXCONFIG_CXXFLAGS ${WXCONFIG_CFLAGS})
|
2016-09-25 16:19:39 -04:00
|
|
|
set(WXCONFIG_LDFLAGS_GUI)
|
|
|
|
set(WXCONFIG_RESFLAGS)
|
2018-12-06 16:38:33 -05:00
|
|
|
set(WXCONFIG_RPATH "-Wl,-rpath,\$libdir")
|
2018-12-06 16:32:44 -05:00
|
|
|
set(LDFLAGS_GL)
|
|
|
|
set(RESCOMP)
|
2016-09-25 16:19:39 -04:00
|
|
|
|
|
|
|
wx_configure_script(
|
2021-10-27 16:28:06 -04:00
|
|
|
"wx-config.in"
|
2016-09-25 16:19:39 -04:00
|
|
|
"${TOOLCHAIN_FULLNAME}"
|
|
|
|
)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
wx_write_config_inplace()
|
|
|
|
wx_write_config()
|