Add support for building benchmarks with CMake.

See https://github.com/wxWidgets/wxWidgets/pull/2220
This commit is contained in:
Vadim Zeitlin
2021-02-08 12:46:18 +01:00
10 changed files with 113 additions and 8 deletions

View File

@@ -0,0 +1,12 @@
#############################################################################
# Name: build/cmake/benchmarks/CMakeLists.txt
# Purpose: CMake file for benchmarks
# Author: Maarten Bent
# Created: 2021-02-07
# Copyright: (c) 2021 wxWidgets development team
# Licence: wxWindows licence
#############################################################################
add_subdirectory(bench)
add_subdirectory(bench_graphics)
add_subdirectory(bench_gui)

View File

@@ -0,0 +1,34 @@
#############################################################################
# Name: build/cmake/benchmarks/bench/CMakeLists.txt
# Purpose: CMake file for benchmarks
# Author: Maarten Bent
# Created: 2021-02-07
# Copyright: (c) 2021 wxWidgets development team
# Licence: wxWindows licence
#############################################################################
set(BENCH_SRC
bench.cpp
bench.h
datetime.cpp
htmlparser/htmlpars.cpp
htmlparser/htmlpars.h
htmlparser/htmltag.cpp
htmlparser/htmltag.h
ipcclient.cpp
log.cpp
mbconv.cpp
printfbench.cpp
strings.cpp
tls.cpp
)
set(BENCH_DATA
htmltest.html
)
wx_add_benchmark(bench CONSOLE ${BENCH_SRC} DATA ${BENCH_DATA})
if(wxUSE_SOCKETS)
wx_exe_link_libraries(bench wxnet)
endif()

View File

@@ -0,0 +1,18 @@
#############################################################################
# Name: build/cmake/benchmarks/bench_graphics/CMakeLists.txt
# Purpose: CMake file for benchmarks
# Author: Maarten Bent
# Created: 2021-02-07
# Copyright: (c) 2021 wxWidgets development team
# Licence: wxWindows licence
#############################################################################
set(BENCH_GRAPGICS_SRC
graphics.cpp
)
wx_add_benchmark(bench_graphics CONSOLE_GUI ${BENCH_GRAPGICS_SRC})
if(wxUSE_OPENGL)
wx_exe_link_libraries(bench_graphics wxgl)
endif()

View File

@@ -0,0 +1,24 @@
#############################################################################
# Name: build/cmake/benchmarks/bench_gui/CMakeLists.txt
# Purpose: CMake file for benchmarks
# Author: Maarten Bent
# Created: 2021-02-07
# Copyright: (c) 2021 wxWidgets development team
# Licence: wxWindows licence
#############################################################################
set(BENCH_GUI_SRC
bench.cpp
bench.h
display.cpp
image.cpp
)
set(IMAGE_DATA
../../samples/image/horse.bmp:horse.bmp
../../samples/image/horse.jpg:horse.jpg
../../samples/image/horse.png:horse.png
../../samples/image/horse.tif:horse.tif
)
wx_add_benchmark(bench_gui CONSOLE_GUI ${BENCH_GUI_SRC} DATA ${IMAGE_DATA})

View File

