[CMake] advice for resolving errors with CMake 3.8

Michael Ellery mellery451 at gmail.com
Wed May 2 19:12:18 EDT 2018


> On May 2, 2018, at 3:55 PM, Alan W. Irwin <irwin at beluga.phys.uvic.ca> wrote:
> 
> On 2018-05-02 09:45-0700 Michael Ellery wrote:
> 
>> I generally develop on a latest cmake (provided by homebrew) and that works well for me. Unfortunately, I also need to support Visual Studio builds and it looks like the cmake that is bundled with VS is 3.8. I’m apparently using bleeding-edge features related to IMPORTED libraries, judging by these errors:
>> 
>> ||   Cannot specify include directories for imported target “some_lib”.
>> 
>> ||   add_library cannot create ALIAS target “NIH::some_lib" because target
>> ||   “some_lib" is IMPORTED.
>> 
>> ||   Cannot specify compile options for imported target “some_lib".
>> ||
>> 
>> What is the recommended way to deal with include dirs and compile settings for IMPORTED targets with pre-3.11?
> 
> Hi Michael:
> 
> Just in case nobody comes up with a simple solution for your question
> about taking the backward step (in my opinion) of making your build
> system compatible with CMake-3.8, have you tried to download and
> install CMake version 3.11 from KitWare for Windows to see if that
> works well for your VS platform?  (My guess is you would merely need
> to change the PATH so that CMake version 3.11 rather than CMake
> version 3.8 was used, but I don't have any VS experience so it might
> be more complicated than that.) Anyhow, I thought this idea was worth
> a shot since it allows you to stick with CMake-3.11 compatibility for
> your build system.
> 
> Alan

HI Alan, 

Thanks for your suggestion. I wish it were that easy, but the bundled VS CMake is pretty tightly coupled and you can’t easily replace it. I believe they also rely on one or two features they might have added or enabled in their build of cmake - so they are currently maintaining a divergent fork that hopefully will eventually get mainlined (?).

In the meantime, it looks like I just need to switch to set_target_properties for 3.8 instead of trying to use target_include_directories on an IMPORTED target. This seems to be working so far.

Thanks,
Mike



More information about the CMake mailing list