[CMake] AUTOUIC generated headers not found by lib that uses lib with headers

Robert Maynard robert.maynard at kitware.com
Mon Jul 30 14:39:02 EDT 2018


You need to defer the evaluation of the include directory to generate
time, which will know what exactly build type is needed. This is done
by using `$<CONFIG>` instead of `${CMAKE_BUILD_TYPE`.

Something like the following should work:

set(directory "${CMAKE_CURRENT_BINARY_DIR}/ComponentsLib_autogen/include_$<CONFIG>")
target_include_directories(ComponentsLib INTERFACE ${directory})
On Mon, Jul 30, 2018 at 1:48 PM Jim Carroll <jim at maplesong.com> wrote:
>
> I have a project that I'm updating from Cmake 3.5 to 3.12.
>
> In the project, I have UI libraries that use other libraries, both of which use Qt 5.6.
> The lowest-level library uses AUTOUIC and I see the headers are generated in the new lib_autogen/include_BUILD_CONFIG directory.
>
> When my higher level library tries to use the lower level library, I get the error that it can't find the auto-generated headers. It only seems to have trouble finding about six of two dozen ui_***.h files.
>
> How can I get my lower level libraries to include the generated header files so they're available to the higher level library that's using it?
>
> I'm using
> cmake 3.12
> Qt 5.6
> Visual Studio 2015
>
> I tried creating a work-around where in the CMakeLists.txt of my lowest level directory I add
>
> # CMake 10+ has a bug where automoc header files aren't found
> SET(COMPONENTS_UIC_HDRS_DIR "${CMAKE_CURRENT_BINARY_DIR}/ComponentsLib_autogen/include_${CMAKE_BUILD_TYPE}")
> message("** COMPONENTS AUTOUIC autogen dir: ${COMPONENTS_UIC_HDRS_DIR}")
> target_include_directories(ComponentsLib INTERFACE ${COMPONENTS_UIC_HDRS_DIR})
>
> but of course the CMAKE_BUILD_TYPE isn't available to CMake at this time. I'd have to move the headers into a place common to the various (Debug/Release) configurations or something.
>
> Thanks!
> -Jim
>
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> https://cmake.org/mailman/listinfo/cmake


More information about the CMake mailing list