1- # Print student task name
2- get_filename_component (TASK_NAME ${CMAKE_CURRENT_LIST_DIR } NAME )
3- message (STATUS "-- ${TASK_NAME} " )
4-
51# Init project
6- project (${TASK_NAME} )
7- set (exec_func_tests "${TASK_NAME} _func_tests " )
8- set (exec_perf_tests "${TASK_NAME} _perf_tests " )
2+ project ("parallel_programming_course" )
3+ set (exec_func_tests "ppc_func_tests " )
4+ set (exec_perf_tests "ppc_perf_tests " )
95set (test_base_dir "${CMAKE_CURRENT_SOURCE_DIR } /tests" )
106
117# Init func tests executable files
128set (list_of_exec_tests "" )
139if (USE_FUNC_TESTS)
1410 file (GLOB_RECURSE func_tests_source_files "${test_base_dir} /func_tests/*" )
15- add_executable (${exec_func_tests} ${func_tests_source_files} " ${test_base_dir} /runner.cpp" )
11+ target_sources (${exec_func_tests} PRIVATE ${func_tests_source_files} )
1612 list (APPEND list_of_exec_tests ${exec_func_tests} )
1713endif (USE_FUNC_TESTS )
1814
1915# Init perf tests executable files
2016if (USE_PERF_TESTS)
2117 file (GLOB_RECURSE perf_tests_source_files "${test_base_dir} /perf_tests/*" )
22- add_executable (${exec_perf_tests} ${perf_tests_source_files} " ${test_base_dir} /runner.cpp" )
18+ target_sources (${exec_perf_tests} PRIVATE ${perf_tests_source_files} )
2319 list (APPEND list_of_exec_tests ${exec_perf_tests} )
2420endif (USE_PERF_TESTS )
2521
22+ # Print student task name
23+ get_filename_component (TASK_NAME ${CMAKE_CURRENT_LIST_DIR } NAME )
24+ message (STATUS "-- ${TASK_NAME} " )
25+
2626# Create lib
2727foreach (dir_type "all" "mpi" "omp" "seq" "stl" "tbb" )
2828 # Check directory existing
@@ -46,45 +46,10 @@ foreach (dir_type "all" "mpi" "omp" "seq" "stl" "tbb")
4646 add_library (${name_lib} STATIC ${lib_source_files} )
4747 endif ()
4848 set_target_properties (${name_lib} PROPERTIES LINKER_LANGUAGE CXX)
49+ target_link_libraries (${name_lib} PUBLIC core_module_lib )
4950
5051 # Link core library
51- target_link_libraries (${exec_func_tests} PUBLIC ${name_lib} core_module_lib )
52- target_link_libraries (${exec_perf_tests} PUBLIC ${name_lib} core_module_lib )
53- endforeach ()
54-
55- # Link 3rdparty libraries
56- add_library (stb_image INTERFACE )
57-
58- foreach (exec_func ${list_of_exec_tests} )
59- target_link_libraries (${exec_func} PUBLIC Threads::Threads )
60- target_link_libraries (${exec_func} PUBLIC ${OpenMP_libomp_LIBRARY} )
61- if ( MPI_COMPILE_FLAGS )
62- set_target_properties (${exec_func} PROPERTIES COMPILE_FLAGS "${MPI_COMPILE_FLAGS} " )
63- endif ( MPI_COMPILE_FLAGS )
64-
65- if ( MPI_LINK_FLAGS )
66- set_target_properties (${exec_func} PROPERTIES LINK_FLAGS "${MPI_LINK_FLAGS} " )
67- endif ( MPI_LINK_FLAGS )
68- target_link_libraries (${exec_func} PUBLIC ${MPI_LIBRARIES} )
69-
70- add_dependencies (${exec_func} ppc_onetbb )
71- target_link_directories (${exec_func} PUBLIC ${CMAKE_BINARY_DIR } /ppc_onetbb/install/lib )
72- if (NOT MSVC )
73- target_link_libraries (${exec_func} PUBLIC tbb )
74- endif ()
75-
76- target_link_directories (stb_image INTERFACE ${CMAKE_SOURCE_DIR } /3rdparty/stb )
77- target_link_libraries (${exec_func} PUBLIC stb_image )
78-
79- add_dependencies (${exec_func} ppc_googletest )
80- target_link_directories (${exec_func} PUBLIC "${CMAKE_BINARY_DIR } /ppc_googletest/install/lib" )
81- target_link_libraries (${exec_func} PUBLIC gtest gtest_main )
82- enable_testing ()
83- add_test (NAME ${exec_func} COMMAND ${exec_func} )
84-
85- # Install the executable
86- install (TARGETS ${exec_func} RUNTIME DESTINATION bin)
52+ foreach (exec_func ${list_of_exec_tests} )
53+ target_link_libraries (${exec_func} PUBLIC ${name_lib} )
54+ endforeach ()
8755endforeach ()
88-
89- # Install the library
90- install (TARGETS ${name_lib} ARCHIVE DESTINATION lib LIBRARY DESTINATION lib)
0 commit comments