|
| 1 | +get_filename_component(CURRENT_DIR_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME) |
| 2 | +project(CURRENT_DIR_NAME) |
| 3 | + |
| 4 | +set(exec_func_tests "ppc_func_tests") |
| 5 | +set(exec_perf_tests "ppc_perf_tests") |
| 6 | +set(test_base_dir "${CMAKE_CURRENT_SOURCE_DIR}/tests") |
| 7 | + |
| 8 | +# Init func tests executable files |
| 9 | +set(list_of_exec_tests "") |
| 10 | +if (USE_FUNC_TESTS) |
| 11 | + file(GLOB_RECURSE func_tests_source_files "${test_base_dir}/functional/*") |
| 12 | + target_sources(${exec_func_tests} PRIVATE ${func_tests_source_files}) |
| 13 | + list(APPEND list_of_exec_tests ${exec_func_tests}) |
| 14 | +endif (USE_FUNC_TESTS) |
| 15 | + |
| 16 | +# Init perf tests executable files |
| 17 | +if (USE_PERF_TESTS) |
| 18 | + file(GLOB_RECURSE perf_tests_source_files "${test_base_dir}/performance/*") |
| 19 | + target_sources(${exec_perf_tests} PRIVATE ${perf_tests_source_files}) |
| 20 | + list(APPEND list_of_exec_tests ${exec_perf_tests}) |
| 21 | +endif (USE_PERF_TESTS) |
| 22 | + |
| 23 | +# Print student task name |
| 24 | +get_filename_component(TASK_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) |
| 25 | +message(STATUS "-- ${TASK_NAME}") |
| 26 | + |
| 27 | +set(technologies "all" "mpi" "omp" "seq" "stl" "tbb") |
| 28 | + |
| 29 | +# Create lib |
| 30 | +foreach (dir_type ${technologies}) |
| 31 | + # Check directory existing |
| 32 | + set(base_dir "${CMAKE_CURRENT_SOURCE_DIR}/${dir_type}") |
| 33 | + if (NOT EXISTS "${base_dir}") |
| 34 | + continue() |
| 35 | + endif () |
| 36 | + |
| 37 | + # Print type of directories |
| 38 | + message(STATUS "-- -- ${dir_type}") |
| 39 | + |
| 40 | + # Create task library |
| 41 | + file(GLOB_RECURSE lib_source_files "${base_dir}/include/*" "${base_dir}/src/*") |
| 42 | + file(GLOB source_files "${base_dir}/src/*") |
| 43 | + |
| 44 | + list(LENGTH source_files result_length) |
| 45 | + set(name_lib "${TASK_NAME}_${dir_type}") |
| 46 | + if(result_length EQUAL 0) |
| 47 | + add_library(${name_lib} INTERFACE ${lib_source_files}) |
| 48 | + else() |
| 49 | + add_library(${name_lib} STATIC ${lib_source_files}) |
| 50 | + endif() |
| 51 | + set_target_properties(${name_lib} PROPERTIES LINKER_LANGUAGE CXX) |
| 52 | + target_link_libraries(${name_lib} PUBLIC core_module_lib) |
| 53 | + |
| 54 | + # Link core library |
| 55 | + foreach (exec_func ${list_of_exec_tests}) |
| 56 | + target_link_libraries(${exec_func} PUBLIC ${name_lib}) |
| 57 | + endforeach () |
| 58 | +endforeach () |
0 commit comments