From 72a493bbade4b14b8d61bff9173e89452dc5d7c5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=D0=A0=D0=BE=D0=BC=D0=B0=D0=BD=20=D0=9C=D0=B8=D1=85=D0=B0?= =?utf8?q?=D0=B9=D0=BB=D0=BE=D0=B2=D0=B8=D1=87=20=D0=A0=D1=83=D1=81=D1=8F?= =?utf8?q?=D0=B5=D0=B2/AI=20Tools=20Lab=20/SRR/Staff=20Engineer/=EC=82=BC?= =?utf8?q?=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Fri, 31 Aug 2018 18:23:29 +0300 Subject: [PATCH] Fix build bugs: not enabled target if its dependent targets are unavailable (#1258) Targets for tests won't be built if main targets aren't set Signed-off-by: Roman Rusyaev --- contrib/nnc/examples/caffe_frontend/CMakeLists.txt | 4 ++++ contrib/nnc/examples/tflite_frontend/CMakeLists.txt | 4 ++++ contrib/nnc/tests/import/CMakeLists.txt | 17 ++++++++++------- contrib/nnc/tests/interpreter/CMakeLists.txt | 10 +++++++++- contrib/nnc/unittests/core/CMakeLists.txt | 4 +++- contrib/nnc/unittests/module/CMakeLists.txt | 15 ++++++++------- contrib/nnc/unittests/soft_backend/CMakeLists.txt | 6 ++++-- 7 files changed, 42 insertions(+), 18 deletions(-) diff --git a/contrib/nnc/examples/caffe_frontend/CMakeLists.txt b/contrib/nnc/examples/caffe_frontend/CMakeLists.txt index dc3fe20..0bfe328 100644 --- a/contrib/nnc/examples/caffe_frontend/CMakeLists.txt +++ b/contrib/nnc/examples/caffe_frontend/CMakeLists.txt @@ -1,3 +1,7 @@ +if (NOT TARGET caffe_importer) + return () +endif() + add_nncc_example_executable(caffe_model_dumper ${OPTIONS_SRC} model_dump.cpp) nncc_target_link_libraries(caffe_model_dumper nnc_support caffe_importer) target_include_directories(caffe_model_dumper PRIVATE ${NNC_CAFFE_FRONTEND_DIR}) \ No newline at end of file diff --git a/contrib/nnc/examples/tflite_frontend/CMakeLists.txt b/contrib/nnc/examples/tflite_frontend/CMakeLists.txt index 5a26def..101430d 100644 --- a/contrib/nnc/examples/tflite_frontend/CMakeLists.txt +++ b/contrib/nnc/examples/tflite_frontend/CMakeLists.txt @@ -1,3 +1,7 @@ +if (NOT TARGET tflite_import) + return () +endif() + add_executable(tflite_import_example sanity_check.cpp ${OPTIONS_SRC}) target_link_libraries(tflite_import_example PUBLIC tflite_schema) diff --git a/contrib/nnc/tests/import/CMakeLists.txt b/contrib/nnc/tests/import/CMakeLists.txt index 023ddba..1ca2461 100644 --- a/contrib/nnc/tests/import/CMakeLists.txt +++ b/contrib/nnc/tests/import/CMakeLists.txt @@ -9,11 +9,14 @@ # These executables are not executed anywhere because it is not yet decided # how to store large files (in this case, files with models), and how to run all system tests. # As soon as it is decided, model files should be added, as well as the code that runs the tests. +if (TARGET tflite_import) + add_executable(system_test_import_tflite tflite.cpp ${OPTIONS_SRC}) + target_link_libraries(system_test_import_tflite PRIVATE nnc_support tflite_import) + target_include_directories(system_test_import_tflite PRIVATE ${NNC_TFLITE_FRONTEND_DIR}) +endif() -add_executable(system_test_import_tflite tflite.cpp ${OPTIONS_SRC}) -target_link_libraries(system_test_import_tflite PRIVATE nnc_support tflite_import) -target_include_directories(system_test_import_tflite PRIVATE ${NNC_TFLITE_FRONTEND_DIR}) - -add_executable(system_test_import_caffe caffe.cpp ${OPTIONS_SRC}) -target_link_libraries(system_test_import_caffe PRIVATE nnc_support caffe_importer) -target_include_directories(system_test_import_caffe PRIVATE ${NNC_CAFFE_FRONTEND_DIR}) +if (TARGET caffe_importer) + add_executable(system_test_import_caffe caffe.cpp ${OPTIONS_SRC}) + target_link_libraries(system_test_import_caffe PRIVATE nnc_support caffe_importer) + target_include_directories(system_test_import_caffe PRIVATE ${NNC_CAFFE_FRONTEND_DIR}) +endif() diff --git a/contrib/nnc/tests/interpreter/CMakeLists.txt b/contrib/nnc/tests/interpreter/CMakeLists.txt index b05e79c..68d15e9 100644 --- a/contrib/nnc/tests/interpreter/CMakeLists.txt +++ b/contrib/nnc/tests/interpreter/CMakeLists.txt @@ -1,4 +1,12 @@ -nncc_find_package(FlatBuffers REQUIRED) +nncc_find_package(FlatBuffers QUIET) +if (NOT FlatBuffers_FOUND) + return() +endif() + +if (NOT TARGET getst) + # we can't built this target properly if unit tests is disabled + return() +endif() # Compile flatbuffers schemas # Produces FB_GEN_SOURCES and FB_GEN_INCLUDE_DIRS variables diff --git a/contrib/nnc/unittests/core/CMakeLists.txt b/contrib/nnc/unittests/core/CMakeLists.txt index ff437a2..3129338 100644 --- a/contrib/nnc/unittests/core/CMakeLists.txt +++ b/contrib/nnc/unittests/core/CMakeLists.txt @@ -2,4 +2,6 @@ file(GLOB_RECURSE HEADERS "${NNC_CORE_DIR}/include/*.h") file(GLOB_RECURSE TESTS "*.cpp") add_nncc_test(nnc_core_test ${TESTS}) -nncc_target_link_libraries(nnc_core_test nnc_core) +if (TARGET nnc_core_test) + nncc_target_link_libraries(nnc_core_test nnc_core) +endif() diff --git a/contrib/nnc/unittests/module/CMakeLists.txt b/contrib/nnc/unittests/module/CMakeLists.txt index 4c0697e..91034cf 100644 --- a/contrib/nnc/unittests/module/CMakeLists.txt +++ b/contrib/nnc/unittests/module/CMakeLists.txt @@ -2,11 +2,12 @@ file(GLOB_RECURSE TEST_SOURCES "*.cpp") # Plugin module tests add_nncc_test(nnc_module_test ${OPTIONS_SRC} ${TEST_SOURCES} ${HEADERS}) -nncc_target_link_libraries(nnc_module_test nnc_support dl) - -# Set macro in nnc_module_test with some_parser absolute path -target_compile_definitions(nnc_module_test PRIVATE - CMAKE_SAMPLE_PLUGIN_ABS_PATH=$ - CMAKE_SAMPLE_PLUGIN_2_ABS_PATH=$ - CMAKE_SAMPLE_PLUGIN_DIR_ABS_PATH=$) +if (TARGET nnc_module_test) + nncc_target_link_libraries(nnc_module_test nnc_support dl) + # Set macro in nnc_module_test with some_parser absolute path + target_compile_definitions(nnc_module_test PRIVATE + CMAKE_SAMPLE_PLUGIN_ABS_PATH=$ + CMAKE_SAMPLE_PLUGIN_2_ABS_PATH=$ + CMAKE_SAMPLE_PLUGIN_DIR_ABS_PATH=$) +endif() diff --git a/contrib/nnc/unittests/soft_backend/CMakeLists.txt b/contrib/nnc/unittests/soft_backend/CMakeLists.txt index 5479caa..a67999c 100644 --- a/contrib/nnc/unittests/soft_backend/CMakeLists.txt +++ b/contrib/nnc/unittests/soft_backend/CMakeLists.txt @@ -7,5 +7,7 @@ file(GLOB_RECURSE TESTS "*.cpp") make_generated_sources("${SOFT_DEF_SOURCES}" ${CMAKE_CURRENT_BINARY_DIR} SOFT_GENERATED_SOURCES) add_nncc_test(nnc_soft_backend_test ${TESTS} ${OPTIONS_SRC} ${SOFT_BACKEND_CPP_SOURCES} ${SOFT_GENERATED_SOURCES}) -nncc_target_link_libraries(nnc_soft_backend_test nnc_support nnc_interpreter nnc_core soft_backend_common) -target_include_directories(nnc_soft_backend_test PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${NNC_SOFT_BACKEND_DIR}) +if (TARGET nnc_soft_backend_test) + nncc_target_link_libraries(nnc_soft_backend_test nnc_support nnc_interpreter nnc_core soft_backend_common) + target_include_directories(nnc_soft_backend_test PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${NNC_SOFT_BACKEND_DIR}) +endif() -- 2.7.4