@@ -7,6 +7,9 @@ cmake_minimum_required(VERSION 3.7)
7
7
# Project
8
8
project (gemmlowp C CXX)
9
9
10
+ include (CTest) # option(BUILD_TESTING). ON by default.
11
+ include (GNUInstallDirs)
12
+
10
13
# Set C++11 as default standard
11
14
set (CMAKE_CXX_STANDARD 11)
12
15
@@ -52,40 +55,71 @@ else()
52
55
endif ()
53
56
target_link_libraries (eight_bit_int_gemm ${EXTERNAL_LIBRARIES} )
54
57
55
- # Benchmarks
56
- add_executable (benchmark
57
- "${gemmlowp_src} /test/benchmark.cc" ${gemmlowp_test_headers} )
58
- target_link_libraries (benchmark ${EXTERNAL_LIBRARIES} )
59
-
60
- add_executable (benchmark_all_sizes
61
- "${gemmlowp_src} /test/benchmark_all_sizes.cc" ${gemmlowp_test_headers} )
62
- target_compile_options (benchmark_all_sizes PRIVATE -DBENCHMARK_8bit -DBENCHMARK_QUICK)
63
- target_link_libraries (benchmark_all_sizes ${EXTERNAL_LIBRARIES} )
64
-
65
- # Gemmlowp test
66
- add_executable (test_gemmlowp
67
- "${gemmlowp_src} /test/test.cc" "${gemmlowp_src} /test/test_data.cc" ${gemmlowp_test_headers} )
68
- target_link_libraries (test_gemmlowp eight_bit_int_gemm)
69
-
70
- # Math helpers test
71
- add_executable (test_math_helpers
72
- "${gemmlowp_src} /test/test_math_helpers.cc" ${gemmlowp_test_headers} )
73
-
74
- # BlockingCounter test
75
- add_executable (test_blocking_counter
76
- "${gemmlowp_src} /test/test_blocking_counter.cc" ${gemmlowp_test_headers} )
77
- target_link_libraries (test_blocking_counter ${EXTERNAL_LIBRARIES} )
78
-
79
- # Allocator test
80
- add_executable (test_allocator
81
- "${gemmlowp_src} /test/test_allocator.cc" ${gemmlowp_test_headers} )
82
-
83
- # FixedPoint test
84
- add_executable (test_fixedpoint
85
- "${gemmlowp_src} /test/test_fixedpoint.cc" ${gemmlowp_test_headers} )
86
-
87
- # Add tests
88
- enable_testing ()
89
- foreach (testname "test_math_helpers" "test_blocking_counter" "test_allocator" "test_fixedpoint" "test_gemmlowp" )
90
- add_test (NAME ${testname} COMMAND "${testname} " )
91
- endforeach (testname)
58
+ # INTERFACE target to help header include
59
+ add_library (gemmlowp INTERFACE )
60
+ target_include_directories (gemmlowp INTERFACE
61
+ $<BUILD_INTERFACE:${gemmlowp_src} >
62
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR} /gemmlowp>)
63
+ target_link_libraries (gemmlowp INTERFACE eight_bit_int_gemm)
64
+
65
+ install (FILES ${eight_bit_int_gemm_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} /gemmlowp/eight_bit_int_gemm)
66
+ file (GLOB meta_headers "${gemmlowp_src} /meta/*.h" )
67
+ install (FILES ${meta_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} /gemmlowp/meta)
68
+ file (GLOB public_headers "${gemmlowp_src} /public/*.h" )
69
+ install (FILES ${public_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} /gemmlowp/public )
70
+ file (GLOB profile_headers "${gemmlowp_src} /profiling/*.h" )
71
+ install (FILES ${profile_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} /gemmlowp/profiling)
72
+ file (GLOB internal_headers "${gemmlowp_src} /internal/*.h" )
73
+ install (FILES ${internal_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} /gemmlowp/internal )
74
+ file (GLOB fixedpoint_headers "${gemmlowp_src} /fixedpoint/*.h" )
75
+ install (FILES ${fixedpoint_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} /gemmlowp/fixedpoint)
76
+
77
+ install (TARGETS gemmlowp eight_bit_int_gemm
78
+ EXPORT gemmlowp-config # support find_package(gemmlowp CONFIG)
79
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
80
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
81
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} )
82
+
83
+ install (EXPORT gemmlowp-config # export gemmlowp::gemmlowp
84
+ NAMESPACE gemmlowp:: # gemmlowp::eight_bit_int_gemm
85
+ DESTINATION ${CMAKE_INSTALL_LIBDIR} /cmake/gemmlowp)
86
+
87
+ if (BUILD_TESTING)
88
+ # Benchmarks
89
+ add_executable (benchmark
90
+ "${gemmlowp_src} /test/benchmark.cc" ${gemmlowp_test_headers} )
91
+ target_link_libraries (benchmark ${EXTERNAL_LIBRARIES} )
92
+
93
+ add_executable (benchmark_all_sizes
94
+ "${gemmlowp_src} /test/benchmark_all_sizes.cc" ${gemmlowp_test_headers} )
95
+ target_compile_options (benchmark_all_sizes PRIVATE -DBENCHMARK_8bit -DBENCHMARK_QUICK)
96
+ target_link_libraries (benchmark_all_sizes ${EXTERNAL_LIBRARIES} )
97
+
98
+ # Gemmlowp test
99
+ add_executable (test_gemmlowp
100
+ "${gemmlowp_src} /test/test.cc" "${gemmlowp_src} /test/test_data.cc" ${gemmlowp_test_headers} )
101
+ target_link_libraries (test_gemmlowp eight_bit_int_gemm)
102
+
103
+ # Math helpers test
104
+ add_executable (test_math_helpers
105
+ "${gemmlowp_src} /test/test_math_helpers.cc" ${gemmlowp_test_headers} )
106
+
107
+ # BlockingCounter test
108
+ add_executable (test_blocking_counter
109
+ "${gemmlowp_src} /test/test_blocking_counter.cc" ${gemmlowp_test_headers} )
110
+ target_link_libraries (test_blocking_counter ${EXTERNAL_LIBRARIES} )
111
+
112
+ # Allocator test
113
+ add_executable (test_allocator
114
+ "${gemmlowp_src} /test/test_allocator.cc" ${gemmlowp_test_headers} )
115
+
116
+ # FixedPoint test
117
+ add_executable (test_fixedpoint
118
+ "${gemmlowp_src} /test/test_fixedpoint.cc" ${gemmlowp_test_headers} )
119
+
120
+ # Add tests
121
+ enable_testing ()
122
+ foreach (testname "test_math_helpers" "test_blocking_counter" "test_allocator" "test_fixedpoint" "test_gemmlowp" )
123
+ add_test (NAME ${testname} COMMAND "${testname} " )
124
+ endforeach (testname)
125
+ endif ()
0 commit comments