@@ -605,13 +605,14 @@ function(wx_print_thirdparty_library_summary)
message(STATUS ${message})
endfunction()
# Add sample, test or demo
# wx_add(<name> <group> [CONSOLE|DLL] [IMPORTANT] [SRC_FILES...]
# Add sample, test, demo or benchmark
# wx_add(<name> <group> [CONSOLE|CONSOLE_GUI|DLL] [IMPORTANT] [SRC_FILES...]
# [LIBRARIES ...] [NAME target_name] [FOLDER folder]
# [DATA ...] [DEFINITIONS ...] [RES ...])
# name default target name
# group can be Samples, Tests or Demos
# group can be Samples, Tests, Demos or Benchmarks
# first parameter may be CONSOLE to indicate a console application or DLL to indicate a shared library
# or CONSOLE_GUI to indicate a console application that uses gui libraries
# all following parameters are src files for the executable
#
# Optionally:
@@ -639,9 +640,13 @@ function(wx_add_demo name)
wx_add(${name} "Demos" ${ARGN})
endfunction()
function(wx_add_benchmark name)
wx_add(${name} "Benchmarks" ${ARGN})
endfunction()
function(wx_add name group)
cmake_parse_arguments(APP
"CONSOLE;DLL;IMPORTANT"
"CONSOLE;CONSOLE_GUI;DLL;IMPORTANT"
"NAME;FOLDER"
"DATA;DEFINITIONS;DEPENDS;LIBRARIES;RES"
${ARGN}
@@ -668,6 +673,9 @@ function(wx_add name group)
elseif(group STREQUAL Demos)
set(SUB_DIR "demos/${name}")
set(DEFAULT_RC_FILE "demos/${name}/${target_name}.rc")
elseif(group STREQUAL Benchmarks)
set(SUB_DIR "tests/benchmarks")
set(DEFAULT_RC_FILE "samples/sample.rc")
else()
message(WARNING "Unkown group \"${group}\"")
return()
@@ -709,7 +717,7 @@ function(wx_add name group)
if(APP_DLL)
add_library(${target_name} SHARED ${src_files})
else()
if(APP_CONSOLE OR group STREQUAL Tests)
if(APP_CONSOLE OR APP_CONSOLE_GUI)
set(exe_type)
else()
set(exe_type WIN32 MACOSX_BUNDLE)

View File

@@ -32,6 +32,10 @@ if(wxBUILD_DEMOS)
add_subdirectory(build/cmake/demos demos)
endif()
if(wxBUILD_BENCHMARKS)
add_subdirectory(build/cmake/benchmarks benchmarks)
endif()
if(NOT wxBUILD_CUSTOM_SETUP_HEADER_PATH)
# Write setup.h after all variables are available
include(build/cmake/setup.cmake)

View File

@@ -15,10 +15,13 @@ wx_option(wxBUILD_SAMPLES "Build only important samples (SOME) or ALL" OFF
wx_option(wxBUILD_TESTS "Build console tests (CONSOLE_ONLY) or ALL" OFF
STRINGS CONSOLE_ONLY ALL OFF)
wx_option(wxBUILD_DEMOS "Build demos" OFF)
wx_option(wxBUILD_BENCHMARKS "Build benchmarks" OFF)
wx_option(wxBUILD_PRECOMP "Use precompiled headers")
mark_as_advanced(wxBUILD_PRECOMP)
wx_option(wxBUILD_INSTALL "Create install/uninstall target for wxWidgets")
wx_option(wxBUILD_COMPATIBILITY
"enable compatibilty with earlier wxWidgets versions" 3.0 STRINGS 2.8 3.0 3.1)
mark_as_advanced(wxBUILD_COMPATIBILITY)
# Allow user specified setup.h folder
set(wxBUILD_CUSTOM_SETUP_HEADER_PATH "" CACHE PATH "Include path containing custom wx/setup.h")
mark_as_advanced(wxBUILD_CUSTOM_SETUP_HEADER_PATH)
@@ -32,10 +35,12 @@ mark_as_advanced(wxBUILD_DEBUG_LEVEL)
if(NOT APPLE)
wx_option(wxBUILD_USE_STATIC_RUNTIME "Link using the static runtime library" OFF)
mark_as_advanced(wxBUILD_USE_STATIC_RUNTIME)
endif()
if(MSVC)
wx_option(wxBUILD_MSVC_MULTIPROC "Enable multi-processor compilation for MSVC")
mark_as_advanced(wxBUILD_MSVC_MULTIPROC)
endif()
if(NOT MSVC OR MSVC_VERSION GREATER 1800)

View File

@@ -37,7 +37,7 @@ set(TEST_DRAWING_DATA
drawing/references/image_test_image_gdiplus-6.1_2_ref.png
)
wx_add_test(test_drawing ${TEST_DRAWING_SRC}
wx_add_test(test_drawing CONSOLE_GUI ${TEST_DRAWING_SRC}
DATA ${TEST_DRAWING_DATA}
)
if(wxUSE_SOCKETS)

View File

@@ -181,7 +181,7 @@ set(TEST_GUI_DATA
intl/ja/internat.po
)
wx_add_test(test_gui ${TEST_GUI_SRC}
wx_add_test(test_gui CONSOLE_GUI ${TEST_GUI_SRC}
DATA ${TEST_GUI_DATA}
)
if(wxUSE_AUI)

View File

@@ -17,7 +17,7 @@ set(TEST_SRC
allheaders.h
)
wx_add_test(test_headers ${TEST_SRC})
wx_add_test(test_headers CONSOLE_GUI ${TEST_SRC})
if(wxUSE_SOCKETS)
wx_exe_link_libraries(test_headers wxnet)
endif()