[CMake] race condition with target_objects
Juan E. Sanchez
juan.e.sanchez at gmail.com
Tue Jun 26 15:20:13 EDT 2018
Hello Brad,
Thanks for finding the issue. I had simply replaced the shared library
I was using with the name of the TARGET_OBJECTS generator.
The shared objects are great. It helps me bypass Apple security issues
when a system interpreter loads a shared library, which loads another
shared library.
Regards,
Juan
On 6/26/18 1:34 PM, Brad King wrote:
> On 06/26/2018 01:32 PM, Juan E. Sanchez wrote:
>> The likely problem is that the symdiff_objects and the symdiff_tcl are
>> in side-by-side directories. They are both added using ADD_SUBDIRECTORY
>> one level up. If I put symdiff_python before symdiff_tcl, then that
>> target will fail. Please fix your Makefile generator.
>
> Target dependencies are agnostic to the directories. The ordering at
> most matters for serial builds of independent targets.
>
> While trying to reproduce this in a simple example I found the problem:
>
> ```
> TARGET_LINK_LIBRARIES (symdiff_tcl $<TARGET_OBJECTS:symdiff_objects> ${TCL_ARCHIVE})
> ```
>
> That is not the way to reference an object library.
>
> The documentation:
>
> https://cmake.org/cmake/help/v3.12/manual/cmake-buildsystem.7.html#object-libraries
>
> shows that `$<TARGET_OBJECTS:...>` belongs in the list of *sources*,
> not linked libraries. You should be using:
>
> ```
> add_library(symdiff_tcl SHARED ... $<TARGET_OBJECTS:symdiff_objects>)
> ```
>
> -Brad
>
More information about the CMake
mailing list