Skip to content

Commit ab9d785

Browse files
committed
Build perf via cmake.
1 parent e710d01 commit ab9d785

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ if(TAOCPP_JSON_BUILD_EXAMPLES)
5151
add_subdirectory(src/example/json)
5252
endif()
5353

54+
# performance
55+
option(TAOCPP_JSON_BUILD_PERFORMANCE "Build performance programs" ${TAOCPP_JSON_IS_MAIN_PROJECT})
56+
if(TAOCPP_JSON_BUILD_PERFORMANCE)
57+
add_subdirectory(src/perf/json)
58+
endif()
59+
5460
option(TAOCPP_JSON_INSTALL "Generate the install target" ${TAOCPP_JSON_IS_MAIN_PROJECT})
5561
if(TAOCPP_JSON_INSTALL)
5662
include(CMakePackageConfigHelpers)

src/perf/json/CMakeLists.txt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
cmake_minimum_required(VERSION 3.8...3.19)
2+
3+
set(perfsources
4+
benchmark.cpp
5+
parse_file.cpp
6+
pretty_print_file.cpp
7+
print_double.cpp
8+
print_file.cpp
9+
sizes.cpp
10+
syntax_only.cpp
11+
)
12+
13+
# file(GLOB ...) is used to validate the above list of perf_sources
14+
file(GLOB glob_perf_sources RELATIVE ${CMAKE_CURRENT_LIST_DIR} *.cpp)
15+
16+
foreach(perfsourcefile ${perfsources})
17+
if(${perfsourcefile} IN_LIST glob_perf_sources)
18+
list(REMOVE_ITEM glob_perf_sources ${perfsourcefile})
19+
else()
20+
message(SEND_ERROR "File ${perfsourcefile} is missing from src/perf/json")
21+
endif()
22+
get_filename_component(exename ${perfsourcefile} NAME_WE)
23+
set(exename "tao-json-perf-${exename}")
24+
add_executable(${exename} ${perfsourcefile})
25+
target_link_libraries(${exename} PRIVATE taocpp::json)
26+
set_target_properties(${exename} PROPERTIES
27+
CXX_STANDARD 11
28+
CXX_STANDARD_REQUIRED ON
29+
CXX_EXTENSIONS OFF
30+
)
31+
if(MSVC)
32+
target_compile_options(${exename} PRIVATE /W4 /WX /utf-8)
33+
else()
34+
target_compile_options(${exename} PRIVATE -pedantic -Wall -Wextra -Wshadow -Werror)
35+
endif()
36+
endforeach()
37+
38+
if(glob_perf_sources)
39+
foreach(ignored_source_file ${glob_perf_sources})
40+
message(SEND_ERROR "File ${ignored_source_file} in src/perf/json is ignored")
41+
endforeach()
42+
endif()

0 commit comments

Comments
 (0)