2016-09-25 16:19:39 -04:00
|
|
|
#############################################################################
|
|
|
|
# Name: build/cmake/functions.cmake
|
|
|
|
# Purpose: Common CMake functions for wxWidgets
|
|
|
|
# Author: Tobias Taschner
|
|
|
|
# Created: 2016-09-20
|
|
|
|
# Copyright: (c) 2016 wxWidgets development team
|
|
|
|
# Licence: wxWindows licence
|
|
|
|
#############################################################################
|
|
|
|
|
|
|
|
include(CMakeDependentOption)
|
2018-08-17 13:15:08 -04:00
|
|
|
include(CMakeParseArguments) # For compatibility with CMake < 3.4
|
2016-09-25 16:19:39 -04:00
|
|
|
include(ExternalProject)
|
|
|
|
if(CMAKE_GENERATOR STREQUAL "Xcode")
|
|
|
|
# wxWidgets does not use the unity features of cotire so we can
|
|
|
|
# include Obj-C files when using precompiled headers with Xcode
|
|
|
|
set(COTIRE_UNITY_SOURCE_EXCLUDE_EXTENSIONS "" CACHE STRING "wxWidgets override of cotire exclude")
|
|
|
|
endif()
|
|
|
|
include(cotire) # For precompiled header handling
|
|
|
|
include(CMakePrintHelpers)
|
|
|
|
|
|
|
|
# This function adds a list of headers to a variable while prepending
|
|
|
|
# include/ to the path
|
2018-05-18 16:01:02 -04:00
|
|
|
macro(wx_add_headers src_var)
|
2016-09-25 16:19:39 -04:00
|
|
|
set(headers)
|
2018-05-18 16:01:02 -04:00
|
|
|
foreach(header ${ARGN})
|
2016-09-25 16:19:39 -04:00
|
|
|
list(APPEND headers ${wxSOURCE_DIR}/include/${header})
|
|
|
|
if(header MATCHES "\\.cpp$")
|
|
|
|
# .cpp files in include directory should not be compiled
|
2018-05-18 16:01:02 -04:00
|
|
|
if (wxBUILD_MONOLITHIC)
|
|
|
|
# set_source_files_properties only works within the same CMakeLists.txt
|
|
|
|
list(APPEND wxMONO_NONCOMPILED_CPP_FILES ${wxSOURCE_DIR}/include/${header})
|
|
|
|
set(wxMONO_NONCOMPILED_CPP_FILES ${wxMONO_NONCOMPILED_CPP_FILES} PARENT_SCOPE)
|
|
|
|
else()
|
|
|
|
set_source_files_properties(${wxSOURCE_DIR}/include/${header}
|
|
|
|
PROPERTIES HEADER_FILE_ONLY TRUE)
|
|
|
|
endif()
|
2016-09-25 16:19:39 -04:00
|
|
|
endif()
|
|
|
|
endforeach()
|
2018-05-18 16:01:02 -04:00
|
|
|
list(APPEND ${src_var} ${headers})
|
|
|
|
endmacro()
|
2016-09-25 16:19:39 -04:00
|
|
|
|
|
|
|
# Add sources from a ..._SRC variable and headers from a ..._HDR
|
|
|
|
macro(wx_append_sources src_var source_base_name)
|
|
|
|
if(NOT DEFINED ${src_var})
|
|
|
|
set(${src_var} "")
|
|
|
|
endif()
|
|
|
|
if(DEFINED ${source_base_name}_SRC)
|
|
|
|
wx_list_add_prefix(${src_var} "${wxSOURCE_DIR}/" ${${source_base_name}_SRC})
|
|
|
|
endif()
|
|
|
|
if(DEFINED ${source_base_name}_HDR)
|
|
|
|
wx_add_headers(${src_var} ${${source_base_name}_HDR})
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Add prefix to list of items
|
|
|
|
# wx_list_add_prefix(<out_var> <pref> <items...>)
|
|
|
|
macro(wx_list_add_prefix out_var prefix)
|
|
|
|
foreach(item ${ARGN})
|
|
|
|
list(APPEND ${out_var} ${prefix}${item})
|
|
|
|
endforeach()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Older cmake versions don't support string(APPEND ...) provide a workaround
|
|
|
|
macro(wx_string_append var str)
|
|
|
|
set(${var} ${${var}}${str})
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# wx_install(...)
|
2017-12-09 08:38:11 -05:00
|
|
|
# Forward to install call if wxBUILD_INSTALL is enabled
|
2016-09-25 16:19:39 -04:00
|
|
|
macro(wx_install)
|
|
|
|
if(wxBUILD_INSTALL)
|
|
|
|
install(${ARGN})
|
2017-12-09 08:38:11 -05:00
|
|
|
endif()
|
2016-09-25 16:19:39 -04:00
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Set properties common to builtin third party libraries and wx libs
|
|
|
|
function(wx_set_common_target_properties target_name)
|
2018-10-24 04:52:47 -04:00
|
|
|
cmake_parse_arguments(wxCOMMON_TARGET_PROPS "DEFAULT_WARNINGS" "" "" ${ARGN})
|
|
|
|
|
2016-09-25 16:19:39 -04:00
|
|
|
set_target_properties(${target_name} PROPERTIES
|
|
|
|
LIBRARY_OUTPUT_DIRECTORY "${wxOUTPUT_DIR}${wxPLATFORM_LIB_DIR}"
|
|
|
|
ARCHIVE_OUTPUT_DIRECTORY "${wxOUTPUT_DIR}${wxPLATFORM_LIB_DIR}"
|
|
|
|
RUNTIME_OUTPUT_DIRECTORY "${wxOUTPUT_DIR}${wxPLATFORM_LIB_DIR}"
|
|
|
|
)
|
2019-07-16 19:12:33 -04:00
|
|
|
|
2020-08-05 14:04:05 -04:00
|
|
|
if(wxBUILD_PIC)
|
|
|
|
set_target_properties(${target_name} PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
|
|
|
|
endif()
|
|
|
|
|
2021-03-17 05:06:11 -04:00
|
|
|
set(common_gcc_clang_compile_options
|
|
|
|
-Wall
|
|
|
|
-Wno-ctor-dtor-privacy
|
|
|
|
-Woverloaded-virtual
|
|
|
|
-Wundef
|
|
|
|
-Wunused-parameter
|
|
|
|
)
|
|
|
|
|
|
|
|
if(WXOSX_COCOA OR WXGTK3)
|
|
|
|
# when building using GTK+ 3 or Cocoa we currently get tons of deprecation
|
|
|
|
# warnings from the standard headers -- disable them as we already know
|
|
|
|
# that they're deprecated but we still have to use them to support older
|
|
|
|
# toolkit versions and leaving this warning enabled prevents seeing any
|
|
|
|
# other ones
|
|
|
|
list(APPEND common_gcc_clang_compile_options
|
|
|
|
-Wno-deprecated-declarations
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2019-07-16 19:12:33 -04:00
|
|
|
if(MSVC)
|
|
|
|
if(wxCOMMON_TARGET_PROPS_DEFAULT_WARNINGS)
|
|
|
|
set(MSVC_WARNING_LEVEL "/W3")
|
|
|
|
else()
|
|
|
|
set(MSVC_WARNING_LEVEL "/W4")
|
2018-10-24 04:52:47 -04:00
|
|
|
endif()
|
2019-07-16 19:12:33 -04:00
|
|
|
target_compile_options(${target_name} PRIVATE ${MSVC_WARNING_LEVEL})
|
2020-04-26 13:33:20 -04:00
|
|
|
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND NOT wxCOMMON_TARGET_PROPS_DEFAULT_WARNINGS)
|
|
|
|
target_compile_options(${target_name} PRIVATE
|
2021-03-17 05:06:11 -04:00
|
|
|
${common_gcc_clang_compile_options}
|
2020-04-26 13:33:20 -04:00
|
|
|
)
|
|
|
|
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND NOT wxCOMMON_TARGET_PROPS_DEFAULT_WARNINGS)
|
|
|
|
target_compile_options(${target_name} PRIVATE
|
2021-03-17 05:06:11 -04:00
|
|
|
${common_gcc_clang_compile_options}
|
2020-04-26 13:33:20 -04:00
|
|
|
-Wno-ignored-attributes
|
|
|
|
)
|
2018-10-24 04:52:47 -04:00
|
|
|
endif()
|
2018-12-09 09:55:04 -05:00
|
|
|
|
2018-12-06 17:20:48 -05:00
|
|
|
if(CMAKE_USE_PTHREADS_INIT)
|
|
|
|
target_compile_options(${target_name} PRIVATE "-pthread")
|
2018-12-09 09:55:04 -05:00
|
|
|
# clang++.exe: warning: argument unused during compilation: '-pthread' [-Wunused-command-line-argument]
|
|
|
|
if(NOT (WIN32 AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
|
|
|
|
set_target_properties(${target_name} PROPERTIES LINK_FLAGS "-pthread")
|
|
|
|
endif()
|
2018-12-06 17:20:48 -05:00
|
|
|
endif()
|
2016-09-25 16:19:39 -04:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
# Set common properties on wx library target
|
|
|
|
function(wx_set_target_properties target_name is_base)
|
2020-05-17 13:41:44 -04:00
|
|
|
if(${target_name} MATCHES "wx.*")
|
|
|
|
string(SUBSTRING ${target_name} 2 -1 target_name_short)
|
|
|
|
else()
|
|
|
|
set(target_name_short ${target_name})
|
|
|
|
endif()
|
|
|
|
|
2016-09-25 16:19:39 -04:00
|
|
|
# Set library name according to:
|
2020-02-12 16:30:32 -05:00
|
|
|
# docs/contributing/about-platform-toolkit-and-library-names.md
|
2016-09-25 16:19:39 -04:00
|
|
|
if(is_base)
|
|
|
|
set(lib_toolkit base)
|
|
|
|
else()
|
|
|
|
set(lib_toolkit ${wxBUILD_TOOLKIT}${wxBUILD_WIDGETSET})
|
|
|
|
endif()
|
2020-02-12 16:30:32 -05:00
|
|
|
if(MSVC)
|
2016-09-25 16:19:39 -04:00
|
|
|
set(lib_version ${wxMAJOR_VERSION}${wxMINOR_VERSION})
|
|
|
|
else()
|
|
|
|
set(lib_version ${wxMAJOR_VERSION}.${wxMINOR_VERSION})
|
|
|
|
endif()
|
|
|
|
if(wxUSE_UNICODE)
|
|
|
|
set(lib_unicode u)
|
|
|
|
else()
|
|
|
|
set(lib_unicode)
|
|
|
|
endif()
|
2020-05-17 13:41:44 -04:00
|
|
|
if(NOT target_name_short STREQUAL "base" AND NOT target_name_short STREQUAL "mono")
|
2016-09-25 16:19:39 -04:00
|
|
|
# Do not append library name for base library
|
2020-05-17 13:41:44 -04:00
|
|
|
set(lib_suffix _${target_name_short})
|
2016-09-25 16:19:39 -04:00
|
|
|
else()
|
|
|
|
set(lib_suffix)
|
|
|
|
endif()
|
2020-02-16 15:33:44 -05:00
|
|
|
set(lib_flavour "")
|
|
|
|
if(wxBUILD_FLAVOUR)
|
|
|
|
set(lib_flavour "_${wxBUILD_FLAVOUR}")
|
|
|
|
string(REPLACE "-" "_" lib_flavour ${lib_flavour})
|
|
|
|
endif()
|
2020-02-12 16:30:32 -05:00
|
|
|
|
2016-09-25 16:19:39 -04:00
|
|
|
if(WIN32)
|
2020-02-12 16:30:32 -05:00
|
|
|
if(MSVC)
|
|
|
|
# match visual studio name
|
|
|
|
set_target_properties(${target_name}
|
|
|
|
PROPERTIES
|
2020-02-16 15:33:44 -05:00
|
|
|
OUTPUT_NAME "wx${lib_toolkit}${lib_version}${lib_unicode}${lib_flavour}${lib_suffix}"
|
|
|
|
OUTPUT_NAME_DEBUG "wx${lib_toolkit}${lib_version}${lib_unicode}d${lib_flavour}${lib_suffix}"
|
2020-02-12 16:30:32 -05:00
|
|
|
PREFIX ""
|
|
|
|
)
|
|
|
|
else()
|
|
|
|
# match configure name (mingw, cygwin)
|
|
|
|
set_target_properties(${target_name}
|
|
|
|
PROPERTIES
|
2020-02-16 15:33:44 -05:00
|
|
|
OUTPUT_NAME "wx_${lib_toolkit}${lib_unicode}${lib_flavour}${lib_suffix}-${lib_version}"
|
|
|
|
OUTPUT_NAME_DEBUG "wx_${lib_toolkit}${lib_unicode}d${lib_flavour}${lib_suffix}-${lib_version}"
|
2020-02-12 16:30:32 -05:00
|
|
|
PREFIX "lib"
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2016-09-25 16:19:39 -04:00
|
|
|
if(wxBUILD_SHARED)
|
|
|
|
# Add compiler type and or vendor
|
2020-02-16 15:33:44 -05:00
|
|
|
set(dll_suffix "${lib_flavour}${lib_suffix}_${wxCOMPILER_PREFIX}")
|
2016-09-25 16:19:39 -04:00
|
|
|
if(wxBUILD_VENDOR)
|
|
|
|
wx_string_append(dll_suffix "_${wxBUILD_VENDOR}")
|
|
|
|
endif()
|
|
|
|
|
2020-02-12 16:30:32 -05:00
|
|
|
set(dll_version ${wxMAJOR_VERSION}${wxMINOR_VERSION})
|
2016-09-25 16:19:39 -04:00
|
|
|
if(wxVERSION_IS_DEV)
|
|
|
|
wx_string_append(dll_version ${wxRELEASE_NUMBER})
|
|
|
|
endif()
|
|
|
|
set_target_properties(${target_name}
|
|
|
|
PROPERTIES
|
2020-02-16 15:33:44 -05:00
|
|
|
RUNTIME_OUTPUT_NAME "wx${lib_toolkit}${dll_version}${lib_unicode}${dll_suffix}"
|
|
|
|
RUNTIME_OUTPUT_NAME_DEBUG "wx${lib_toolkit}${dll_version}${lib_unicode}d${dll_suffix}"
|
2020-02-12 16:30:32 -05:00
|
|
|
PREFIX ""
|
|
|
|
)
|
2016-09-25 16:19:39 -04:00
|
|
|
target_compile_definitions(${target_name} PRIVATE
|
2020-02-16 15:33:44 -05:00
|
|
|
"-DWXDLLNAME=wx${lib_toolkit}${dll_version}${lib_unicode}$<$<CONFIG:Debug>:d>${dll_suffix}")
|
2016-09-25 16:19:39 -04:00
|
|
|
endif()
|
|
|
|
else()
|
2021-03-23 06:28:16 -04:00
|
|
|
set(cross_target "")
|
2021-04-05 15:26:04 -04:00
|
|
|
if (CMAKE_CROSSCOMPILING)
|
2021-03-23 06:28:16 -04:00
|
|
|
set(cross_target "-${CMAKE_SYSTEM_NAME}")
|
|
|
|
endif ()
|
|
|
|
|
2016-09-25 16:19:39 -04:00
|
|
|
set_target_properties(${target_name}
|
|
|
|
PROPERTIES
|
2021-03-23 06:28:16 -04:00
|
|
|
OUTPUT_NAME wx_${lib_toolkit}${lib_unicode}${lib_flavour}${lib_suffix}-${lib_version}${cross_target}
|
2019-01-21 05:47:15 -05:00
|
|
|
# NOTE: wx-config can not be used to connect the libraries with the debug suffix.
|
2021-04-05 15:26:04 -04:00
|
|
|
#OUTPUT_NAME_DEBUG wx_${lib_toolkit}${lib_unicode}d${lib_flavour}${lib_suffix}-${lib_version}${cross_target}
|
2021-03-23 06:28:16 -04:00
|
|
|
OUTPUT_NAME_DEBUG wx_${lib_toolkit}${lib_unicode}${lib_flavour}${lib_suffix}-${lib_version}${cross_target}
|
2016-09-25 16:19:39 -04:00
|
|
|
)
|
|
|
|
endif()
|
|
|
|
if(CYGWIN)
|
|
|
|
target_link_libraries(${target_name} PUBLIC -L/usr/lib/w32api)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Set common compile definitions
|
|
|
|
target_compile_definitions(${target_name} PRIVATE WXBUILDING _LIB)
|
2020-05-17 13:41:44 -04:00
|
|
|
if(target_name_short STREQUAL "mono" AND wxUSE_GUI)
|
2016-09-25 16:19:39 -04:00
|
|
|
target_compile_definitions(${target_name} PRIVATE wxUSE_GUI=1 wxUSE_BASE=1)
|
|
|
|
elseif(is_base OR NOT wxUSE_GUI)
|
|
|
|
target_compile_definitions(${target_name} PRIVATE wxUSE_GUI=0 wxUSE_BASE=1)
|
|
|
|
else()
|
|
|
|
target_compile_definitions(${target_name} PRIVATE wxUSE_GUI=1 wxUSE_BASE=0)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(wxUSE_UNICODE)
|
2018-01-20 11:30:25 -05:00
|
|
|
if(WIN32)
|
|
|
|
target_compile_definitions(${target_name} PUBLIC UNICODE)
|
|
|
|
endif()
|
2016-09-25 16:19:39 -04:00
|
|
|
target_compile_definitions(${target_name} PUBLIC _UNICODE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WIN32 AND MSVC)
|
|
|
|
# Suppress deprecation warnings for standard library calls
|
|
|
|
target_compile_definitions(${target_name} PRIVATE
|
|
|
|
_CRT_SECURE_NO_DEPRECATE=1
|
|
|
|
_CRT_NON_CONFORMING_SWPRINTFS=1
|
|
|
|
_SCL_SECURE_NO_WARNINGS=1
|
2018-01-10 16:53:00 -05:00
|
|
|
_WINSOCK_DEPRECATED_NO_WARNINGS=1
|
2016-09-25 16:19:39 -04:00
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
target_include_directories(${target_name}
|
|
|
|
BEFORE
|
|
|
|
PUBLIC
|
|
|
|
${wxSETUP_HEADER_PATH}
|
|
|
|
${wxSOURCE_DIR}/include
|
|
|
|
)
|
|
|
|
|
2017-12-09 08:38:11 -05:00
|
|
|
if(wxTOOLKIT_INCLUDE_DIRS)
|
2016-09-25 16:19:39 -04:00
|
|
|
target_include_directories(${target_name}
|
|
|
|
PUBLIC ${wxTOOLKIT_INCLUDE_DIRS})
|
|
|
|
endif()
|
2018-01-27 07:39:45 -05:00
|
|
|
|
2018-02-27 16:47:27 -05:00
|
|
|
if (WIN32)
|
|
|
|
set(WIN32_LIBRARIES
|
2018-01-27 07:39:45 -05:00
|
|
|
kernel32
|
|
|
|
user32
|
|
|
|
gdi32
|
|
|
|
comdlg32
|
|
|
|
winspool
|
|
|
|
winmm
|
|
|
|
shell32
|
|
|
|
shlwapi
|
|
|
|
comctl32
|
|
|
|
ole32
|
|
|
|
oleaut32
|
|
|
|
uuid
|
|
|
|
rpcrt4
|
|
|
|
advapi32
|
|
|
|
version
|
2021-04-18 16:13:45 -04:00
|
|
|
ws2_32
|
2018-01-27 07:39:45 -05:00
|
|
|
wininet
|
|
|
|
oleacc
|
|
|
|
uxtheme
|
|
|
|
)
|
|
|
|
target_link_libraries(${target_name}
|
2018-02-27 16:47:27 -05:00
|
|
|
PUBLIC ${WIN32_LIBRARIES})
|
2018-01-27 07:39:45 -05:00
|
|
|
endif()
|
|
|
|
|
2017-12-09 08:38:11 -05:00
|
|
|
if(wxTOOLKIT_LIBRARIES)
|
2016-09-25 16:19:39 -04:00
|
|
|
target_link_libraries(${target_name}
|
|
|
|
PUBLIC ${wxTOOLKIT_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
target_compile_definitions(${target_name}
|
|
|
|
PUBLIC ${wxTOOLKIT_DEFINITIONS})
|
|
|
|
|
|
|
|
if(wxBUILD_SHARED)
|
2020-05-17 13:41:44 -04:00
|
|
|
string(TOUPPER ${target_name_short} target_name_upper)
|
|
|
|
if(target_name_short STREQUAL "mono")
|
2016-09-25 16:19:39 -04:00
|
|
|
target_compile_definitions(${target_name} PRIVATE DLL_EXPORTS WXMAKINGDLL)
|
|
|
|
else()
|
|
|
|
target_compile_definitions(${target_name} PRIVATE DLL_EXPORTS WXMAKINGDLL_${target_name_upper})
|
|
|
|
endif()
|
2020-05-17 13:41:44 -04:00
|
|
|
if(NOT target_name_short STREQUAL "base")
|
2016-09-25 16:19:39 -04:00
|
|
|
target_compile_definitions(${target_name} PRIVATE WXUSINGDLL)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Link common libraries
|
2020-05-17 13:41:44 -04:00
|
|
|
if(NOT target_name_short STREQUAL "mono")
|
|
|
|
if(NOT target_name_short STREQUAL "base")
|
2016-09-25 16:19:39 -04:00
|
|
|
# All libraries except base need the base library
|
2020-05-17 13:41:44 -04:00
|
|
|
target_link_libraries(${target_name} PUBLIC wxbase)
|
2016-09-25 16:19:39 -04:00
|
|
|
endif()
|
2020-05-17 13:41:44 -04:00
|
|
|
if(NOT is_base AND NOT target_name_short STREQUAL "core")
|
2016-09-25 16:19:39 -04:00
|
|
|
# All non base libraries except core need core
|
2020-05-17 13:41:44 -04:00
|
|
|
target_link_libraries(${target_name} PUBLIC wxcore)
|
2016-09-25 16:19:39 -04:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set_target_properties(${target_name} PROPERTIES FOLDER Libraries)
|
|
|
|
|
|
|
|
wx_set_common_target_properties(${target_name})
|
|
|
|
endfunction()
|
|
|
|
|
2018-12-28 13:26:39 -05:00
|
|
|
# List of libraries added via wx_add_library() to use for wx-config
|
|
|
|
set(wxLIB_TARGETS)
|
|
|
|
|
2016-09-25 16:19:39 -04:00
|
|
|
# Add a wxWidgets library
|
|
|
|
# wx_add_library(<target_name> [IS_BASE] <src_files>...)
|
|
|
|
# first parameter is the name of the library
|
|
|
|
# if the second parameter is set to IS_BASE a non UI lib is created
|
|
|
|
# all additional parameters are source files for the library
|
2018-05-18 16:01:02 -04:00
|
|
|
macro(wx_add_library name)
|
2016-09-25 16:19:39 -04:00
|
|
|
cmake_parse_arguments(wxADD_LIBRARY "IS_BASE" "" "" ${ARGN})
|
|
|
|
set(src_files ${wxADD_LIBRARY_UNPARSED_ARGUMENTS})
|
|
|
|
|
2018-12-28 13:26:39 -05:00
|
|
|
list(APPEND wxLIB_TARGETS ${name})
|
|
|
|
set(wxLIB_TARGETS ${wxLIB_TARGETS} PARENT_SCOPE)
|
|
|
|
|
2020-05-17 13:41:44 -04:00
|
|
|
if(wxBUILD_MONOLITHIC AND NOT ${name} STREQUAL "wxmono")
|
2016-09-25 16:19:39 -04:00
|
|
|
# collect all source files for mono library
|
|
|
|
set(wxMONO_SRC_FILES ${wxMONO_SRC_FILES} ${src_files} PARENT_SCOPE)
|
2018-05-18 16:01:02 -04:00
|
|
|
else()
|
|
|
|
list(APPEND src_files ${wxSETUP_HEADER_FILE})
|
2016-09-25 16:19:39 -04:00
|
|
|
|
2018-05-18 16:01:02 -04:00
|
|
|
if(wxBUILD_SHARED)
|
|
|
|
set(wxBUILD_LIB_TYPE SHARED)
|
|
|
|
if(WIN32)
|
|
|
|
# Add WIN32 version information
|
|
|
|
list(APPEND src_files "${wxSOURCE_DIR}/src/msw/version.rc" "${wxSOURCE_DIR}/include/wx/msw/genrcdefs.h")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(wxBUILD_LIB_TYPE STATIC)
|
2016-09-25 16:19:39 -04:00
|
|
|
endif()
|
|
|
|
|
2020-05-17 13:41:44 -04:00
|
|
|
if(${name} MATCHES "wx.*")
|
|
|
|
string(SUBSTRING ${name} 2 -1 name_short)
|
|
|
|
else()
|
|
|
|
set(name_short ${name})
|
|
|
|
endif()
|
|
|
|
|
2018-05-18 16:01:02 -04:00
|
|
|
add_library(${name} ${wxBUILD_LIB_TYPE} ${src_files})
|
2020-05-17 13:41:44 -04:00
|
|
|
add_library(wx::${name_short} ALIAS ${name})
|
2018-05-18 16:01:02 -04:00
|
|
|
wx_set_target_properties(${name} ${wxADD_LIBRARY_IS_BASE})
|
2020-08-02 07:57:51 -04:00
|
|
|
set_target_properties(${name} PROPERTIES PROJECT_LABEL ${name_short})
|
2016-09-25 16:19:39 -04:00
|
|
|
|
2018-05-18 16:01:02 -04:00
|
|
|
# Setup install
|
|
|
|
wx_install(TARGETS ${name}
|
|
|
|
LIBRARY DESTINATION "lib${wxPLATFORM_LIB_DIR}"
|
|
|
|
ARCHIVE DESTINATION "lib${wxPLATFORM_LIB_DIR}"
|
|
|
|
RUNTIME DESTINATION "lib${wxPLATFORM_LIB_DIR}"
|
|
|
|
BUNDLE DESTINATION Applications/wxWidgets
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
endmacro()
|
2016-09-25 16:19:39 -04:00
|
|
|
|
2018-08-17 13:49:38 -04:00
|
|
|
# Enable cotire for target, use optional second argument for prec. header
|
2016-09-25 16:19:39 -04:00
|
|
|
macro(wx_target_enable_precomp target_name)
|
2018-08-17 13:49:38 -04:00
|
|
|
target_compile_definitions(${target_name} PRIVATE WX_PRECOMP)
|
|
|
|
if(NOT ${ARGV1} STREQUAL "")
|
|
|
|
set_target_properties(${target_name} PROPERTIES
|
|
|
|
COTIRE_CXX_PREFIX_HEADER_INIT ${ARGV1})
|
2016-09-25 16:19:39 -04:00
|
|
|
endif()
|
2018-08-17 13:49:38 -04:00
|
|
|
set_target_properties(${target_name} PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)
|
|
|
|
cotire(${target_name})
|
2016-09-25 16:19:39 -04:00
|
|
|
endmacro()
|
|
|
|
|
2021-01-15 19:33:55 -05:00
|
|
|
# Enable precompiled headers for applications
|
|
|
|
macro(wx_app_enable_precomp target_name)
|
2018-08-16 14:21:52 -04:00
|
|
|
if(wxBUILD_PRECOMP)
|
2018-08-17 13:49:38 -04:00
|
|
|
wx_target_enable_precomp(${target_name} "${wxSOURCE_DIR}/include/wx/wxprec.h")
|
2018-08-16 14:21:52 -04:00
|
|
|
elseif(MSVC)
|
|
|
|
target_compile_definitions(${target_name} PRIVATE NOPCH)
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2016-09-25 16:19:39 -04:00
|
|
|
# Enable precompiled headers for wx libraries
|
|
|
|
macro(wx_finalize_lib target_name)
|
2018-05-18 16:01:02 -04:00
|
|
|
if(wxBUILD_PRECOMP)
|
|
|
|
if(TARGET ${target_name})
|
2018-09-04 07:55:16 -04:00
|
|
|
wx_target_enable_precomp(${target_name} "${wxSOURCE_DIR}/include/wx/wxprec.h")
|
2018-05-18 16:01:02 -04:00
|
|
|
endif()
|
2016-09-25 16:19:39 -04:00
|
|
|
elseif(MSVC)
|
2018-05-18 16:01:02 -04:00
|
|
|
wx_lib_compile_definitions(${target_name} PRIVATE NOPCH)
|
2016-09-25 16:19:39 -04:00
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# wx_lib_link_libraries(name [])
|
|
|
|
# Forwards everything to target_link_libraries() except for monolithic
|
|
|
|
# build where it collects all libraries for linking with the mono lib
|
|
|
|
macro(wx_lib_link_libraries name)
|
|
|
|
if(wxBUILD_MONOLITHIC)
|
|
|
|
cmake_parse_arguments(_LIB_LINK "" "" "PUBLIC;PRIVATE" ${ARGN})
|
|
|
|
list(APPEND wxMONO_LIBS_PUBLIC ${_LIB_LINK_PUBLIC})
|
|
|
|
list(APPEND wxMONO_LIBS_PRIVATE ${_LIB_LINK_PRIVATE})
|
2018-05-18 16:01:02 -04:00
|
|
|
set(wxMONO_LIBS_PUBLIC ${wxMONO_LIBS_PUBLIC} PARENT_SCOPE)
|
|
|
|
set(wxMONO_LIBS_PRIVATE ${wxMONO_LIBS_PRIVATE} PARENT_SCOPE)
|
2016-09-25 16:19:39 -04:00
|
|
|
else()
|
|
|
|
target_link_libraries(${name};${ARGN})
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# wx_exe_link_libraries(target libs...)
|
|
|
|
# Link wx libraries to executable
|
|
|
|
macro(wx_exe_link_libraries name)
|
2021-01-15 19:33:55 -05:00
|
|
|
if(TARGET ${name})
|
|
|
|
if(wxBUILD_MONOLITHIC)
|
|
|
|
target_link_libraries(${name} PUBLIC wxmono)
|
|
|
|
else()
|
|
|
|
target_link_libraries(${name};PRIVATE;${ARGN})
|
|
|
|
endif()
|
2016-09-25 16:19:39 -04:00
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# wx_lib_include_directories(name [])
|
|
|
|
# Forwards everything to target_include_directories() except for monolithic
|
|
|
|
# build where it collects all include paths for linking with the mono lib
|
|
|
|
macro(wx_lib_include_directories name)
|
2019-11-27 14:40:11 -05:00
|
|
|
cmake_parse_arguments(_LIB_INCLUDE_DIRS "" "" "PUBLIC;PRIVATE" ${ARGN})
|
2016-09-25 16:19:39 -04:00
|
|
|
if(wxBUILD_MONOLITHIC)
|
|
|
|
list(APPEND wxMONO_INCLUDE_DIRS_PUBLIC ${_LIB_INCLUDE_DIRS_PUBLIC})
|
|
|
|
list(APPEND wxMONO_INCLUDE_DIRS_PRIVATE ${_LIB_INCLUDE_DIRS_PRIVATE})
|
2018-05-18 16:01:02 -04:00
|
|
|
set(wxMONO_INCLUDE_DIRS_PUBLIC ${wxMONO_INCLUDE_DIRS_PUBLIC} PARENT_SCOPE)
|
|
|
|
set(wxMONO_INCLUDE_DIRS_PRIVATE ${wxMONO_INCLUDE_DIRS_PRIVATE} PARENT_SCOPE)
|
2016-09-25 16:19:39 -04:00
|
|
|
else()
|
2019-11-27 14:40:11 -05:00
|
|
|
set(INCLUDE_POS)
|
|
|
|
if (_LIB_INCLUDE_DIRS_PRIVATE)
|
|
|
|
set(INCLUDE_POS BEFORE)
|
|
|
|
endif()
|
|
|
|
target_include_directories(${name};${INCLUDE_POS};${ARGN})
|
2016-09-25 16:19:39 -04:00
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# wx_lib_compile_definitions(name [])
|
|
|
|
# Forwards everything to target_compile_definitions() except for monolithic
|
|
|
|
# build where it collects all definitions for linking with the mono lib
|
|
|
|
macro(wx_lib_compile_definitions name)
|
|
|
|
if(wxBUILD_MONOLITHIC)
|
|
|
|
cmake_parse_arguments(_LIB_DEFINITIONS "" "" "PUBLIC;PRIVATE" ${ARGN})
|
|
|
|
list(APPEND wxMONO_DEFINITIONS_PUBLIC ${_LIB_DEFINITIONS_PUBLIC})
|
|
|
|
list(APPEND wxMONO_DEFINITIONS_PRIVATE ${_LIB_DEFINITIONS_PRIVATE})
|
2018-05-18 16:01:02 -04:00
|
|
|
set(wxMONO_DEFINITIONS_PUBLIC ${wxMONO_DEFINITIONS_PUBLIC} PARENT_SCOPE)
|
|
|
|
set(wxMONO_DEFINITIONS_PRIVATE ${wxMONO_DEFINITIONS_PRIVATE} PARENT_SCOPE)
|
2016-09-25 16:19:39 -04:00
|
|
|
else()
|
|
|
|
target_compile_definitions(${name};${ARGN})
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Set common properties for a builtin third party library
|
|
|
|
function(wx_set_builtin_target_properties target_name)
|
|
|
|
if(wxUSE_UNICODE AND target_name STREQUAL "wxregex")
|
|
|
|
set(lib_unicode u)
|
|
|
|
else()
|
|
|
|
set(lib_unicode)
|
|
|
|
endif()
|
|
|
|
if(NOT WIN32)
|
|
|
|
set(postfix -${wxMAJOR_VERSION}.${wxMINOR_VERSION})
|
|
|
|
endif()
|
|
|
|
set_target_properties(${target_name}
|
|
|
|
PROPERTIES
|
|
|
|
OUTPUT_NAME ${target_name}${lib_unicode}${postfix}
|
|
|
|
)
|
|
|
|
if(WIN32)
|
|
|
|
set_target_properties(${target_name}
|
|
|
|
PROPERTIES
|
|
|
|
OUTPUT_NAME_DEBUG ${target_name}${lib_unicode}d
|
|
|
|
)
|
|
|
|
endif()
|
2018-02-04 12:51:22 -05:00
|
|
|
|
|
|
|
if(wxUSE_UNICODE)
|
|
|
|
if(WIN32)
|
|
|
|
target_compile_definitions(${target_name} PUBLIC UNICODE)
|
|
|
|
endif()
|
|
|
|
target_compile_definitions(${target_name} PUBLIC _UNICODE)
|
|
|
|
endif()
|
|
|
|
|
2016-09-25 16:19:39 -04:00
|
|
|
if(MSVC)
|
|
|
|
# we're not interested in deprecation warnings about the use of
|
|
|
|
# standard C functions in the 3rd party libraries (these warnings
|
|
|
|
# are only given by VC8+ but it's simpler to just always define
|
|
|
|
# this symbol which disables them, even for previous VC versions)
|
2018-01-10 16:53:00 -05:00
|
|
|
target_compile_definitions(${target_name} PRIVATE
|
|
|
|
_CRT_SECURE_NO_DEPRECATE=1
|
|
|
|
_SCL_SECURE_NO_WARNINGS=1
|
|
|
|
)
|
2016-09-25 16:19:39 -04:00
|
|
|
endif()
|
|
|
|
|
2019-05-03 13:50:57 -04:00
|
|
|
target_include_directories(${target_name}
|
|
|
|
BEFORE
|
|
|
|
PUBLIC
|
|
|
|
${wxSETUP_HEADER_PATH}
|
|
|
|
)
|
|
|
|
|
2016-09-25 16:19:39 -04:00
|
|
|
set_target_properties(${target_name} PROPERTIES FOLDER "Third Party Libraries")
|
|
|
|
|
2020-08-05 14:04:05 -04:00
|
|
|
if(wxBUILD_SHARED OR wxBUILD_PIC)
|
|
|
|
set_target_properties(${target_name} PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
|
|
|
|
endif()
|
|
|
|
|
2018-10-24 04:52:47 -04:00
|
|
|
wx_set_common_target_properties(${target_name} DEFAULT_WARNINGS)
|
2016-09-25 16:19:39 -04:00
|
|
|
if(NOT wxBUILD_SHARED)
|
|
|
|
wx_install(TARGETS ${name} ARCHIVE DESTINATION "lib${wxPLATFORM_LIB_DIR}")
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
2017-12-09 08:38:11 -05:00
|
|
|
# Add a third party builtin library
|
2016-09-25 16:19:39 -04:00
|
|
|
function(wx_add_builtin_library name)
|
|
|
|
wx_list_add_prefix(src_list "${wxSOURCE_DIR}/" ${ARGN})
|
2020-05-17 13:41:33 -04:00
|
|
|
|
|
|
|
if(${name} MATCHES "wx.*")
|
|
|
|
string(SUBSTRING ${name} 2 -1 name_short)
|
|
|
|
else()
|
|
|
|
set(name_short ${name})
|
|
|
|
endif()
|
|
|
|
|
2016-09-25 16:19:39 -04:00
|
|
|
add_library(${name} STATIC ${src_list})
|
2020-05-17 13:41:33 -04:00
|
|
|
add_library(wx::${name_short} ALIAS ${name})
|
2016-09-25 16:19:39 -04:00
|
|
|
wx_set_builtin_target_properties(${name})
|
2020-08-02 07:57:51 -04:00
|
|
|
set_target_properties(${name} PROPERTIES PROJECT_LABEL ${name_short})
|
2016-09-25 16:19:39 -04:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
# List of third party libraries added via wx_add_thirdparty_library()
|
|
|
|
# to display in configuration summary
|
|
|
|
set(wxTHIRD_PARTY_LIBRARIES)
|
|
|
|
|
|
|
|
# Add third party library
|
|
|
|
function(wx_add_thirdparty_library var_name lib_name help_str)
|
|
|
|
cmake_parse_arguments(THIRDPARTY "" "DEFAULT;DEFAULT_APPLE;DEFAULT_WIN32" "" ${ARGN})
|
|
|
|
|
|
|
|
if(THIRDPARTY_DEFAULT)
|
|
|
|
set(thirdparty_lib_default ${THIRDPARTY_DEFAULT})
|
|
|
|
elseif(THIRDPARTY_DEFAULT_APPLE AND APPLE)
|
|
|
|
set(thirdparty_lib_default ${THIRDPARTY_DEFAULT_APPLE})
|
|
|
|
elseif(THIRDPARTY_DEFAULT_WIN32 AND WIN32)
|
|
|
|
set(thirdparty_lib_default ${THIRDPARTY_DEFAULT_WIN32})
|
|
|
|
elseif(UNIX AND NOT APPLE)
|
|
|
|
# Try sys libraries for MSYS and CYGWIN
|
|
|
|
set(thirdparty_lib_default sys)
|
|
|
|
elseif(WIN32 OR APPLE)
|
|
|
|
# On Windows or apple platforms prefer using the builtin libraries
|
|
|
|
set(thirdparty_lib_default builtin)
|
|
|
|
else()
|
|
|
|
set(thirdparty_lib_default sys)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
wx_option(${var_name} ${help_str} ${thirdparty_lib_default}
|
|
|
|
STRINGS builtin sys OFF)
|
|
|
|
|
|
|
|
if(${var_name} STREQUAL "sys")
|
|
|
|
# If the sys library can not be found use builtin
|
|
|
|
find_package(${lib_name})
|
|
|
|
string(TOUPPER ${lib_name} lib_name_upper)
|
|
|
|
if(NOT ${${lib_name_upper}_FOUND})
|
|
|
|
wx_option_force_value(${var_name} builtin)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(${var_name} STREQUAL "builtin" AND NOT wxBUILD_SHARED)
|
|
|
|
# Only install if we build as static libraries
|
|
|
|
wx_install(TARGETS ${target_name}
|
|
|
|
LIBRARY DESTINATION lib
|
|
|
|
ARCHIVE DESTINATION lib
|
|
|
|
)
|
|
|
|
endif()
|
2017-12-09 08:38:11 -05:00
|
|
|
|
2016-09-25 16:19:39 -04:00
|
|
|
set(wxTHIRD_PARTY_LIBRARIES ${wxTHIRD_PARTY_LIBRARIES} ${var_name} "${help_str}" PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(wx_print_thirdparty_library_summary)
|
2018-12-12 14:43:17 -05:00
|
|
|
set(nameLength 0)
|
|
|
|
set(nameValLength 0)
|
2016-09-25 16:19:39 -04:00
|
|
|
set(var_name)
|
2018-12-12 14:43:17 -05:00
|
|
|
foreach(entry IN LISTS wxTHIRD_PARTY_LIBRARIES)
|
|
|
|
if(NOT var_name)
|
|
|
|
set(var_name ${entry})
|
|
|
|
else()
|
|
|
|
string(LENGTH ${var_name} len)
|
|
|
|
if(len GREATER nameLength)
|
|
|
|
set(nameLength ${len})
|
|
|
|
endif()
|
|
|
|
string(LENGTH ${${var_name}} len)
|
|
|
|
if(len GREATER nameValLength)
|
|
|
|
set(nameValLength ${len})
|
|
|
|
endif()
|
|
|
|
set(var_name)
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
math(EXPR nameLength "${nameLength}+1") # account for :
|
2016-09-25 16:19:39 -04:00
|
|
|
|
2018-12-12 14:43:17 -05:00
|
|
|
set(message "Which libraries should wxWidgets use?\n")
|
|
|
|
foreach(entry IN LISTS wxTHIRD_PARTY_LIBRARIES)
|
2016-09-25 16:19:39 -04:00
|
|
|
if(NOT var_name)
|
|
|
|
set(var_name ${entry})
|
|
|
|
else()
|
2018-12-12 14:43:17 -05:00
|
|
|
set(namestr "${var_name}: ")
|
|
|
|
set(nameval "${${var_name}} ")
|
|
|
|
string(SUBSTRING ${namestr} 0 ${nameLength} namestr)
|
|
|
|
string(SUBSTRING ${nameval} 0 ${nameValLength} nameval)
|
|
|
|
wx_string_append(message " ${namestr} ${nameval} (${entry})\n")
|
2016-09-25 16:19:39 -04:00
|
|
|
set(var_name)
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
message(STATUS ${message})
|
|
|
|
endfunction()
|
|
|
|
|
2021-02-07 14:15:37 -05:00
|
|
|
# Add sample, test, demo or benchmark
|
2021-02-07 14:11:56 -05:00
|
|
|
# wx_add(<name> <group> [CONSOLE|CONSOLE_GUI|DLL] [IMPORTANT] [SRC_FILES...]
|
2021-01-15 19:33:55 -05:00
|
|
|
# [LIBRARIES ...] [NAME target_name] [FOLDER folder]
|
|
|
|
# [DATA ...] [DEFINITIONS ...] [RES ...])
|
|
|
|
# name default target name
|
2021-02-07 14:15:37 -05:00
|
|
|
# group can be Samples, Tests, Demos or Benchmarks
|
2021-01-15 19:33:55 -05:00
|
|
|
# first parameter may be CONSOLE to indicate a console application or DLL to indicate a shared library
|
2021-02-07 14:11:56 -05:00
|
|
|
# or CONSOLE_GUI to indicate a console application that uses gui libraries
|
2021-01-15 19:33:55 -05:00
|
|
|
# all following parameters are src files for the executable
|
|
|
|
#
|
2016-09-25 16:19:39 -04:00
|
|
|
# Optionally:
|
2021-01-15 19:33:55 -05:00
|
|
|
# IMPORTANT (samples only) does not require wxBUILD_SAMPLES=ALL
|
|
|
|
# LIBRARIES followed by required libraries
|
|
|
|
# NAME alternative target_name
|
|
|
|
# FOLDER subfolder in IDE
|
|
|
|
# DATA followed by required data files. Use a colon to separate different source and dest paths
|
|
|
|
# DEFINITIONS list of definitions for the target
|
|
|
|
# RES followed by WIN32 .rc files
|
2016-09-25 16:19:39 -04:00
|
|
|
#
|
2018-08-17 13:15:08 -04:00
|
|
|
# Additionally the following variables may be set before calling wx_add_sample:
|
2016-09-25 16:19:39 -04:00
|
|
|
# wxSAMPLE_SUBDIR subdirectory in the samples/ folder to use as base
|
|
|
|
# wxSAMPLE_FOLDER IDE sub folder to be used for the samples
|
2021-01-15 19:33:55 -05:00
|
|
|
|
2016-09-25 16:19:39 -04:00
|
|
|
function(wx_add_sample name)
|
2021-01-15 19:33:55 -05:00
|
|
|
wx_add(${name} "Samples" ${ARGN})
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(wx_add_test name)
|
|
|
|
wx_add(${name} "Tests" ${ARGN})
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(wx_add_demo name)
|
|
|
|
wx_add(${name} "Demos" ${ARGN})
|
|
|
|
endfunction()
|
|
|
|
|
2021-02-07 14:15:37 -05:00
|
|
|
function(wx_add_benchmark name)
|
|
|
|
wx_add(${name} "Benchmarks" ${ARGN})
|
|
|
|
endfunction()
|
|
|
|
|
2021-01-15 19:33:55 -05:00
|
|
|
function(wx_add name group)
|
|
|
|
cmake_parse_arguments(APP
|
2021-02-07 14:11:56 -05:00
|
|
|
"CONSOLE;CONSOLE_GUI;DLL;IMPORTANT"
|
2016-09-25 16:19:39 -04:00
|
|
|
"NAME;FOLDER"
|
|
|
|
"DATA;DEFINITIONS;DEPENDS;LIBRARIES;RES"
|
|
|
|
${ARGN}
|
|
|
|
)
|
2021-01-15 19:33:55 -05:00
|
|
|
|
|
|
|
if(APP_NAME)
|
|
|
|
set(target_name ${APP_NAME})
|
|
|
|
else()
|
|
|
|
set(target_name ${name})
|
2016-09-25 16:19:39 -04:00
|
|
|
endif()
|
|
|
|
|
2021-01-15 19:33:55 -05:00
|
|
|
if(group STREQUAL Samples)
|
|
|
|
if(NOT APP_IMPORTANT AND NOT wxBUILD_SAMPLES STREQUAL "ALL")
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
set(SUB_DIR "samples/${wxSAMPLE_SUBDIR}${name}")
|
|
|
|
set(DEFAULT_RC_FILE "samples/sample.rc")
|
|
|
|
elseif(group STREQUAL Tests)
|
|
|
|
if(NOT APP_CONSOLE AND NOT wxBUILD_TESTS STREQUAL "ALL")
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
set(SUB_DIR "tests")
|
|
|
|
set(DEFAULT_RC_FILE "samples/sample.rc")
|
|
|
|
elseif(group STREQUAL Demos)
|
|
|
|
set(SUB_DIR "demos/${name}")
|
|
|
|
set(DEFAULT_RC_FILE "demos/${name}/${target_name}.rc")
|
2021-02-07 14:15:37 -05:00
|
|
|
elseif(group STREQUAL Benchmarks)
|
|
|
|
set(SUB_DIR "tests/benchmarks")
|
|
|
|
set(DEFAULT_RC_FILE "samples/sample.rc")
|
2021-01-15 19:33:55 -05:00
|
|
|
else()
|
|
|
|
message(WARNING "Unkown group \"${group}\"")
|
2016-09-25 16:19:39 -04:00
|
|
|
return()
|
|
|
|
endif()
|
2021-01-15 19:33:55 -05:00
|
|
|
|
|
|
|
foreach(depend ${APP_DEPENDS})
|
2016-09-25 16:19:39 -04:00
|
|
|
if(NOT ${depend})
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2017-12-09 08:38:11 -05:00
|
|
|
|
2021-01-15 19:33:55 -05:00
|
|
|
# Only build GUI applications with wxUSE_GUI=1
|
|
|
|
if(NOT wxUSE_GUI AND NOT APP_CONSOLE)
|
2016-09-25 16:19:39 -04:00
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
2021-01-15 19:33:55 -05:00
|
|
|
if(APP_UNPARSED_ARGUMENTS)
|
2016-09-25 16:19:39 -04:00
|
|
|
wx_list_add_prefix(src_files
|
2021-01-15 19:33:55 -05:00
|
|
|
"${wxSOURCE_DIR}/${SUB_DIR}/"
|
|
|
|
${APP_UNPARSED_ARGUMENTS})
|
2016-09-25 16:19:39 -04:00
|
|
|
else()
|
|
|
|
# If no source files have been specified use default src name
|
2021-01-15 19:33:55 -05:00
|
|
|
set(src_files ${wxSOURCE_DIR}/${SUB_DIR}/${name}.cpp)
|
2016-09-25 16:19:39 -04:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WIN32)
|
2021-01-15 19:33:55 -05:00
|
|
|
if(APP_RES)
|
|
|
|
foreach(res ${APP_RES})
|
|
|
|
list(APPEND src_files ${wxSOURCE_DIR}/${SUB_DIR}/${res})
|
2016-09-25 16:19:39 -04:00
|
|
|
endforeach()
|
|
|
|
else()
|
2021-01-15 19:33:55 -05:00
|
|
|
# Include default resource file
|
|
|
|
list(APPEND src_files ${wxSOURCE_DIR}/${DEFAULT_RC_FILE})
|
2016-09-25 16:19:39 -04:00
|
|
|
endif()
|
|
|
|
elseif(APPLE AND NOT IPHONE)
|
|
|
|
list(APPEND src_files ${wxSOURCE_DIR}/src/osx/carbon/wxmac.icns)
|
|
|
|
endif()
|
|
|
|
|
2021-01-15 19:33:55 -05:00
|
|
|
if(APP_DLL)
|
2016-09-25 16:19:39 -04:00
|
|
|
add_library(${target_name} SHARED ${src_files})
|
|
|
|
else()
|
2021-02-07 14:11:56 -05:00
|
|
|
if(APP_CONSOLE OR APP_CONSOLE_GUI)
|
2016-09-25 16:19:39 -04:00
|
|
|
set(exe_type)
|
|
|
|
else()
|
|
|
|
set(exe_type WIN32 MACOSX_BUNDLE)
|
|
|
|
endif()
|
2019-10-28 19:33:43 -04:00
|
|
|
|
|
|
|
if (WXMSW AND DEFINED wxUSE_DPI_AWARE_MANIFEST)
|
|
|
|
set(wxDPI_MANIFEST_PRFIX "wx")
|
|
|
|
if (wxARCH_SUFFIX)
|
|
|
|
set(wxDPI_MANIFEST_PRFIX "amd64")
|
|
|
|
endif()
|
|
|
|
set(wxUSE_DPI_AWARE_MANIFEST_VALUE 0)
|
|
|
|
if (${wxUSE_DPI_AWARE_MANIFEST} MATCHES "system")
|
|
|
|
set(wxUSE_DPI_AWARE_MANIFEST_VALUE 1)
|
2019-12-13 15:44:26 -05:00
|
|
|
list(APPEND src_files "${wxSOURCE_DIR}/include/wx/msw/${wxDPI_MANIFEST_PRFIX}_dpi_aware.manifest")
|
2019-10-28 19:33:43 -04:00
|
|
|
elseif(${wxUSE_DPI_AWARE_MANIFEST} MATCHES "per-monitor")
|
|
|
|
set(wxUSE_DPI_AWARE_MANIFEST_VALUE 2)
|
2019-12-13 15:44:26 -05:00
|
|
|
list(APPEND src_files "${wxSOURCE_DIR}/include/wx/msw/${wxDPI_MANIFEST_PRFIX}_dpi_aware_pmv2.manifest")
|
2019-10-28 19:33:43 -04:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2016-09-25 16:19:39 -04:00
|
|
|
add_executable(${target_name} ${exe_type} ${src_files})
|
2019-10-28 19:33:43 -04:00
|
|
|
|
|
|
|
if (DEFINED wxUSE_DPI_AWARE_MANIFEST_VALUE)
|
|
|
|
target_compile_definitions(${target_name} PRIVATE wxUSE_DPI_AWARE_MANIFEST=${wxUSE_DPI_AWARE_MANIFEST_VALUE})
|
|
|
|
endif()
|
2016-09-25 16:19:39 -04:00
|
|
|
endif()
|
2021-01-15 19:33:55 -05:00
|
|
|
|
|
|
|
# All applications use at least the base library other libraries
|
2016-09-25 16:19:39 -04:00
|
|
|
# will have to be added with wx_link_sample_libraries()
|
2020-05-17 13:41:44 -04:00
|
|
|
wx_exe_link_libraries(${target_name} wxbase)
|
2021-01-15 19:33:55 -05:00
|
|
|
if(NOT APP_CONSOLE)
|
|
|
|
# UI applications always require core
|
2020-05-17 13:41:44 -04:00
|
|
|
wx_exe_link_libraries(${target_name} wxcore)
|
2016-09-25 16:19:39 -04:00
|
|
|
else()
|
|
|
|
target_compile_definitions(${target_name} PRIVATE wxUSE_GUI=0 wxUSE_BASE=1)
|
|
|
|
endif()
|
2021-01-15 19:33:55 -05:00
|
|
|
if(APP_LIBRARIES)
|
|
|
|
wx_exe_link_libraries(${target_name} ${APP_LIBRARIES})
|
2016-09-25 16:19:39 -04:00
|
|
|
endif()
|
|
|
|
if(wxBUILD_SHARED)
|
|
|
|
target_compile_definitions(${target_name} PRIVATE WXUSINGDLL)
|
|
|
|
endif()
|
2021-01-15 19:33:55 -05:00
|
|
|
if(APP_DEFINITIONS)
|
|
|
|
target_compile_definitions(${target_name} PRIVATE ${APP_DEFINITIONS})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(group STREQUAL Samples)
|
|
|
|
target_include_directories(${target_name} PRIVATE ${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)
|
2016-09-25 16:19:39 -04:00
|
|
|
endif()
|
2021-01-15 19:33:55 -05:00
|
|
|
|
|
|
|
if(APP_DATA)
|
2016-09-25 16:19:39 -04:00
|
|
|
# TODO: handle data files differently for OS X bundles
|
|
|
|
# Copy data files to output directory
|
2021-01-15 19:33:55 -05:00
|
|
|
foreach(data_src ${APP_DATA})
|
2020-05-17 13:41:22 -04:00
|
|
|
string(FIND ${data_src} ":" HAS_COLON)
|
|
|
|
if(${HAS_COLON} GREATER -1)
|
|
|
|
MATH(EXPR DEST_INDEX "${HAS_COLON}+1")
|
|
|
|
string(SUBSTRING ${data_src} ${DEST_INDEX} -1 data_dst)
|
|
|
|
string(SUBSTRING ${data_src} 0 ${HAS_COLON} data_src)
|
|
|
|
else()
|
|
|
|
set(data_dst ${data_src})
|
|
|
|
endif()
|
|
|
|
|
2017-12-09 08:38:11 -05:00
|
|
|
list(APPEND cmds COMMAND ${CMAKE_COMMAND}
|
2021-01-15 19:33:55 -05:00
|
|
|
-E copy ${wxSOURCE_DIR}/${SUB_DIR}/${data_src}
|
2020-05-17 13:41:22 -04:00
|
|
|
${wxOUTPUT_DIR}/${wxPLATFORM_LIB_DIR}/${data_dst})
|
2016-09-25 16:19:39 -04:00
|
|
|
endforeach()
|
|
|
|
add_custom_command(
|
|
|
|
TARGET ${target_name} ${cmds}
|
2021-01-15 19:33:55 -05:00
|
|
|
COMMENT "Copying ${target_name} data files...")
|
2016-09-25 16:19:39 -04:00
|
|
|
endif()
|
2021-01-15 19:33:55 -05:00
|
|
|
|
|
|
|
if(APPLE)
|
2016-09-25 16:19:39 -04:00
|
|
|
if(NOT IPHONE)
|
|
|
|
set_target_properties(${target_name} PROPERTIES
|
2018-02-23 09:33:22 -05:00
|
|
|
MACOSX_BUNDLE_INFO_PLIST "${wxSOURCE_DIR}/samples/Info.plist.in"
|
2016-09-25 16:19:39 -04:00
|
|
|
RESOURCE "${wxSOURCE_DIR}/src/osx/carbon/wxmac.icns")
|
|
|
|
endif()
|
|
|
|
set_target_properties(${target_name} PROPERTIES
|
|
|
|
MACOSX_BUNDLE_ICON_FILE wxmac.icns
|
|
|
|
MACOSX_BUNDLE_LONG_VERSION_STRING "${wxVERSION}"
|
|
|
|
MACOSX_BUNDLE_SHORT_VERSION_STRING "${wxVERSION}"
|
|
|
|
MACOSX_BUNDLE_VERSION "${wxVERSION}"
|
|
|
|
MACOSX_BUNDLE_COPYRIGHT "${wxCOPYRIGHT}"
|
|
|
|
MACOSX_BUNDLE_GUI_IDENTIFIER "org.wxwidgets.${target_name}"
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2021-01-15 19:33:55 -05:00
|
|
|
if(APP_FOLDER)
|
|
|
|
set(APP_FOLDER ${group}/${APP_FOLDER})
|
|
|
|
elseif(wxSAMPLE_FOLDER)
|
|
|
|
set(APP_FOLDER ${group}/${wxSAMPLE_FOLDER})
|
|
|
|
else()
|
|
|
|
set(APP_FOLDER ${group})
|
2016-09-25 16:19:39 -04:00
|
|
|
endif()
|
|
|
|
wx_set_common_target_properties(${target_name})
|
2021-01-15 19:33:55 -05:00
|
|
|
wx_app_enable_precomp(${target_name})
|
2016-09-25 16:19:39 -04:00
|
|
|
set_target_properties(${target_name} PROPERTIES
|
2021-01-15 19:33:55 -05:00
|
|
|
FOLDER ${APP_FOLDER}
|
2016-09-25 16:19:39 -04:00
|
|
|
)
|
2018-01-10 16:56:42 -05:00
|
|
|
set_target_properties(${target_name} PROPERTIES
|
2021-01-15 19:34:03 -05:00
|
|
|
VS_DEBUGGER_WORKING_DIRECTORY "${wxOUTPUT_DIR}/${wxPLATFORM_LIB_DIR}"
|
2018-01-10 16:56:42 -05:00
|
|
|
)
|
2021-01-15 19:33:55 -05:00
|
|
|
|
|
|
|
if(group STREQUAL Tests)
|
|
|
|
add_test(NAME ${target_name}
|
|
|
|
COMMAND ${target_name}
|
2021-01-15 19:34:03 -05:00
|
|
|
WORKING_DIRECTORY "${wxOUTPUT_DIR}/${wxPLATFORM_LIB_DIR}")
|
2021-01-15 19:33:55 -05:00
|
|
|
endif()
|
2016-09-25 16:19:39 -04:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
# Link libraries to a sample
|
|
|
|
function(wx_link_sample_libraries name)
|
2020-05-17 13:41:57 -04:00
|
|
|
if(TARGET ${name})
|
|
|
|
target_link_libraries(${name} PUBLIC ${ARGN})
|
|
|
|
endif()
|
2016-09-25 16:19:39 -04:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
# Add a option and mark is as advanced if it starts with wxUSE_
|
|
|
|
# wx_option(<name> <desc> [default] [STRINGS strings])
|
|
|
|
# The default is ON if not third parameter is specified
|
|
|
|
function(wx_option name desc)
|
|
|
|
cmake_parse_arguments(OPTION "" "" "STRINGS" ${ARGN})
|
|
|
|
if(ARGC EQUAL 2)
|
|
|
|
set(default ON)
|
|
|
|
else()
|
|
|
|
set(default ${OPTION_UNPARSED_ARGUMENTS})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(OPTION_STRINGS)
|
|
|
|
set(cache_type STRING)
|
|
|
|
else()
|
|
|
|
set(cache_type BOOL)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(${name} "${default}" CACHE ${cache_type} "${desc}")
|
|
|
|
string(SUBSTRING ${name} 0 6 prefix)
|
|
|
|
if(prefix STREQUAL "wxUSE_")
|
|
|
|
mark_as_advanced(${name})
|
|
|
|
endif()
|
|
|
|
if(OPTION_STRINGS)
|
|
|
|
set_property(CACHE ${name} PROPERTY STRINGS ${OPTION_STRINGS})
|
|
|
|
# Check valid value
|
|
|
|
set(value_is_valid FALSE)
|
|
|
|
set(avail_values)
|
|
|
|
foreach(opt ${OPTION_STRINGS})
|
|
|
|
if(${name} STREQUAL opt)
|
|
|
|
set(value_is_valid TRUE)
|
|
|
|
break()
|
|
|
|
endif()
|
|
|
|
wx_string_append(avail_values " ${opt}")
|
|
|
|
endforeach()
|
|
|
|
if(NOT value_is_valid)
|
|
|
|
message(FATAL_ERROR "Invalid value \"${${name}}\" for option ${name}. Valid values are: ${avail_values}")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
# Force a new value for an option created with wx_option
|
|
|
|
function(wx_option_force_value name value)
|
|
|
|
get_property(helpstring CACHE ${name} PROPERTY HELPSTRING)
|
|
|
|
get_property(type CACHE ${name} PROPERTY TYPE)
|
|
|
|
set(${name} ${value} CACHE ${type} ${helpstring} FORCE)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
macro(wx_dependent_option option doc default depends force)
|
|
|
|
if(${option}_ISSET MATCHES "^${option}_ISSET$")
|
|
|
|
set(${option}_AVAILABLE 1)
|
|
|
|
foreach(d ${depends})
|
|
|
|
string(REGEX REPLACE " +" ";" CMAKE_DEPENDENT_OPTION_DEP "${d}")
|
|
|
|
if(${CMAKE_DEPENDENT_OPTION_DEP})
|
|
|
|
else()
|
|
|
|
set(${option}_AVAILABLE 0)
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
if(${option}_AVAILABLE)
|
|
|
|
wx_option(${option} "${doc}" "${default}")
|
|
|
|
set(${option} "${${option}}" CACHE BOOL "${doc}" FORCE)
|
|
|
|
else()
|
|
|
|
if(${option} MATCHES "^${option}$")
|
|
|
|
else()
|
|
|
|
set(${option} "${${option}}" CACHE INTERNAL "${doc}")
|
|
|
|
endif()
|
|
|
|
set(${option} ${force})
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(${option} "${${option}_ISSET}")
|
|
|
|
endif()
|
|
|
|
endmacro()
|