gpt-3.5-turbo-0301· openai
Suzhen/CodeChat
how can i groupsourcesby_directory() using cmake. In your answer, remember to put all…
- User
how can i group_sources_by_directory() using cmake. In your answer, remember to put all cmake script code inside
c++scope to make it markdown style. - Assistantc++
# Define a function to group sources by directory function(group_sources_by_directory sources_list) set(source_files "") foreach(source_file IN LISTS ${sources_list}) get_filename_component(source_path "${source_file}" PATH) list(APPEND source_files "${source_path}") endforeach() list(REMOVE_DUPLICATES source_files) foreach(source_dir IN LISTS source_files) file(GLOB source_group "${source_dir}/*.cpp" "${source_dir}/*.h") source_group("${source_dir}" FILES ${source_group}) endforeach() endfunction() # Call the function by passing the list of source files group_sources_by_directory(sources_list)