From 19ed277ec2f0a321599428f118d43e0cf2ad88f7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Staff=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Thu, 14 Jun 2018 18:53:10 +0900 Subject: [PATCH] Add 'add_subdirectories' module (#288) This commit adds 'add_subdirectores' module which provides 'add_subdirectories' function, and simplifies top-level CMakeLists.txt using this new function. Signed-off-by: Jonghyun Park --- CMakeLists.txt | 2 ++ cmake/modules/add_subdirectories.cmake | 10 ++++++++++ contrib/CMakeLists.txt | 7 +------ libs/CMakeLists.txt | 4 +--- libs/frontend/CMakeLists.txt | 3 +-- tools/CMakeLists.txt | 1 + 6 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 cmake/modules/add_subdirectories.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e5135a..ca27820 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,6 +87,8 @@ function(add_nncc_test) endif(ENABLE_TEST) endfunction(add_nncc_test) +nncc_include(add_subdirectories) + ### ### Components ### diff --git a/cmake/modules/add_subdirectories.cmake b/cmake/modules/add_subdirectories.cmake new file mode 100644 index 0000000..10b272b --- /dev/null +++ b/cmake/modules/add_subdirectories.cmake @@ -0,0 +1,10 @@ +function(add_subdirectories) + file(GLOB PROJECT_FILES + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + "*/CMakeLists.txt") + + foreach(PROJECT_FILE IN ITEMS ${PROJECT_FILES}) + get_filename_component(PROJECT_DIR ${PROJECT_FILE} DIRECTORY) + add_subdirectory(${PROJECT_DIR}) + endforeach(PROJECT_FILE) +endfunction(add_subdirectories) diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index 78417ea..5ea6cda 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -1,6 +1 @@ -file(GLOB CONTRIB_CMAKE_FILES "*/CMakeLists.txt") - -foreach(CONTRIB_CMAKE_FILE ${CONTRIB_CMAKE_FILES}) - get_filename_component(CONTRIB_BASE ${CONTRIB_CMAKE_FILE} DIRECTORY) - add_subdirectory(${CONTRIB_BASE}) -endforeach(CONTRIB_CMAKE_FILE ${CONTRIB_CMAKE_FILES}) +add_subdirectories() diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt index 9583add..5ea6cda 100644 --- a/libs/CMakeLists.txt +++ b/libs/CMakeLists.txt @@ -1,3 +1 @@ -add_subdirectory(foundation) -add_subdirectory(core) -add_subdirectory(frontend) +add_subdirectories() diff --git a/libs/frontend/CMakeLists.txt b/libs/frontend/CMakeLists.txt index 1562556..5ea6cda 100644 --- a/libs/frontend/CMakeLists.txt +++ b/libs/frontend/CMakeLists.txt @@ -1,2 +1 @@ -add_subdirectory(caffe) -add_subdirectory(tflite) +add_subdirectories() diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index e69de29..5ea6cda 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectories() -- 2.7.4