CMake: Add benchmarks

Put each benchmark application in a sub-directory instead of specifying all in one
file, because cotire cannot create PCH targets for the same file twice (bench.cpp).
This commit is contained in:
Maarten Bent 2021-02-07 20:15:37 +01:00
parent 7b79423470
commit 9585e08365
7 changed files with 102 additions and 2 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,12 +605,12 @@ function(wx_print_thirdparty_library_summary)
message(STATUS ${message})
endfunction()
# Add sample, test or demo
# 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
@ -640,6 +640,10 @@ 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;CONSOLE_GUI;DLL;IMPORTANT"
@ -669,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()

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,6 +15,7 @@ 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")
wx_option(wxBUILD_INSTALL "Create install/uninstall target for wxWidgets")
wx_option(wxBUILD_COMPATIBILITY