automoc: Too long path issue on Windows platform using cmake 3.8.1
I upgraded the cmake version we used in our Windows build environment from 3.4.2 to 3.8.1. We need this upgrade (or at least the upgrade to cmake 3.7.2) because we aim to update Visual Studio to 2017 version, and need for that to have the corresponding CMake generator. In Our build environment CMAKE_AUTOMOC is ON As a result of the cmake version upgrade, I started to have too long path issue, on Windows platform (Windows 7/Windows server 2008 , Visual Studio 2013), with c++ source file generated by moc. This is a result of the new location for auto-generated files(see AUTOMOC documentation https://cmake.org/cmake/help/v3.8/prop_tgt/AUTOMOC.html). They use to be located in the <CMAKE_CURRENT_BINARY_DIR> and are, with the 3.8 release located in <CMAKE_CURRENT_BINARY_DIR>/_autogen/include directory (two more directory levels) This is hard coded in CMake C++ source code with no way for customization. So I only have two solutions:
- Re-organize our source code directory tree, trying to shorten directory names, rename the targets using shorter names
- Modify the CMake source code and rebuild CMake 3.8.1 on both Linux and Windows platforms The first solution is too heavy and we don't have material time to plan such a huge change. So I quickly patched two C++ cmake source code files to relocate the auto-generated moc files in <CMAKE_BINARY_DIR>/autogen/<target_name>_autogen directory and rebuild cmake 3.8.1 on both Linux and Windows platformsPatchedCmakeFiles.zip. This is a really annoying problem and it would be very helpful to have an external way to customize the location of the auto-generated file (at least the root directory where to create the <target_name>_autogen directory) using a CMAKE macro for example Hope this will be integrated quickly. Thanks Dominique