3

When I use target_precompile_headers() in visual studio I will get the following structure:

+-- Precompile Header File
|  |
|  +-- cmake_pch.hxx
|  +-- cmake_pch.hxx
|  +-- cmake_pch.hxx
|  +-- cmake_pch.hxx
+-- Source Files
|  | 
|  +-- cmake_pch.cxx

Calling source_group() after this method doesn't work. How do I group these files together?

dotdolfin
  • 105
  • 7

1 Answers1

0

For example you can make:

source_group("Generated Files" FILES ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${PROJECT_NAME}.dir/cmake_pch.cxx)
foreach(config_type ${CMAKE_CONFIGURATION_TYPES})
    source_group("Generated Files" FILES ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${PROJECT_NAME}.dir/${config_type}/cmake_pch.hxx)
endforeach()

There is no cmake variable than contains the path to CMakeFiles/${PROJECT_NAME}.dir, hence the above usage rather is a hack.

The result:

Generated Files
|
+-- cmake_pch.cxx
+-- cmake_pch.hxx
+-- cmake_pch.hxx
+-- cmake_pch.hxx
+-- cmake_pch.hxx