@@ -8,27 +8,32 @@ add_library(fpm INTERFACE)
8
8
9
9
target_include_directories (fpm INTERFACE include )
10
10
11
+ # if this project is being used as a submodule, it's someone elses' dependency.
12
+ # in that case, we don't want to set up any testing, since they just want to
13
+ # use it as a library.
14
+ get_directory_property (hasParent PARENT_DIRECTORY )
15
+ if (NOT hasParent)
11
16
#
12
17
# Test suite
13
18
#
14
19
enable_testing ()
15
20
include (GoogleTest)
16
21
17
22
add_executable (fpm-test
18
- tests/arithmetic.cpp
19
- tests/arithmetic_int.cpp
20
- tests/basic_math.cpp
21
- tests/constants.cpp
22
- tests/conversion.cpp
23
- tests/classification.cpp
24
- tests/customizations.cpp
25
- tests/detail.cpp
26
- tests/input .cpp
27
- tests/manip.cpp
28
- tests/nearest.cpp
29
- tests/output .cpp
30
- tests/power.cpp
31
- tests/trigonometry.cpp
23
+ tests/arithmetic.cpp
24
+ tests/arithmetic_int.cpp
25
+ tests/basic_math.cpp
26
+ tests/constants.cpp
27
+ tests/conversion.cpp
28
+ tests/classification.cpp
29
+ tests/customizations.cpp
30
+ tests/detail.cpp
31
+ tests/input .cpp
32
+ tests/manip.cpp
33
+ tests/nearest.cpp
34
+ tests/output .cpp
35
+ tests/power.cpp
36
+ tests/trigonometry.cpp
32
37
)
33
38
set_target_properties (fpm-test PROPERTIES CXX_STANDARD 11)
34
39
target_link_libraries (fpm-test PRIVATE fpm gtest_main)
@@ -44,29 +49,29 @@ include(ExternalProject)
44
49
set (LIBFIXMATH_ROOT "${CMAKE_CURRENT_BINARY_DIR} /libfixmath" )
45
50
46
51
ExternalProject_Add(libfixmath-external
47
- GIT_REPOSITORY "https://github.com/PetteriAimonen/libfixmath.git"
48
- GIT_TAG bada934981a5961569ad2cb6b9006ed94542cc9c
49
- PREFIX ${LIBFIXMATH_ROOT}
50
- CONFIGURE_COMMAND ""
51
- BUILD_COMMAND ""
52
- INSTALL_COMMAND ""
52
+ GIT_REPOSITORY "https://github.com/PetteriAimonen/libfixmath.git"
53
+ GIT_TAG bada934981a5961569ad2cb6b9006ed94542cc9c
54
+ PREFIX ${LIBFIXMATH_ROOT}
55
+ CONFIGURE_COMMAND ""
56
+ BUILD_COMMAND ""
57
+ INSTALL_COMMAND ""
53
58
)
54
59
55
60
set (LIBFIXMATH_SOURCES
56
- ${LIBFIXMATH_ROOT} /src/libfixmath-external/libfixmath/fix16.c
57
- ${LIBFIXMATH_ROOT} /src/libfixmath-external/libfixmath/fix16_exp.c
58
- ${LIBFIXMATH_ROOT} /src/libfixmath-external/libfixmath/fix16_sqrt.c
59
- ${LIBFIXMATH_ROOT} /src/libfixmath-external/libfixmath/fix16_str.c
60
- ${LIBFIXMATH_ROOT} /src/libfixmath-external/libfixmath/fix16_trig.c
61
- ${LIBFIXMATH_ROOT} /src/libfixmath-external/libfixmath/fract32.c
62
- ${LIBFIXMATH_ROOT} /src/libfixmath-external/libfixmath/uint32.c
61
+ ${LIBFIXMATH_ROOT} /src/libfixmath-external/libfixmath/fix16.c
62
+ ${LIBFIXMATH_ROOT} /src/libfixmath-external/libfixmath/fix16_exp.c
63
+ ${LIBFIXMATH_ROOT} /src/libfixmath-external/libfixmath/fix16_sqrt.c
64
+ ${LIBFIXMATH_ROOT} /src/libfixmath-external/libfixmath/fix16_str.c
65
+ ${LIBFIXMATH_ROOT} /src/libfixmath-external/libfixmath/fix16_trig.c
66
+ ${LIBFIXMATH_ROOT} /src/libfixmath-external/libfixmath/fract32.c
67
+ ${LIBFIXMATH_ROOT} /src/libfixmath-external/libfixmath/uint32.c
63
68
)
64
69
set_source_files_properties (${LIBFIXMATH_SOURCES} PROPERTIES GENERATED TRUE )
65
70
add_library (libfixmath ${LIBFIXMATH_SOURCES} )
66
71
67
72
# Set libfixmath compile options to match fpm functionality
68
73
target_compile_definitions (libfixmath
69
- PUBLIC
74
+ PUBLIC
70
75
FIXMATH_NO_CACHE # No caching of results
71
76
72
77
#FIXMATH_NO_OVERFLOW # We want no runtime-overflow detection, but it fails to compile
@@ -86,12 +91,12 @@ add_dependencies(libfixmath libfixmath-external)
86
91
set (LIBCNL_ROOT "${CMAKE_CURRENT_BINARY_DIR} /libcnl" )
87
92
88
93
ExternalProject_Add(libcnl-external
89
- GIT_REPOSITORY "https://github.com/johnmcfarlane/cnl"
90
- GIT_TAG 4d445566fe7c6c8939fffc145a2f30fd587796a6
91
- PREFIX ${LIBCNL_ROOT}
92
- CONFIGURE_COMMAND ""
93
- BUILD_COMMAND ""
94
- INSTALL_COMMAND ""
94
+ GIT_REPOSITORY "https://github.com/johnmcfarlane/cnl"
95
+ GIT_TAG 4d445566fe7c6c8939fffc145a2f30fd587796a6
96
+ PREFIX ${LIBCNL_ROOT}
97
+ CONFIGURE_COMMAND ""
98
+ BUILD_COMMAND ""
99
+ INSTALL_COMMAND ""
95
100
)
96
101
97
102
add_library (libcnl INTERFACE )
@@ -103,9 +108,9 @@ add_dependencies(libcnl libcnl-external)
103
108
# Runs benchmarks of FPM operations and dumps results to standard output.
104
109
#
105
110
add_executable (fpm-benchmark
106
- benchmarks/arithmetic.cpp
107
- benchmarks/power.cpp
108
- benchmarks/trigonometry.cpp
111
+ benchmarks/arithmetic.cpp
112
+ benchmarks/power.cpp
113
+ benchmarks/trigonometry.cpp
109
114
)
110
115
target_link_libraries (fpm-benchmark PRIVATE fpm libfixmath libcnl benchmark benchmark_main)
111
116
@@ -114,20 +119,20 @@ target_link_libraries(fpm-benchmark PRIVATE fpm libfixmath libcnl benchmark benc
114
119
# Dumps the accuracy of approximated FPM functions to JSON files.
115
120
#
116
121
add_executable (fpm-accuracy
117
- accuracy/accuracy.cpp
122
+ accuracy/accuracy.cpp
118
123
)
119
124
set_target_properties (fpm-accuracy PROPERTIES CXX_STANDARD 14)
120
125
target_link_libraries (fpm-accuracy PRIVATE fpm libfixmath)
121
126
122
127
123
128
include (FindGnuplot)
124
129
if (GNUPLOT_FOUND)
125
- # Create accuracy data
126
- set (DATA_DIR ${CMAKE_CURRENT_BINARY_DIR} )
130
+ # Create accuracy data
131
+ set (DATA_DIR ${CMAKE_CURRENT_BINARY_DIR} )
127
132
128
- set (DATA_FILES_ACCURACY "" )
129
- set (IMG_FILES_ACCURACY "" )
130
- foreach (DATA sin-trig cos-trig tan-trig asin-invtrig acos-invtrig atan-invtrig atan2-trig sqrt-auto cbrt-auto pow-auto exp-auto exp2-auto log -auto log2-auto log10-auto)
133
+ set (DATA_FILES_ACCURACY "" )
134
+ set (IMG_FILES_ACCURACY "" )
135
+ foreach (DATA sin-trig cos-trig tan-trig asin-invtrig acos-invtrig atan-invtrig atan2-trig sqrt-auto cbrt-auto pow-auto exp-auto exp2-auto log -auto log2-auto log10-auto)
131
136
string (REGEX MATCHALL "[^-]+" M ${DATA} )
132
137
list (GET M 0 SERIES)
133
138
list (GET M 1 TYPE )
@@ -137,62 +142,63 @@ if (GNUPLOT_FOUND)
137
142
list (APPEND IMG_FILES_ACCURACY ${IMG_FILE} )
138
143
139
144
add_custom_command (
140
- OUTPUT ${IMG_FILE}
141
- COMMAND ${GNUPLOT_EXECUTABLE} -c ${PROJECT_SOURCE_DIR} /accuracy/accuracy.gnuplot ${SERIES} ${TYPE}
142
- DEPENDS ${DATA_DIR} /${SERIES} .csv accuracy/accuracy.gnuplot
143
- WORKING_DIRECTORY ${DATA_DIR}
144
- VERBATIM
145
- COMMENT "Plotting ${SERIES} accuracy data"
145
+ OUTPUT ${IMG_FILE}
146
+ COMMAND ${GNUPLOT_EXECUTABLE} -c ${PROJECT_SOURCE_DIR} /accuracy/accuracy.gnuplot ${SERIES} ${TYPE}
147
+ DEPENDS ${DATA_DIR} /${SERIES} .csv accuracy/accuracy.gnuplot
148
+ WORKING_DIRECTORY ${DATA_DIR}
149
+ VERBATIM
150
+ COMMENT "Plotting ${SERIES} accuracy data"
146
151
)
147
- endforeach (DATA)
152
+ endforeach (DATA)
148
153
149
- add_custom_command (
154
+ add_custom_command (
150
155
OUTPUT ${DATA_FILES_ACCURACY}
151
156
COMMAND fpm-accuracy
152
157
DEPENDS fpm-accuracy
153
158
WORKING_DIRECTORY ${DATA_DIR}
154
159
VERBATIM
155
160
COMMENT "Generating accuracy data with fpm-accuracy"
156
- )
161
+ )
157
162
158
- add_custom_target (fpm-accuracy-images DEPENDS ${IMG_FILES_ACCURACY} )
163
+ add_custom_target (fpm-accuracy-images DEPENDS ${IMG_FILES_ACCURACY} )
159
164
endif ()
160
165
161
166
if (CMAKE_BUILD_TYPE STREQUAL "Release" )
162
- # Enable the performance data-generation command only for Release builds.
167
+ # Enable the performance data-generation command only for Release builds.
163
168
164
- set (DATA_FILE_PERFORMANCE_JSON ${DATA_DIR} /performance.json)
165
- add_custom_command (
169
+ set (DATA_FILE_PERFORMANCE_JSON ${DATA_DIR} /performance.json)
170
+ add_custom_command (
166
171
OUTPUT ${DATA_FILE_PERFORMANCE_JSON}
167
172
COMMAND fpm-benchmark --benchmark_out=${DATA_FILE_PERFORMANCE_JSON} --benchmark_out_format=json
168
173
DEPENDS fpm-benchmark
169
174
WORKING_DIRECTORY ${DATA_DIR}
170
175
VERBATIM
171
176
COMMENT "Generating performance data with fpm-benchmark"
172
- )
177
+ )
173
178
174
- set (DATA_FILE_PERFORMANCE_GNUPLOT ${DATA_DIR} /performance.csv)
175
- add_custom_command (
179
+ set (DATA_FILE_PERFORMANCE_GNUPLOT ${DATA_DIR} /performance.csv)
180
+ add_custom_command (
176
181
OUTPUT ${DATA_FILE_PERFORMANCE_GNUPLOT}
177
182
COMMAND python ${PROJECT_SOURCE_DIR} /benchmarks/benchmark.py ${DATA_FILE_PERFORMANCE_JSON} ${DATA_FILE_PERFORMANCE_GNUPLOT}
178
183
DEPENDS ${DATA_FILE_PERFORMANCE_JSON} ${PROJECT_SOURCE_DIR} /benchmarks/benchmark.py
179
184
WORKING_DIRECTORY ${DATA_DIR}
180
185
VERBATIM
181
186
COMMENT "Converting performance data for GnuPlot"
182
- )
187
+ )
183
188
184
- set (IMG_FILE_PERFORMANCE "{$DATA_DIR}/performance.png" )
185
- add_custom_command (
189
+ set (IMG_FILE_PERFORMANCE "{$DATA_DIR}/performance.png" )
190
+ add_custom_command (
186
191
OUTPUT ${IMG_FILE_PERFORMANCE}
187
192
COMMAND ${GNUPLOT_EXECUTABLE} ${PROJECT_SOURCE_DIR} /benchmarks/benchmark.gnuplot
188
193
DEPENDS ${DATA_FILE_PERFORMANCE_GNUPLOT} ${PROJECT_SOURCE_DIR} /benchmarks/benchmark.gnuplot
189
194
WORKING_DIRECTORY ${DATA_DIR}
190
195
VERBATIM
191
196
COMMENT "Plotting performance data"
192
- )
197
+ )
193
198
194
- add_custom_target (fpm-performance-images DEPENDS ${IMG_FILE_PERFORMANCE} )
199
+ add_custom_target (fpm-performance-images DEPENDS ${IMG_FILE_PERFORMANCE} )
195
200
endif ()
196
201
197
202
add_subdirectory (3rdparty/googlebench)
198
203
add_subdirectory (3rdparty/googletest)
204
+ endif ()
0 commit comments