Skip to content

Commit 7351a71

Browse files
committed
build: auto-glob sources in cmake
1 parent 2d1cb7d commit 7351a71

11 files changed

Lines changed: 76 additions & 115 deletions

File tree

app/Accuracy/CMakeLists.txt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
set(INCLUDE_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/acc.hpp")
2-
set(SRC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/acc.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/acc_anchor.cpp")
3-
add_library(ACCLib STATIC ${INCLUDE_HEADERS} ${SRC_FILES})
1+
file(GLOB ACC_CPP CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
2+
file(GLOB ACC_HPP CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
3+
list(FILTER ACC_CPP EXCLUDE REGEX "accuracy_check\\.cpp$")
4+
5+
add_library(ACCLib STATIC ${ACC_HPP} ${ACC_CPP})
46

57
set_target_properties(ACCLib PROPERTIES LINKER_LANGUAGE CXX)
68

@@ -16,7 +18,8 @@ itlabai_target_defaults(ACCLib)
1618
add_dependencies(ACCLib opencv_external)
1719
target_compile_definitions(ACCLib PUBLIC IMAGE1_PATH="${ITLABAI_TEST_DATA_DIR}/lena.jpg")
1820

19-
add_executable(Accuracy_Check accuracy_check.cpp)
21+
file(GLOB ACC_MAIN CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/accuracy_check.cpp")
22+
add_executable(Accuracy_Check ${ACC_MAIN})
2023
target_link_libraries(Accuracy_Check PRIVATE ACCLib OpenCV::opencv_world)
2124
itlabai_link_externals(Accuracy_Check openmp)
2225
itlabai_target_defaults(Accuracy_Check)

app/Converters/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
add_executable(Reader_weights reader_weights_sample.cpp)
2-
add_executable(Reader_weights_onnx reader_weights_sample_onnx.cpp)
1+
file(GLOB READER_WEIGHTS_SRC CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/reader_weights_sample.cpp")
2+
file(GLOB READER_WEIGHTS_ONNX_SRC CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/reader_weights_sample_onnx.cpp")
3+
add_executable(Reader_weights ${READER_WEIGHTS_SRC})
4+
add_executable(Reader_weights_onnx ${READER_WEIGHTS_ONNX_SRC})
35
target_link_libraries(Reader_weights PUBLIC perf_lib layers_lib reader_lib)
46
target_link_libraries(Reader_weights_onnx PUBLIC perf_lib layers_lib reader_lib)
57
itlabai_target_defaults(Reader_weights)

app/Graph/CMakeLists.txt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
set(INCLUDE_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/build.hpp")
2-
set(SRC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/build.cpp")
3-
add_library(BuildGraph STATIC ${INCLUDE_HEADERS} ${SRC_FILES})
1+
file(GLOB BUILDGRAPH_CPP CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
2+
file(GLOB BUILDGRAPH_HPP CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
3+
list(FILTER BUILDGRAPH_CPP INCLUDE REGEX "/build\\.cpp$")
4+
5+
add_library(BuildGraph STATIC ${BUILDGRAPH_HPP} ${BUILDGRAPH_CPP})
46

57
set_target_properties(BuildGraph PROPERTIES LINKER_LANGUAGE CXX)
68

@@ -20,17 +22,20 @@ target_compile_definitions(BuildGraph PUBLIC
2022
MNIST_PATH="${CMAKE_SOURCE_DIR}/docs/mnist/mnist/test"
2123
)
2224

23-
add_executable(Graph_Build graph_build.cpp)
25+
file(GLOB GRAPH_BUILD_MAIN CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/graph_build.cpp")
26+
add_executable(Graph_Build ${GRAPH_BUILD_MAIN})
2427
target_link_libraries(Graph_Build PRIVATE BuildGraph)
2528
itlabai_target_defaults(Graph_Build)
2629
itlabai_apply_runtime_rpath(Graph_Build)
2730

28-
add_executable(ACC acc_check.cpp)
31+
file(GLOB ACC_MAIN CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/acc_check.cpp")
32+
add_executable(ACC ${ACC_MAIN})
2933
target_link_libraries(ACC PRIVATE BuildGraph OpenCV::opencv_world)
3034
itlabai_target_defaults(ACC)
3135
itlabai_apply_runtime_rpath(ACC)
3236

33-
add_executable(onnx_subgraphs onnx_subgraphs.cpp)
37+
file(GLOB ONNX_SUBGRAPHS_MAIN CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/onnx_subgraphs.cpp")
38+
add_executable(onnx_subgraphs ${ONNX_SUBGRAPHS_MAIN})
3439
target_link_libraries(onnx_subgraphs PRIVATE BuildGraph)
3540
if(ITLABAI_ENABLE_OPENMP AND TARGET OpenMP::OpenMP_CXX)
3641
target_link_libraries(onnx_subgraphs PRIVATE OpenMP::OpenMP_CXX)

app/ReaderImage/CMakeLists.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
set(INCLUDE_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/reader_img.hpp")
2-
set(SRC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/reader_img_s.cpp")
3-
add_library(ReadLib STATIC ${INCLUDE_HEADERS} ${SRC_FILES})
1+
file(GLOB READER_IMG_HEADERS CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
2+
file(GLOB READER_IMG_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/*_s.cpp")
3+
add_library(ReadLib STATIC ${READER_IMG_HEADERS} ${READER_IMG_SOURCES})
44

55
set_target_properties(ReadLib PROPERTIES LINKER_LANGUAGE CXX)
66

@@ -10,7 +10,8 @@ itlabai_target_defaults(ReadLib)
1010
add_dependencies(ReadLib opencv_external)
1111
target_compile_definitions(ReadLib PUBLIC IMAGE1_PATH="${ITLABAI_TEST_DATA_DIR}/lena.jpg")
1212

13-
add_executable(Reader reader_img.cpp)
13+
file(GLOB READER_MAIN CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/reader_img.cpp")
14+
add_executable(Reader ${READER_MAIN})
1415
target_link_libraries(Reader PRIVATE ReadLib OpenCV::opencv_world)
1516
itlabai_target_defaults(Reader)
1617
itlabai_apply_runtime_rpath(Reader)

include/CMakeLists.txt

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,21 @@
1-
set(GRAPH_HEADERS
2-
${CMAKE_CURRENT_SOURCE_DIR}/graph/graph.hpp
3-
${CMAKE_CURRENT_SOURCE_DIR}/graph/runtime_options.hpp
1+
file(GLOB_RECURSE GRAPH_HEADERS CONFIGURE_DEPENDS
2+
"${CMAKE_CURRENT_SOURCE_DIR}/graph/*.hpp"
43
)
5-
set(GRAPHT_HEADERS
6-
${CMAKE_CURRENT_SOURCE_DIR}/graph_transformations/graph_transformations.hpp
4+
file(GLOB_RECURSE GRAPHT_HEADERS CONFIGURE_DEPENDS
5+
"${CMAKE_CURRENT_SOURCE_DIR}/graph_transformations/*.hpp"
76
)
8-
set(LAYERS_HEADERS
9-
${CMAKE_CURRENT_SOURCE_DIR}/layers/BatchNormalizationLayer.hpp
10-
${CMAKE_CURRENT_SOURCE_DIR}/layers/BinaryOpLayer.hpp
11-
${CMAKE_CURRENT_SOURCE_DIR}/layers/ConcatLayer.hpp
12-
${CMAKE_CURRENT_SOURCE_DIR}/layers/ConvLayer.hpp
13-
${CMAKE_CURRENT_SOURCE_DIR}/layers/DropOutLayer.hpp
14-
${CMAKE_CURRENT_SOURCE_DIR}/layers/EWLayer.hpp
15-
${CMAKE_CURRENT_SOURCE_DIR}/layers/FCLayer.hpp
16-
${CMAKE_CURRENT_SOURCE_DIR}/layers/FlattenLayer.hpp
17-
${CMAKE_CURRENT_SOURCE_DIR}/layers/InputLayer.hpp
18-
${CMAKE_CURRENT_SOURCE_DIR}/layers/Layer.hpp
19-
${CMAKE_CURRENT_SOURCE_DIR}/layers/MatmulLayer.hpp
20-
${CMAKE_CURRENT_SOURCE_DIR}/layers/OutputLayer.hpp
21-
${CMAKE_CURRENT_SOURCE_DIR}/layers/PoolingLayer.hpp
22-
${CMAKE_CURRENT_SOURCE_DIR}/layers/ReduceLayer.hpp
23-
${CMAKE_CURRENT_SOURCE_DIR}/layers/ReshapeLayer.hpp
24-
${CMAKE_CURRENT_SOURCE_DIR}/layers/Shape.hpp
25-
${CMAKE_CURRENT_SOURCE_DIR}/layers/SoftmaxLayer.hpp
26-
${CMAKE_CURRENT_SOURCE_DIR}/layers/SplitLayer.hpp
27-
${CMAKE_CURRENT_SOURCE_DIR}/layers/Tensor.hpp
28-
${CMAKE_CURRENT_SOURCE_DIR}/layers/TransposeLayer.hpp
29-
${CMAKE_CURRENT_SOURCE_DIR}/parallel/backends.hpp
30-
${CMAKE_CURRENT_SOURCE_DIR}/parallel/parallel.hpp
7+
file(GLOB_RECURSE LAYERS_HEADERS CONFIGURE_DEPENDS
8+
"${CMAKE_CURRENT_SOURCE_DIR}/layers/*.hpp"
9+
"${CMAKE_CURRENT_SOURCE_DIR}/parallel/*.hpp"
3110
)
32-
set(LAYERS_ONEDNN_HEADERS
33-
${CMAKE_CURRENT_SOURCE_DIR}/layers_oneDNN/ConvLayer.hpp
34-
${CMAKE_CURRENT_SOURCE_DIR}/layers_oneDNN/EWLayer.hpp
11+
file(GLOB_RECURSE LAYERS_ONEDNN_HEADERS CONFIGURE_DEPENDS
12+
"${CMAKE_CURRENT_SOURCE_DIR}/layers_oneDNN/*.hpp"
3513
)
36-
set(PERF_HEADERS
37-
${CMAKE_CURRENT_SOURCE_DIR}/perf/benchmarking.hpp
14+
file(GLOB_RECURSE PERF_HEADERS CONFIGURE_DEPENDS
15+
"${CMAKE_CURRENT_SOURCE_DIR}/perf/*.hpp"
3816
)
39-
set(READER_HEADERS
40-
${CMAKE_CURRENT_SOURCE_DIR}/Weights_Reader/reader_weights.hpp
17+
file(GLOB_RECURSE READER_HEADERS CONFIGURE_DEPENDS
18+
"${CMAKE_CURRENT_SOURCE_DIR}/Weights_Reader/*.hpp"
4119
)
4220
set(GRAPH_HEADERS "${GRAPH_HEADERS}" PARENT_SCOPE)
4321
set(GRAPHT_HEADERS "${GRAPHT_HEADERS}" PARENT_SCOPE)

src/Weights_Reader/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
file(GLOB READER_SOURCES CONFIGURE_DEPENDS
2+
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
3+
)
4+
15
add_library(reader_lib STATIC)
2-
target_sources(reader_lib PRIVATE reader_weights.cpp ${READER_HEADERS})
6+
target_sources(reader_lib PRIVATE ${READER_SOURCES} ${READER_HEADERS})
37
target_include_directories(reader_lib
48
PUBLIC
59
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>

src/graph/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
file(GLOB GRAPH_SOURCES CONFIGURE_DEPENDS
2+
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
3+
)
4+
15
add_library(graph_lib STATIC)
2-
target_sources(graph_lib PRIVATE graph.cpp ${GRAPH_HEADERS})
6+
target_sources(graph_lib PRIVATE ${GRAPH_SOURCES} ${GRAPH_HEADERS})
37
target_include_directories(graph_lib
48
PUBLIC
59
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>

src/graph_transformations/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
file(GLOB GRAPHT_SOURCES CONFIGURE_DEPENDS
2+
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
3+
)
4+
15
add_library(graphT_lib STATIC)
2-
target_sources(graphT_lib PRIVATE graph_transformations.cpp ${GRAPHT_HEADERS})
6+
target_sources(graphT_lib PRIVATE ${GRAPHT_SOURCES} ${GRAPHT_HEADERS})
37
target_include_directories(graphT_lib
48
PUBLIC
59
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>

src/layers/CMakeLists.txt

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,9 @@
1-
add_library(layers_lib STATIC)
2-
target_sources(layers_lib
3-
PRIVATE
4-
BatchNormalizationLayer.cpp
5-
BinaryOpLayer.cpp
6-
ConcatLayer.cpp
7-
ConvLayer.cpp
8-
DropOutLayer.cpp
9-
EWLayer.cpp
10-
FCLayer.cpp
11-
FlattenLayer.cpp
12-
Layer.cpp
13-
MatmulLayer.cpp
14-
OutputLayer.cpp
15-
PoolingLayer.cpp
16-
ReduceLayer.cpp
17-
ReshapeLayer.cpp
18-
Shape.cpp
19-
SoftmaxLayer.cpp
20-
SplitLayer.cpp
21-
Tensor.cpp
22-
TransposeLayer.cpp
23-
${LAYERS_HEADERS}
1+
file(GLOB LAYERS_SOURCES CONFIGURE_DEPENDS
2+
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
243
)
4+
5+
add_library(layers_lib STATIC)
6+
target_sources(layers_lib PRIVATE ${LAYERS_SOURCES} ${LAYERS_HEADERS})
257
target_include_directories(layers_lib
268
PUBLIC
279
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>

src/layers_oneDNN/CMakeLists.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
add_library(layers_oneDNN_lib STATIC)
2-
target_sources(layers_oneDNN_lib
3-
PRIVATE
4-
ConvLayer.cpp
5-
EWLayer.cpp
6-
${LAYERS_ONEDNN_HEADERS}
1+
file(GLOB LAYERS_ONEDNN_SOURCES CONFIGURE_DEPENDS
2+
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
73
)
4+
5+
add_library(layers_oneDNN_lib STATIC)
6+
target_sources(layers_oneDNN_lib PRIVATE ${LAYERS_ONEDNN_SOURCES} ${LAYERS_ONEDNN_HEADERS})
87
target_include_directories(layers_oneDNN_lib
98
PUBLIC
109
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>

0 commit comments

Comments
 (0)