set_target_properties ( INTERFACE_INCLUDE_DIRECTORIES ...)

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

set_target_properties ( INTERFACE_INCLUDE_DIRECTORIES ...)

Theodore Hall
Greetings,

  set_target_properties(target PROPERTIES
    IMPORTED_LOCATION location
    IMPORTED_IMPLIB implib
    INTERFACE_INCLUDE_DIRECTORIES directory+
  )

Is there a way to assign more than one directory to INTERFACE_INCLUDE_DIRECTORIES ?  The property name is plural, but every attempt I've made to specify more than one directory has failed.  CMake complains that either: I've passed the wrong number of arguments; or concatenates all of them into one path which of course doesn't exist.

I've found a work-around using

  target_include_directories (target
    INTERFACE directory1
    INTERFACE directory2
  )

It just seems odd that a property with a plural name accepts only a singular value.  I feel like I'm missing something.  I've tried wrapping multiple directories in various kinds of brackets and quotes and separating them with ; or , instead of whitespace.  (This is Windows, so : isn't a path separator; the system PATH variable uses ; as the separator.)

Thanks for any enlightenment.

--

Ted Hall


--

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: set_target_properties ( INTERFACE_INCLUDE_DIRECTORIES ...)

Craig Scott-3


On Fri, Sep 13, 2019 at 8:24 AM Theodore Hall <[hidden email]> wrote:
Greetings,

  set_target_properties(target PROPERTIES
    IMPORTED_LOCATION location
    IMPORTED_IMPLIB implib
    INTERFACE_INCLUDE_DIRECTORIES directory+
  )

Is there a way to assign more than one directory to INTERFACE_INCLUDE_DIRECTORIES ?  The property name is plural, but every attempt I've made to specify more than one directory has failed.  CMake complains that either: I've passed the wrong number of arguments; or concatenates all of them into one path which of course doesn't exist.

I've found a work-around using

  target_include_directories (target
    INTERFACE directory1
    INTERFACE directory2
  )

It just seems odd that a property with a plural name accepts only a singular value.  I feel like I'm missing something.  I've tried wrapping multiple directories in various kinds of brackets and quotes and separating them with ; or , instead of whitespace.  (This is Windows, so : isn't a path separator; the system PATH variable uses ; as the separator.)


OPTION A: Put quotes around a semi-colon separated string if using set_target_properties():

set_target_properties(target PROPERTIES 
    IMPORTED_LOCATION location
    IMPORTED_IMPLIB implib
    INTERFACE_INCLUDE_DIRECTORIES "directory1;directory2"
  )

OPTION B: List multiple directories after just one INTERFACE keyword if using target_include_directories():

  target_include_directories (target
    INTERFACE directory1 directory2
  )

Either option should work for all platforms, but note that option A will overwrite any previous contents of INTERFACE_INCLUDED_DIRECTORIES whereas option B will append to any previous contents. For that reason, I'd generally recommend option B. 

--
Craig Scott
Melbourne, Australia

Get the hand-book for every CMake user: Professional CMake: A Practical Guide
Consulting services (CMake, C++, build/release processes): https://crascit.com/services

--

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: set_target_properties ( INTERFACE_INCLUDE_DIRECTORIES ...)

Theodore Hall
On Thu, Sep 12, 2019 at 6:31 PM Craig Scott <[hidden email]> wrote:

OPTION A: Put quotes around a semi-colon separated string if using set_target_properties():

Many thanks.  I had tried quotes, and I had tried a semi-colon, and I thought that I had tried them together, but evidently I missed that permutation.

I'm actually sticking with OPTION B anyway -- it seems cleaner.  But I was mystified looking for OPTION A.

-- 

Ted Hall


--

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: set_target_properties ( INTERFACE_INCLUDE_DIRECTORIES ...)

Petr Kmoch
For completeness, there is also OPTION C:

  set_property(TARGET target PROPERTY INTERFACE_INCLUDE_DIRECTORIES directory1 directory2)

set_target_properties() is a shorthand for setting several properties at once, so it assumes its arguments are prop value prop value. If you need finer control, such as appending or easy way to pass multiple values, use the full power of set_property().

Petr

On Fri, 13 Sep 2019 at 06:24, Theodore Hall <[hidden email]> wrote:
On Thu, Sep 12, 2019 at 6:31 PM Craig Scott <[hidden email]> wrote:

OPTION A: Put quotes around a semi-colon separated string if using set_target_properties():

Many thanks.  I had tried quotes, and I had tried a semi-colon, and I thought that I had tried them together, but evidently I missed that permutation.

I'm actually sticking with OPTION B anyway -- it seems cleaner.  But I was mystified looking for OPTION A.

-- 

Ted Hall

--

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