11add_executable (benchmark
22 benchmark.cpp
3- ieeeToString.cpp
43)
5-
4+ add_library (benchmark_deps INTERFACE )
5+ add_library (ieeeToString ieeeToString.cpp)
6+ target_include_directories (ieeeToString PRIVATE ${ryu_SOURCE_DIR} )
7+ target_link_libraries (benchmark_deps INTERFACE ieeeToString)
68include (CheckSourceCompiles)
79check_source_compiles(CXX "
810#include <charconv>
@@ -15,7 +17,7 @@ int main(void) {
1517 return 0;
1618}
1719" FROM_CHARS_OK)
18- target_compile_definitions (benchmark PUBLIC FROM_CHARS_SUPPORTED=$<IF:$<BOOL :${FROM_CHARS_OK} >,1,0>)
20+ target_compile_definitions (benchmark_deps INTERFACE FROM_CHARS_SUPPORTED=$<IF:$<BOOL :${FROM_CHARS_OK} >,1,0>)
1921check_source_compiles(CXX "
2022#include <charconv>
2123int main(void) {
@@ -27,7 +29,7 @@ int main(void) {
2729 return 0;
2830}
2931" TO_CHARS_OK)
30- target_compile_definitions (benchmark PUBLIC TO_CHARS_SUPPORTED=$<IF:$<BOOL :${TO_CHARS_OK} >,1,0>)
32+ target_compile_definitions (benchmark_deps INTERFACE TO_CHARS_SUPPORTED=$<IF:$<BOOL :${TO_CHARS_OK} >,1,0>)
3133if (TO_CHARS_OK)
3234 message (STATUS "std::to_chars with floats is supported" )
3335else (TO_CHARS_OK)
@@ -42,45 +44,55 @@ CPMAddPackage(
4244 NAME fast_float
4345 GITHUB_REPOSITORY "fastfloat/fast_float"
4446 GIT_TAG v8.0.2)
45- target_link_libraries (benchmark PUBLIC fast_float)
47+ target_link_libraries (benchmark_deps INTERFACE fast_float)
4648if (NOT WIN32 )
47- target_link_libraries (benchmark PUBLIC netlib)
48- target_compile_definitions (benchmark PUBLIC NETLIB_SUPPORTED=1)
49+ target_link_libraries (benchmark_deps INTERFACE netlib)
50+ target_compile_definitions (benchmark_deps INTERFACE NETLIB_SUPPORTED=1)
4951else ()
50- target_compile_definitions (benchmark PUBLIC NETLIB_SUPPORTED=0)
52+ target_compile_definitions (benchmark_deps INTERFACE NETLIB_SUPPORTED=0)
5153endif ()
5254
5355if (NOT CYGWIN )
54- target_link_libraries (benchmark PUBLIC absl::str_format)
55- target_compile_definitions (benchmark PUBLIC ABSEIL_SUPPORTED=1)
56+ target_link_libraries (benchmark_deps INTERFACE absl::str_format)
57+ target_compile_definitions (benchmark_deps INTERFACE ABSEIL_SUPPORTED=1)
5658else ()
57- target_compile_definitions (benchmark PUBLIC ABSEIL_SUPPORTED=0)
59+ target_compile_definitions (benchmark_deps INTERFACE ABSEIL_SUPPORTED=0)
5860endif ()
5961
6062if (TARGET errol)
61- target_link_libraries (benchmark PUBLIC errol)
62- target_compile_definitions (benchmark PUBLIC ERROL_SUPPORTED=1)
63+ target_link_libraries (benchmark_deps INTERFACE errol)
64+ target_compile_definitions (benchmark_deps INTERFACE ERROL_SUPPORTED=1)
6365else ()
64- target_compile_definitions (benchmark PUBLIC ERROL_SUPPORTED=0)
66+ target_compile_definitions (benchmark_deps INTERFACE ERROL_SUPPORTED=0)
6567endif ()
6668
67- target_link_libraries (benchmark PUBLIC fmt)
68- target_link_libraries (benchmark PUBLIC cxxopts)
69+ target_link_libraries (benchmark_deps INTERFACE fmt)
70+ target_link_libraries (benchmark_deps INTERFACE cxxopts)
6971
70- target_link_libraries (benchmark PUBLIC yy_double)
71- target_link_libraries (benchmark PUBLIC double-conversion)
72- target_link_libraries (benchmark PUBLIC ryu::ryu)
73- target_link_libraries (benchmark PUBLIC teju)
72+ target_link_libraries (benchmark_deps INTERFACE yy_double)
73+ target_link_libraries (benchmark_deps INTERFACE double-conversion)
74+ target_link_libraries (benchmark_deps INTERFACE ryu::ryu)
75+ target_link_libraries (benchmark_deps INTERFACE teju)
7476if (teju_has_float128)
75- target_link_libraries (benchmark PUBLIC teju_boost_multiprecision)
77+ target_link_libraries (benchmark_deps INTERFACE teju_boost_multiprecision)
7678endif ()
77- target_link_libraries (benchmark PUBLIC dragonbox::dragonbox_to_chars)
78- target_link_libraries (benchmark PUBLIC dragon_schubfach_lib)
79- target_link_libraries (benchmark PUBLIC dragon4_lib)
79+ target_link_libraries (benchmark_deps INTERFACE dragonbox::dragonbox_to_chars)
80+ target_link_libraries (benchmark_deps INTERFACE dragon_schubfach_lib)
81+ target_link_libraries (benchmark_deps INTERFACE dragon4_lib)
8082if (TARGET swift_lib)
81- target_link_libraries (benchmark PUBLIC swift_lib)
82- target_compile_definitions (benchmark PUBLIC SWIFT_LIB_SUPPORTED=1)
83+ target_link_libraries (benchmark_deps INTERFACE swift_lib)
84+ target_compile_definitions (benchmark_deps INTERFACE SWIFT_LIB_SUPPORTED=1)
8385else (TARGET swift_lib)
84- target_compile_definitions (benchmark PUBLIC SWIFT_LIB_SUPPORTED=0)
86+ target_compile_definitions (benchmark_deps INTERFACE SWIFT_LIB_SUPPORTED=0)
8587endif (TARGET swift_lib)
86- target_include_directories (benchmark PUBLIC ${grisu-exact_SOURCE_DIR})
88+ target_include_directories (benchmark_deps INTERFACE ${grisu-exact_SOURCE_DIR})
89+
90+ target_link_libraries (benchmark PUBLIC benchmark_deps)
91+
92+ if (TO_CHARS_OK AND FROM_CHARS_OK)
93+ add_executable (exhaustivefloat32
94+ exhaustivefloat32.cpp
95+ )
96+ target_link_libraries (exhaustivefloat32 PUBLIC benchmark_deps)
97+ endif (TO_CHARS_OK AND FROM_CHARS_OK)
98+
0 commit comments