Merge branch 'cmake-wxconfig' of https://github.com/MaartenBent/wxWidgets
Make CMake build more similar to the autotools one: install the headers into the same directory and produce working wx-config. See https://github.com/wxWidgets/wxWidgets/pull/1051
This commit is contained in:
@@ -27,6 +27,18 @@ macro(wx_configure_script input output)
|
||||
)
|
||||
endmacro()
|
||||
|
||||
macro(wx_get_dependencies var lib)
|
||||
set(${var})
|
||||
if(TARGET ${lib})
|
||||
get_target_property(deps ${lib} LINK_LIBRARIES)
|
||||
foreach(dep IN LISTS deps)
|
||||
get_filename_component(name ${dep} NAME)
|
||||
wx_string_append(${var} "${name} ")
|
||||
endforeach()
|
||||
string(STRIP ${${var}} ${var})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
function(wx_write_config_inplace)
|
||||
wx_configure_script(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/wx-config-inplace.in"
|
||||
@@ -42,75 +54,101 @@ endfunction()
|
||||
|
||||
function(wx_write_config)
|
||||
|
||||
# TODO: set variables
|
||||
set(includedir "$")
|
||||
wx_string_append(includedir "{prefix}/include")
|
||||
set(libdir "$")
|
||||
wx_string_append(libdir "{exec_prefix}/lib")
|
||||
set(bindir "$")
|
||||
wx_string_append(bindir "{exec_prefix}/bin")
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
set(cross_compiling yes)
|
||||
else()
|
||||
set(cross_compiling no)
|
||||
endif()
|
||||
set(prefix ${CMAKE_INSTALL_PREFIX})
|
||||
set(exec_prefix $)
|
||||
wx_string_append(exec_prefix "{prefix}")
|
||||
set(BUILT_WX_LIBS)
|
||||
foreach(lib IN LISTS wxLIB_TARGETS)
|
||||
wx_string_append(BUILT_WX_LIBS " ${lib}")
|
||||
endforeach()
|
||||
set(CC ${CMAKE_C_COMPILER})
|
||||
set(CXX ${CMAKE_CXX_COMPILER})
|
||||
set(DMALLOC_LIBS)
|
||||
set(exec_prefix "\${prefix}")
|
||||
set(includedir "\${prefix}/include")
|
||||
set(libdir "\${exec_prefix}/lib")
|
||||
set(bindir "\${exec_prefix}/bin")
|
||||
|
||||
find_program(EGREP egrep)
|
||||
mark_as_advanced(EGREP)
|
||||
set(EXTRALIBS_GUI)
|
||||
set(EXTRALIBS_HTML)
|
||||
set(EXTRALIBS_SDL)
|
||||
set(EXTRALIBS_STC)
|
||||
set(EXTRALIBS_WEBVIEW)
|
||||
set(EXTRALIBS_XML)
|
||||
set(LDFLAGS_GL)
|
||||
|
||||
if(wxBUILD_MONOLITHIC)
|
||||
set(MONOLITHIC 1)
|
||||
else()
|
||||
set(MONOLITHIC 0)
|
||||
endif()
|
||||
set(OPENGL_LIBS)
|
||||
set(RESCOMP)
|
||||
if(wxBUILD_SHARED)
|
||||
set(SHARED 1)
|
||||
else()
|
||||
set(SHARED 0)
|
||||
endif()
|
||||
if(wxUSE_UNICODE)
|
||||
set(WX_CHARTYPE unicode)
|
||||
set(lib_unicode_suffix u)
|
||||
else()
|
||||
set(WX_CHARTYPE ansi)
|
||||
set(lib_unicode_suffix)
|
||||
endif()
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
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)
|
||||
#TODO: setting TOOLCHAIN_NAME produces change results in config folder
|
||||
# set(TOOLCHAIN_NAME)
|
||||
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)
|
||||
if(TARGET ${lib})
|
||||
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()
|
||||
string(STRIP ${BUILT_WX_LIBS} BUILT_WX_LIBS)
|
||||
string(STRIP ${STD_BASE_LIBS} STD_BASE_LIBS)
|
||||
string(STRIP ${STD_GUI_LIBS} STD_GUI_LIBS)
|
||||
|
||||
set(WX_RELEASE ${wxMAJOR_VERSION}.${wxMINOR_VERSION})
|
||||
set(WX_VERSION ${wxVERSION})
|
||||
set(WX_SUBVERSION ${wxVERSION}.0)
|
||||
set(WX_FLAVOUR)
|
||||
set(TOOLKIT_DIR ${wxBUILD_TOOLKIT})
|
||||
set(TOOLKIT_VERSION)
|
||||
set(WIDGET_SET ${wxBUILD_WIDGETSET})
|
||||
if(wxUSE_UNICODE)
|
||||
set(WX_CHARTYPE unicode)
|
||||
else()
|
||||
set(WX_CHARTYPE ansi)
|
||||
endif()
|
||||
set(WX_FLAVOUR)
|
||||
set(WX_LIBRARY_BASENAME_GUI)
|
||||
set(WX_LIBRARY_BASENAME_NOGUI)
|
||||
set(WX_RELEASE ${wxMAJOR_VERSION}.${wxMINOR_VERSION})
|
||||
set(WX_SUBVERSION ${wxVERSION}.0)
|
||||
set(WX_VERSION ${wxVERSION})
|
||||
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}")
|
||||
|
||||
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)
|
||||
set(DMALLOC_LIBS)
|
||||
|
||||
set(CC ${CMAKE_C_COMPILER})
|
||||
set(CXX ${CMAKE_CXX_COMPILER})
|
||||
set(WXCONFIG_CFLAGS)
|
||||
set(WXCONFIG_CPPFLAGS)
|
||||
set(WXCONFIG_CXXFLAGS)
|
||||
set(WXCONFIG_LDFLAGS)
|
||||
if(CMAKE_USE_PTHREADS_INIT)
|
||||
set(WXCONFIG_CFLAGS "-pthread")
|
||||
set(WXCONFIG_LDFLAGS "-pthread")
|
||||
endif()
|
||||
set(WXCONFIG_CPPFLAGS "-DWXUSINGDLL")
|
||||
foreach(flag IN LISTS wxTOOLKIT_DEFINITIONS)
|
||||
wx_string_append(WXCONFIG_CPPFLAGS " -D${flag}")
|
||||
endforeach()
|
||||
set(WXCONFIG_CXXFLAGS ${WXCONFIG_CFLAGS})
|
||||
set(WXCONFIG_LDFLAGS_GUI)
|
||||
set(WXCONFIG_LIBS)
|
||||
set(WXCONFIG_RESFLAGS)
|
||||
set(WXCONFIG_RPATH)
|
||||
set(WXCONFIG_RPATH "-Wl,-rpath,\$libdir")
|
||||
set(LDFLAGS_GL)
|
||||
set(RESCOMP)
|
||||
|
||||
wx_configure_script(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/wx-config.in"
|
||||
|
@@ -105,6 +105,10 @@ function(wx_set_common_target_properties target_name)
|
||||
endif()
|
||||
# TODO: add warning flags for other compilers
|
||||
endif()
|
||||
if(CMAKE_USE_PTHREADS_INIT)
|
||||
target_compile_options(${target_name} PRIVATE "-pthread")
|
||||
set_target_properties(${target_name} PROPERTIES LINK_FLAGS "-pthread")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Set common properties on wx library target
|
||||
@@ -313,8 +317,6 @@ macro(wx_add_library name)
|
||||
RUNTIME DESTINATION "lib${wxPLATFORM_LIB_DIR}"
|
||||
BUNDLE DESTINATION Applications/wxWidgets
|
||||
)
|
||||
|
||||
list(APPEND wxLIB_TARGETS ${name})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
@@ -349,7 +351,6 @@ endmacro()
|
||||
|
||||
# Enable precompiled headers for wx libraries
|
||||
macro(wx_finalize_lib target_name)
|
||||
set(wxLIB_TARGETS ${wxLIB_TARGETS} PARENT_SCOPE)
|
||||
if(wxBUILD_PRECOMP)
|
||||
if(TARGET ${target_name})
|
||||
wx_target_enable_precomp(${target_name} "${wxSOURCE_DIR}/include/wx/wxprec.h")
|
||||
|
@@ -12,13 +12,19 @@ if(NOT wxBUILD_INSTALL)
|
||||
endif()
|
||||
|
||||
install(CODE "message(STATUS \"Installing: Headers...\")")
|
||||
wx_install(
|
||||
DIRECTORY "${wxSOURCE_DIR}/include/wx"
|
||||
DESTINATION "include")
|
||||
if(MSVC)
|
||||
if(UNIX)
|
||||
wx_install(
|
||||
DIRECTORY "${wxSOURCE_DIR}/include/msvc"
|
||||
DIRECTORY "${wxSOURCE_DIR}/include/wx"
|
||||
DESTINATION "include/wx-${wxMAJOR_VERSION}.${wxMINOR_VERSION}")
|
||||
else()
|
||||
wx_install(
|
||||
DIRECTORY "${wxSOURCE_DIR}/include/wx"
|
||||
DESTINATION "include")
|
||||
if(MSVC)
|
||||
wx_install(
|
||||
DIRECTORY "${wxSOURCE_DIR}/include/msvc"
|
||||
DESTINATION "include")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# setup header and wx-config
|
||||
|
@@ -9,7 +9,6 @@
|
||||
|
||||
include(../source_groups.cmake)
|
||||
|
||||
set(wxLIB_TARGETS)
|
||||
if(wxBUILD_MONOLITHIC)
|
||||
# Initialize variables for monolithic build
|
||||
set(wxMONO_SRC_FILES)
|
||||
@@ -98,7 +97,3 @@ if(wxBUILD_MONOLITHIC)
|
||||
endforeach()
|
||||
wx_finalize_lib(mono)
|
||||
endif()
|
||||
|
||||
# Propagate variable(s) to parent scope
|
||||
set(wxLIB_TARGETS ${wxLIB_TARGETS} PARENT_SCOPE)
|
||||
set(wxTHIRD_PARTY_LIBRARIES ${wxTHIRD_PARTY_LIBRARIES} PARENT_SCOPE)
|
||||
|
@@ -16,6 +16,3 @@ add_subdirectory(drawing)
|
||||
add_subdirectory(gui)
|
||||
|
||||
endif()
|
||||
|
||||
# Propagate variable(s) to parent scope
|
||||
set(wxTHIRD_PARTY_LIBRARIES ${wxTHIRD_PARTY_LIBRARIES} PARENT_SCOPE)
|
||||
|
Reference in New Issue
Block a user