Getting library name from library target to pass to legacy Makefile

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

Getting library name from library target to pass to legacy Makefile

Dustyn Blasig
Hi All,

I am integrating a legacy Makefile with our CMake flow, and need to pass the name of a CMake library target to the Makefile via add_custom_command(). The library uses the OUTPUT_NAME property to override the default.

add_library(foo_lib SHARED ...)
set_target_properties(foo_lib PROPERTIES OUTPUT_NAME foo) # Generates libfoo.so
add_custom_command(... COMMAND make ... FOO_LIB_LINKER_NAME=<????> ...)

I need <????> to be the value passed to -l of g++, namely -lfoo or -lfood for debug builds. I can't seem to find an expression/property that gives this shortened name. The generator expressions like TARGET_LINKER_FILE_NAME give libfoo.so.

What is the appropriate way to get just the stem of the library with the configuration-specific suffix if needed?

Thanks!

--

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: Getting library name from library target to pass to legacy Makefile

Marc CHEVRIER
You can use generator expression TARGET_FILE_BASE_NAME, available with version 3.15.
Le 22 juil. 2019 à 05:24 +0200, Dustyn Blasig <[hidden email]>, a écrit :
Hi All,

I am integrating a legacy Makefile with our CMake flow, and need to pass the name of a CMake library target to the Makefile via add_custom_command(). The library uses the OUTPUT_NAME property to override the default.

add_library(foo_lib SHARED ...)
set_target_properties(foo_lib PROPERTIES OUTPUT_NAME foo) # Generates libfoo.so
add_custom_command(... COMMAND make ... FOO_LIB_LINKER_NAME=<????> ...)

I need <????> to be the value passed to -l of g++, namely -lfoo or -lfood for debug builds. I can't seem to find an expression/property that gives this shortened name. The generator expressions like TARGET_LINKER_FILE_NAME give libfoo.so.

What is the appropriate way to get just the stem of the library with the configuration-specific suffix if needed?

Thanks!
--

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
Reply | Threaded
Open this post in threaded view
|

Re: Getting library name from library target to pass to legacy Makefile

Dustyn Blasig
Thanks, Marc. That is exactly what I need, but I'm stuck with 3.12.4 for the foreseeable future. Is there a way to get the equivalent behavior in older versions?

On Mon, Jul 22, 2019 at 1:04 AM Marc CHEVRIER <[hidden email]> wrote:
You can use generator expression TARGET_FILE_BASE_NAME, available with version 3.15.
Le 22 juil. 2019 à 05:24 +0200, Dustyn Blasig <[hidden email]>, a écrit :
Hi All,

I am integrating a legacy Makefile with our CMake flow, and need to pass the name of a CMake library target to the Makefile via add_custom_command(). The library uses the OUTPUT_NAME property to override the default.

add_library(foo_lib SHARED ...)
set_target_properties(foo_lib PROPERTIES OUTPUT_NAME foo) # Generates libfoo.so
add_custom_command(... COMMAND make ... FOO_LIB_LINKER_NAME=<????> ...)

I need <????> to be the value passed to -l of g++, namely -lfoo or -lfood for debug builds. I can't seem to find an expression/property that gives this shortened name. The generator expressions like TARGET_LINKER_FILE_NAME give libfoo.so.

What is the appropriate way to get just the stem of the library with the configuration-specific suffix if needed?

Thanks!
--

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
Reply | Threaded
Open this post in threaded view
|

Re: Getting library name from library target to pass to legacy Makefile

Marc CHEVRIER
An alternate solution is to use generator expression TARGET_LINKER_FILE_NAME because the linker is also able to use full path names rather than radical names as library input.
Le 22 juil. 2019 à 17:55 +0200, Dustyn Blasig <[hidden email]>, a écrit :
Thanks, Marc. That is exactly what I need, but I'm stuck with 3.12.4 for the foreseeable future. Is there a way to get the equivalent behavior in older versions?

On Mon, Jul 22, 2019 at 1:04 AM Marc CHEVRIER <[hidden email]> wrote:
You can use generator expression TARGET_FILE_BASE_NAME, available with version 3.15.
Le 22 juil. 2019 à 05:24 +0200, Dustyn Blasig <[hidden email]>, a écrit :
Hi All,

I am integrating a legacy Makefile with our CMake flow, and need to pass the name of a CMake library target to the Makefile via add_custom_command(). The library uses the OUTPUT_NAME property to override the default.

add_library(foo_lib SHARED ...)
set_target_properties(foo_lib PROPERTIES OUTPUT_NAME foo) # Generates libfoo.so
add_custom_command(... COMMAND make ... FOO_LIB_LINKER_NAME=<????> ...)

I need <????> to be the value passed to -l of g++, namely -lfoo or -lfood for debug builds. I can't seem to find an expression/property that gives this shortened name. The generator expressions like TARGET_LINKER_FILE_NAME give libfoo.so.

What is the appropriate way to get just the stem of the library with the configuration-specific suffix if needed?

Thanks!
--

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