Discussion:
[CMake] Default library name?
Hendrik Greving
2018-11-05 16:48:04 UTC
Permalink
Hi, is there a way to get the default library or executable name at
configure time (except obsolete LOCATION property)? i.e.
lib${target_name}.so in Linux, where target_name is NAME target property?
Thanks in advance.
Robert Maynard
2018-11-05 17:05:58 UTC
Permalink
At configure time you query OUTPUT_NAME target property
(https://cmake.org/cmake/help/v3.11/prop_tgt/OUTPUT_NAME.html) and if
not set you use NAME (
https://cmake.org/cmake/help/v3.11/prop_tgt/NAME.html )
On Mon, Nov 5, 2018 at 11:48 AM Hendrik Greving
Hi, is there a way to get the default library or executable name at configure time (except obsolete LOCATION property)? i.e. lib${target_name}.so in Linux, where target_name is NAME target property? Thanks in advance.
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
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
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
Hendrik Greving
2018-11-05 17:41:58 UTC
Permalink
I think OUTPUT_NAME is not set by default. I am getting var-NOTFOUND
Same for RUNTIME_OUTPUT_NAME, LIBRARY_OUTPUT_NAME, PREFIX and SUFFIX
Post by Robert Maynard
At configure time you query OUTPUT_NAME target property
(https://cmake.org/cmake/help/v3.11/prop_tgt/OUTPUT_NAME.html) and if
not set you use NAME (
https://cmake.org/cmake/help/v3.11/prop_tgt/NAME.html )
On Mon, Nov 5, 2018 at 11:48 AM Hendrik Greving
Post by Hendrik Greving
Hi, is there a way to get the default library or executable name at
configure time (except obsolete LOCATION property)? i.e.
lib${target_name}.so in Linux, where target_name is NAME target property?
Thanks in advance.
Post by Hendrik Greving
--
Powered by www.kitware.com
http://www.cmake.org/Wiki/CMake_FAQ
Post by Hendrik Greving
Kitware offers various services to support the CMake community. For more
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
Post by Hendrik Greving
https://cmake.org/mailman/listinfo/cmake
Robert Maynard
2018-11-05 17:55:54 UTC
Permalink
That is correct behavior. OUTPUT_NAME is a customization point to
allow projects to change the name, so if it isn't set CMake will use
the NAME property.
On Mon, Nov 5, 2018 at 12:42 PM Hendrik Greving
Post by Hendrik Greving
I think OUTPUT_NAME is not set by default. I am getting var-NOTFOUND
Same for RUNTIME_OUTPUT_NAME, LIBRARY_OUTPUT_NAME, PREFIX and SUFFIX
Post by Robert Maynard
At configure time you query OUTPUT_NAME target property
(https://cmake.org/cmake/help/v3.11/prop_tgt/OUTPUT_NAME.html) and if
not set you use NAME (
https://cmake.org/cmake/help/v3.11/prop_tgt/NAME.html )
On Mon, Nov 5, 2018 at 11:48 AM Hendrik Greving
Hi, is there a way to get the default library or executable name at configure time (except obsolete LOCATION property)? i.e. lib${target_name}.so in Linux, where target_name is NAME target property? Thanks in advance.
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
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
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
Hendrik Greving
2018-11-05 18:04:15 UTC
Permalink
The name property doesn't return the library name for libraries, i.e. on
Linux, no lib prefix and .so suffix. Also the PREFIX and SUFFIX (see above)
don't appear to be set. Is it possible to retrieve the default library name
on a given platform?
Post by Robert Maynard
That is correct behavior. OUTPUT_NAME is a customization point to
allow projects to change the name, so if it isn't set CMake will use
the NAME property.
On Mon, Nov 5, 2018 at 12:42 PM Hendrik Greving
Post by Hendrik Greving
I think OUTPUT_NAME is not set by default. I am getting var-NOTFOUND
Same for RUNTIME_OUTPUT_NAME, LIBRARY_OUTPUT_NAME, PREFIX and SUFFIX
On Mon, Nov 5, 2018 at 9:26 AM Robert Maynard <
Post by Robert Maynard
At configure time you query OUTPUT_NAME target property
(https://cmake.org/cmake/help/v3.11/prop_tgt/OUTPUT_NAME.html) and if
not set you use NAME (
https://cmake.org/cmake/help/v3.11/prop_tgt/NAME.html )
On Mon, Nov 5, 2018 at 11:48 AM Hendrik Greving
Post by Hendrik Greving
Hi, is there a way to get the default library or executable name at
configure time (except obsolete LOCATION property)? i.e.
lib${target_name}.so in Linux, where target_name is NAME target property?
Thanks in advance.
Post by Hendrik Greving
Post by Robert Maynard
Post by Hendrik Greving
--
Powered by www.kitware.com
http://www.cmake.org/Wiki/CMake_FAQ
Post by Hendrik Greving
Post by Robert Maynard
Post by Hendrik Greving
Kitware offers various services to support the CMake community. For
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
Post by Hendrik Greving
Post by Robert Maynard
Post by Hendrik Greving
https://cmake.org/mailman/listinfo/cmake
Robert Maynard
2018-11-05 18:20:32 UTC
Permalink
Yes, you can do that. I don't know if there is an easier way than the
following:

function(get_full_name target full_name)
get_target_property(name ${target} NAME)
get_target_property(suffix ${target} SUFFIX)
get_target_property(prefix ${target} PREFIX)
get_target_property(type ${target} TYPE)

if(NOT prefix)
set(prefix ${CMAKE_${type}_PREFIX})
endif()

if(NOT suffix)
set(suffix ${CMAKE_${type}_SUFFIX})
endif()

set(${full_name} "${prefix}${name}${suffix}" PARENT_SCOPE)
endfunction()

You will need to modify it if you want to support custom per config
names. Unless you really needs this information at configuration you
should use the $<TARGET_FILE_NAME:tgt> generator expression as it will
always be correct.
On Mon, Nov 5, 2018 at 1:04 PM Hendrik Greving
The name property doesn't return the library name for libraries, i.e. on Linux, no lib prefix and .so suffix. Also the PREFIX and SUFFIX (see above) don't appear to be set. Is it possible to retrieve the default library name on a given platform?
Post by Robert Maynard
That is correct behavior. OUTPUT_NAME is a customization point to
allow projects to change the name, so if it isn't set CMake will use
the NAME property.
On Mon, Nov 5, 2018 at 12:42 PM Hendrik Greving
Post by Hendrik Greving
I think OUTPUT_NAME is not set by default. I am getting var-NOTFOUND
Same for RUNTIME_OUTPUT_NAME, LIBRARY_OUTPUT_NAME, PREFIX and SUFFIX
Post by Robert Maynard
At configure time you query OUTPUT_NAME target property
(https://cmake.org/cmake/help/v3.11/prop_tgt/OUTPUT_NAME.html) and if
not set you use NAME (
https://cmake.org/cmake/help/v3.11/prop_tgt/NAME.html )
On Mon, Nov 5, 2018 at 11:48 AM Hendrik Greving
Hi, is there a way to get the default library or executable name at configure time (except obsolete LOCATION property)? i.e. lib${target_name}.so in Linux, where target_name is NAME target property? Thanks in advance.
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
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
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
Hendrik Greving
2018-11-05 18:43:17 UTC
Permalink
I see. We may be able to work with this. Thanks a lot!
generator expressions don't work with LINK_FLAGS (though I heard they will
be supported in LINK_OPTIONS in 3.13, which would require us to migrate.
But even then, generator expressions don't support and logic around this
like file(GNERATE ..) or string(REPLACE ..) that our (cmake-) files use
frequently. i.e. we are changing paths to upload on an Android target.
Another big issue is that we are using the target name for add_test
commands, i.e. in order to compute some library names based on the target
name as part of the test command. I can't use file(GENERATE to derive the
target name and put the add_test part into a .cmake script because add_test
is not scriptable.
Thanks.
Post by Robert Maynard
Yes, you can do that. I don't know if there is an easier way than the
function(get_full_name target full_name)
get_target_property(name ${target} NAME)
get_target_property(suffix ${target} SUFFIX)
get_target_property(prefix ${target} PREFIX)
get_target_property(type ${target} TYPE)
if(NOT prefix)
set(prefix ${CMAKE_${type}_PREFIX})
endif()
if(NOT suffix)
set(suffix ${CMAKE_${type}_SUFFIX})
endif()
set(${full_name} "${prefix}${name}${suffix}" PARENT_SCOPE)
endfunction()
You will need to modify it if you want to support custom per config
names. Unless you really needs this information at configuration you
should use the $<TARGET_FILE_NAME:tgt> generator expression as it will
always be correct.
On Mon, Nov 5, 2018 at 1:04 PM Hendrik Greving
Post by Hendrik Greving
The name property doesn't return the library name for libraries, i.e. on
Linux, no lib prefix and .so suffix. Also the PREFIX and SUFFIX (see above)
don't appear to be set. Is it possible to retrieve the default library name
on a given platform?
Post by Hendrik Greving
On Mon, Nov 5, 2018 at 9:57 AM Robert Maynard <
Post by Robert Maynard
That is correct behavior. OUTPUT_NAME is a customization point to
allow projects to change the name, so if it isn't set CMake will use
the NAME property.
On Mon, Nov 5, 2018 at 12:42 PM Hendrik Greving
Post by Hendrik Greving
I think OUTPUT_NAME is not set by default. I am getting var-NOTFOUND
Same for RUNTIME_OUTPUT_NAME, LIBRARY_OUTPUT_NAME, PREFIX and SUFFIX
On Mon, Nov 5, 2018 at 9:26 AM Robert Maynard <
Post by Robert Maynard
At configure time you query OUTPUT_NAME target property
(https://cmake.org/cmake/help/v3.11/prop_tgt/OUTPUT_NAME.html) and
if
Post by Hendrik Greving
Post by Robert Maynard
Post by Hendrik Greving
Post by Robert Maynard
not set you use NAME (
https://cmake.org/cmake/help/v3.11/prop_tgt/NAME.html )
On Mon, Nov 5, 2018 at 11:48 AM Hendrik Greving
Post by Hendrik Greving
Hi, is there a way to get the default library or executable name
at configure time (except obsolete LOCATION property)? i.e.
lib${target_name}.so in Linux, where target_name is NAME target property?
Thanks in advance.
Post by Hendrik Greving
Post by Robert Maynard
Post by Hendrik Greving
Post by Robert Maynard
Post by Hendrik Greving
--
Powered by www.kitware.com
http://www.cmake.org/Wiki/CMake_FAQ
Post by Hendrik Greving
Post by Robert Maynard
Post by Hendrik Greving
Post by Robert Maynard
Post by Hendrik Greving
Kitware offers various services to support the CMake community.
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
Post by Hendrik Greving
Post by Robert Maynard
Post by Hendrik Greving
Post by Robert Maynard
Post by Hendrik Greving
https://cmake.org/mailman/listinfo/cmake
Robert Maynard
2018-11-05 19:11:43 UTC
Permalink
The add_test command support generator expressions as part of the
COMMAND component (
https://cmake.org/cmake/help/v3.11/command/add_test.html). So you
could pass the name of the target as command line parameter.
On Mon, Nov 5, 2018 at 1:43 PM Hendrik Greving
Post by Hendrik Greving
I see. We may be able to work with this. Thanks a lot!
generator expressions don't work with LINK_FLAGS (though I heard they will be supported in LINK_OPTIONS in 3.13, which would require us to migrate. But even then, generator expressions don't support and logic around this like file(GNERATE ..) or string(REPLACE ..) that our (cmake-) files use frequently. i.e. we are changing paths to upload on an Android target. Another big issue is that we are using the target name for add_test commands, i.e. in order to compute some library names based on the target name as part of the test command. I can't use file(GENERATE to derive the target name and put the add_test part into a .cmake script because add_test is not scriptable.
Thanks.
Post by Robert Maynard
Yes, you can do that. I don't know if there is an easier way than the
function(get_full_name target full_name)
get_target_property(name ${target} NAME)
get_target_property(suffix ${target} SUFFIX)
get_target_property(prefix ${target} PREFIX)
get_target_property(type ${target} TYPE)
if(NOT prefix)
set(prefix ${CMAKE_${type}_PREFIX})
endif()
if(NOT suffix)
set(suffix ${CMAKE_${type}_SUFFIX})
endif()
set(${full_name} "${prefix}${name}${suffix}" PARENT_SCOPE)
endfunction()
You will need to modify it if you want to support custom per config
names. Unless you really needs this information at configuration you
should use the $<TARGET_FILE_NAME:tgt> generator expression as it will
always be correct.
On Mon, Nov 5, 2018 at 1:04 PM Hendrik Greving
The name property doesn't return the library name for libraries, i.e. on Linux, no lib prefix and .so suffix. Also the PREFIX and SUFFIX (see above) don't appear to be set. Is it possible to retrieve the default library name on a given platform?
Post by Robert Maynard
That is correct behavior. OUTPUT_NAME is a customization point to
allow projects to change the name, so if it isn't set CMake will use
the NAME property.
On Mon, Nov 5, 2018 at 12:42 PM Hendrik Greving
Post by Hendrik Greving
I think OUTPUT_NAME is not set by default. I am getting var-NOTFOUND
Same for RUNTIME_OUTPUT_NAME, LIBRARY_OUTPUT_NAME, PREFIX and SUFFIX
Post by Robert Maynard
At configure time you query OUTPUT_NAME target property
(https://cmake.org/cmake/help/v3.11/prop_tgt/OUTPUT_NAME.html) and if
not set you use NAME (
https://cmake.org/cmake/help/v3.11/prop_tgt/NAME.html )
On Mon, Nov 5, 2018 at 11:48 AM Hendrik Greving
Hi, is there a way to get the default library or executable name at configure time (except obsolete LOCATION property)? i.e. lib${target_name}.so in Linux, where target_name is NAME target property? Thanks in advance.
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
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
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
Hendrik Greving
2018-11-05 19:18:54 UTC
Permalink
Post by Robert Maynard
So you could pass the name of the target as command line parameter.
We do all sorts of string operations on it. This wouldn't work with the
generator expression.
Post by Robert Maynard
The add_test command support generator expressions as part of the
COMMAND component (
https://cmake.org/cmake/help/v3.11/command/add_test.html). So you
could pass the name of the target as command line parameter.
On Mon, Nov 5, 2018 at 1:43 PM Hendrik Greving
I see. We may be able to work with this. Thanks a lot!
generator expressions don't work with LINK_FLAGS (though I heard they
will be supported in LINK_OPTIONS in 3.13, which would require us to
migrate. But even then, generator expressions don't support and logic
around this like file(GNERATE ..) or string(REPLACE ..) that our (cmake-)
files use frequently. i.e. we are changing paths to upload on an Android
target. Another big issue is that we are using the target name for add_test
commands, i.e. in order to compute some library names based on the target
name as part of the test command. I can't use file(GENERATE to derive the
target name and put the add_test part into a .cmake script because add_test
is not scriptable.
Thanks.
On Mon, Nov 5, 2018 at 10:21 AM Robert Maynard <
Post by Robert Maynard
Yes, you can do that. I don't know if there is an easier way than the
function(get_full_name target full_name)
get_target_property(name ${target} NAME)
get_target_property(suffix ${target} SUFFIX)
get_target_property(prefix ${target} PREFIX)
get_target_property(type ${target} TYPE)
if(NOT prefix)
set(prefix ${CMAKE_${type}_PREFIX})
endif()
if(NOT suffix)
set(suffix ${CMAKE_${type}_SUFFIX})
endif()
set(${full_name} "${prefix}${name}${suffix}" PARENT_SCOPE)
endfunction()
You will need to modify it if you want to support custom per config
names. Unless you really needs this information at configuration you
should use the $<TARGET_FILE_NAME:tgt> generator expression as it will
always be correct.
On Mon, Nov 5, 2018 at 1:04 PM Hendrik Greving
Post by Hendrik Greving
The name property doesn't return the library name for libraries, i.e.
on Linux, no lib prefix and .so suffix. Also the PREFIX and SUFFIX (see
above) don't appear to be set. Is it possible to retrieve the default
library name on a given platform?
Post by Robert Maynard
Post by Hendrik Greving
On Mon, Nov 5, 2018 at 9:57 AM Robert Maynard <
Post by Robert Maynard
That is correct behavior. OUTPUT_NAME is a customization point to
allow projects to change the name, so if it isn't set CMake will use
the NAME property.
On Mon, Nov 5, 2018 at 12:42 PM Hendrik Greving
Post by Hendrik Greving
I think OUTPUT_NAME is not set by default. I am getting
var-NOTFOUND
Post by Robert Maynard
Post by Hendrik Greving
Post by Robert Maynard
Post by Hendrik Greving
Same for RUNTIME_OUTPUT_NAME, LIBRARY_OUTPUT_NAME, PREFIX and
SUFFIX
Post by Robert Maynard
Post by Hendrik Greving
Post by Robert Maynard
Post by Hendrik Greving
On Mon, Nov 5, 2018 at 9:26 AM Robert Maynard <
Post by Robert Maynard
At configure time you query OUTPUT_NAME target property
(https://cmake.org/cmake/help/v3.11/prop_tgt/OUTPUT_NAME.html)
and if
Post by Robert Maynard
Post by Hendrik Greving
Post by Robert Maynard
Post by Hendrik Greving
Post by Robert Maynard
not set you use NAME (
https://cmake.org/cmake/help/v3.11/prop_tgt/NAME.html )
On Mon, Nov 5, 2018 at 11:48 AM Hendrik Greving
Post by Hendrik Greving
Hi, is there a way to get the default library or executable
name at configure time (except obsolete LOCATION property)? i.e.
lib${target_name}.so in Linux, where target_name is NAME target property?
Thanks in advance.
Post by Robert Maynard
Post by Hendrik Greving
Post by Robert Maynard
Post by Hendrik Greving
Post by Robert Maynard
Post by Hendrik Greving
--
Powered by www.kitware.com
http://www.cmake.org/Wiki/CMake_FAQ
Post by Robert Maynard
Post by Hendrik Greving
Post by Robert Maynard
Post by Hendrik Greving
Post by Robert Maynard
Post by Hendrik Greving
Kitware offers various services to support the CMake community.
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
http://cmake.org/cmake/help/training.html
Post by Robert Maynard
Post by Hendrik Greving
Post by Robert Maynard
Post by Hendrik Greving
Post by Robert Maynard
Post by Hendrik Greving
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Post by Robert Maynard
Post by Hendrik Greving
Post by Robert Maynard
Post by Hendrik Greving
Post by Robert Maynard
Post by Hendrik Greving
https://cmake.org/mailman/listinfo/cmake
Alexander Neundorf
2018-11-05 21:03:13 UTC
Permalink
Post by Robert Maynard
Yes, you can do that. I don't know if there is an easier way than the
you could have a look at the following variables:
CMAKE_STATIC_LIBRARY_PREFIX
CMAKE_STATIC_LIBRARY_SUFFIX
CMAKE_SHARED_LIBRARY_PREFIX
CMAKE_SHARED_LIBRARY_SUFFIX
CMAKE_EXECUTABLE_SUFFIX

Alex
--
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
Loading...