I did eventually find a solution where I set up an imported target with IMPORTED_LOCATION and IMPORTED_LOCATION_DEBUG properties pointing to the object files, and then linked in that target with target_link_libraries(). I admit I wasn't completely sure if adding .obj/.o files to the link lines in this way would be well supported, though it did seem to work OK in practice in the generators I tested to cover what our customers and build systems use (Visual Studio, NMake Makefiles [JOM], Unix Makefiles for the Linux build, and Ninja on Linux). -- Daniel ________________________________________ From: Robert Maynard [robert.mayn...@kitware.com] Sent: Tuesday, December 18, 2018 11:08 AM To: Daniel Schepler Cc: CMake MailingList Subject: Re: [CMake] How to link in different prebuilt objects based on configuration
As far as I know this is a limitation of the MSVC project files, and CMake errors out on that generator rather than try and build an invalid project. Have you tried do something where you have the Config and Release objects as separate targets that always exist, but selectively conditionally to them based on the Config setting? On Thu, Dec 13, 2018 at 2:16 PM Daniel Schepler <dschep...@scalable-networks.com> wrote: > > We have a build here where a large portion of our product is in source code > available to customers, but then there is a core which we only distribute as > prebuilt "private objects". However, then when we test the customer-type > build on Windows, we get an error like: > > --- > CMake Error in CMakeLists.txt: > Target "exata" has source files which vary by configuration. This is not > supported by the "Visual Studio 15 2017 Win64" generator. > > Config "Debug": > > E:/EXata_7_0/qualnet_dev_13_Dec18/kernel/obj/exata-main-windows-x64-vc14d.obj > > Config "Release": > > E:/EXata_7_0/qualnet_dev_13_Dec18/kernel/obj/exata-main-windows-x64-vc14.obj > --- > > (This object file is marked with source file property EXTERNAL_OBJECT=1.) > > Is this a limitation in Visual Studio projects, or a limitation in CMake? In > either case, what workaround could allow this build to support generating > Visual Studio projects? > -- > Daniel Schepler > -- > > 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 -- 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