Fix C/C++ files generation (#704)
authorVitaliy Cherepanov/AI Tools Lab /SRR/Engineer/삼성전자 <v.cherepanov@samsung.com>
Thu, 19 Jul 2018 14:11:37 +0000 (17:11 +0300)
committerSergey Vostokov/AI Tools Lab /SRR/Staff Engineer/삼성전자 <s.vostokov@samsung.com>
Thu, 19 Jul 2018 14:11:37 +0000 (23:11 +0900)
generation header from *.def files:
 - created separate rule for each def file
 - fix library dependency

Signed-off-by: Vitaliy Cherepanov <v.cherepanov@samsung.com>
contrib/nnc/libs/backend/soft/CMakeLists.txt

index 4da485c..d6c8f80 100644 (file)
@@ -6,17 +6,17 @@ file(GLOB_RECURSE TESTS "src/*.test.cpp")
 file(GLOB_RECURSE SOFT_DEF_SOURCES include/*.def)
 list(REMOVE_ITEM SOFT_BACKEND_SOURCES ${TESTS} ${DEF_CONV})
 
-# TODO move this macro to common make file
-macro(replace_ext ext dest_list src_list)
-    SET(${dest_list} "")
-    FOREACH(file IN LISTS ${src_list})
-        GET_FILENAME_COMPONENT(file_path ${file} PATH)
-        GET_FILENAME_COMPONENT(file_name ${file} NAME_WE)
-        list(APPEND ${dest_list} "${file_path}/${file_name}/${ext}")
-    ENDFOREACH()
-endmacro()
-
-replace_ext(".h" SOFT_GENERATED_SOURCES SOFT_DEF_SOURCES)
+set(SOFT_GENERATED_SOURCES "")
+foreach(file IN LISTS SOFT_DEF_SOURCES)
+    get_filename_component(file_name ${file} NAME_WE)
+    set(out_file "${CMAKE_CURRENT_BINARY_DIR}/${file_name}.h")
+    list(APPEND SOFT_GENERATED_SOURCES "${out_file}")
+    add_custom_command(
+            OUTPUT  ${out_file}
+            COMMAND def2src ${CMAKE_CURRENT_BINARY_DIR} ${file}
+            DEPENDS def2src ${file}
+    )
+endforeach()
 
 add_library(soft_backend SHARED ${SOFT_BACKEND_SOURCES} ${SOFT_GENERATED_SOURCES})
 
@@ -27,12 +27,6 @@ target_include_directories(nnc_soft_backend_test PRIVATE ${CMAKE_CURRENT_BINARY_
 
 add_executable(def2src ${DEF_CONV})
 
-add_custom_command(
-        OUTPUT  ${SOFT_GENERATED_SOURCES}
-        COMMAND def2src ${CMAKE_CURRENT_BINARY_DIR} ${SOFT_DEF_SOURCES}
-        DEPENDS def2src ${SOFT_DEF_SOURCES}
-)
-
 target_link_libraries(soft_backend PRIVATE nncc_core)
 
 target_include_directories(soft_backend PUBLIC include)