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 <hendrik.greving....@gmail.com> wrote: > > 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? > > On Mon, Nov 5, 2018 at 9:57 AM Robert Maynard <robert.mayn...@kitware.com> > wrote: >> >> 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 >> <hendrik.greving....@gmail.com> wrote: >> > >> > 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 <robert.mayn...@kitware.com> >> > wrote: >> >> >> >> 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 >> >> <hendrik.greving....@gmail.com> wrote: >> >> > >> >> > 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 >> >> > >> >> > 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