import objects to CMake

classic Classic list List threaded Threaded
2 messages Options
Hex
Reply | Threaded
Open this post in threaded view
|

import objects to CMake

Hex

hello community,

Following an example on the usage of IMPORTED_OBJECTS from the book "Professional CMake"

I receive the following error:

Error evaluating generator expression:

    $<TARGET_SOURCES:myObjLib>

  Expression did not evaluate to a known generator expression


I wonder if there is a mistake in the code snippet? I was able to make it work using TARGET_OBJECTS instead of TARGET_SOURCES (CMake 3.15).

this is the original CMakeLists.txt:

add_library(myObjLib OBJECT IMPORTED)
set_target_properties(myObjLib PROPERTIES
   IMPORTED_OBJECTS /some/path/obj1.obj
                    /some/path/obj2.obj
)

add_executable(myExe $<TARGET_SOURCES:myObjLib>)



--

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
Reply | Threaded
Open this post in threaded view
|

Re: import objects to CMake

Craig Scott-3


On Tue, Jul 23, 2019 at 10:27 PM hex <[hidden email]> wrote:

hello community,

Following an example on the usage of IMPORTED_OBJECTS from the book "Professional CMake"

I'm happy to accept corrections and suggestions for the book at the following link (it's a more appropriate channel than here on this list):


 

I receive the following error:

Error evaluating generator expression:

    $<TARGET_SOURCES:myObjLib>

  Expression did not evaluate to a known generator expression


I wonder if there is a mistake in the code snippet? I was able to make it work using TARGET_OBJECTS instead of TARGET_SOURCES (CMake 3.15).

Yes it is an error, it should have been $<TARGET_OBJECTS:myObjLib>. It will be corrected in the next update. Thanks.


 

this is the original CMakeLists.txt:

add_library(myObjLib OBJECT IMPORTED)
set_target_properties(myObjLib PROPERTIES
   IMPORTED_OBJECTS /some/path/obj1.obj
                    /some/path/obj2.obj
)

add_executable(myExe $<TARGET_SOURCES:myObjLib>)


--
Craig Scott
Melbourne, Australia

Get the hand-book for every CMake user: Professional CMake: A Practical Guide

--

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