I've googled this issue for a while now but found only few references (1,2) and no solution. I'd like to enforce that find_package() will only accept static or shared libraries. I would then set this option based on BUILD_SHARED_LIBS=(ON|OFF). I.e. I'd love to have something like: if(BUILD_SHARED_LIBS) BUILD_TYPE="SHARED" else() BUILD_TYPE="STATIC" endif() find_package(XXX ${BUILD_TYPE}) find_package(YYY ${BUILD_TYPE}) find_package(ZZZ ${BUILD_TYPE}) ... It seems that this does not exist? I could also not find a good workaround. The best I can find is to use 'NAMES' and add the static or shared library names manually. This is not very suitable, because I have a project with more than 30 dependencies. The project should either build (fully) static or (fully) shared. I can not easily maintain lists of 30 static and shared library names on several platforms. Is there a solution or good workaround? All the best, Mario Emmenlauer (1) https://cmake.org/pipermail/cmake/2012-September/052059.html (2) https://cmake.org/pipermail/cmake/2010-December/041326.html -- BioDataAnalysis GmbH, Mario Emmenlauer Tel. Buero: +49-89-74677203 Balanstr. 43 mailto: memmenlauer * biodataanalysis.de D-81669 München http://www.biodataanalysis.de/ -- 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 |
Another possibility is to customize the variable CMAKE_FIND_LIBRARY_SUFFIXES.
For example, on linux: * shared only: set (CMAKE_FIND_LIBRARY_SUFFIXES ".so") * static only: set (CMAKE_FIND_LIBRARY_SUFFIXES ".a") On Windows, it is more problematic because static and "import" shared libraries have same extension: ".lib". But, if, by chance, you have different prefixes to distinguish them, you can rely on variable CMAKE_FIND_LIBRARY_PREFIXES to manage that. On 21/03/2018 10:56, "CMake on behalf of Mario Emmenlauer" <[hidden email] on behalf of [hidden email]> wrote: I've googled this issue for a while now but found only few references (1,2) and no solution. I'd like to enforce that find_package() will only accept static or shared libraries. I would then set this option based on BUILD_SHARED_LIBS=(ON|OFF). I.e. I'd love to have something like: if(BUILD_SHARED_LIBS) BUILD_TYPE="SHARED" else() BUILD_TYPE="STATIC" endif() find_package(XXX ${BUILD_TYPE}) find_package(YYY ${BUILD_TYPE}) find_package(ZZZ ${BUILD_TYPE}) ... It seems that this does not exist? I could also not find a good workaround. The best I can find is to use 'NAMES' and add the static or shared library names manually. This is not very suitable, because I have a project with more than 30 dependencies. The project should either build (fully) static or (fully) shared. I can not easily maintain lists of 30 static and shared library names on several platforms. Is there a solution or good workaround? All the best, Mario Emmenlauer (1) https://cmake.org/pipermail/cmake/2012-September/052059.html (2) https://cmake.org/pipermail/cmake/2010-December/041326.html -- BioDataAnalysis GmbH, Mario Emmenlauer Tel. Buero: +49-89-74677203 Balanstr. 43 mailto: memmenlauer * biodataanalysis.de D-81669 München http://www.biodataanalysis.de/ -- 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 |
Dear Marc, this is a pretty neat idea! Let me quickly recapitulate: the library prefixes and suffixes for multiple platforms are: | static | shared | prefix | suffix | prefix | suffix --------------------------------------------------------------------- Linux | lib | .a | lib | .so MacOSX | lib | .a | lib | .dylib MinGW | lib | .a | lib | .dll.a/.dll MSVC | - | .lib | - | .lib/.dll Is that about correct? So it should work mostly everywhere with the note- worthy exception of MSVC, where the shared import library is not easily discriminated from the static library. Is there a good solution for MSVC too? All the best, Mario On 22.03.2018 09:41, CHEVRIER, Marc wrote: > Another possibility is to customize the variable CMAKE_FIND_LIBRARY_SUFFIXES. > For example, on linux: > * shared only: set (CMAKE_FIND_LIBRARY_SUFFIXES ".so") > * static only: set (CMAKE_FIND_LIBRARY_SUFFIXES ".a") > > On Windows, it is more problematic because static and "import" shared libraries have same extension: ".lib". > But, if, by chance, you have different prefixes to distinguish them, you can rely on variable CMAKE_FIND_LIBRARY_PREFIXES to manage that. > > > On 21/03/2018 10:56, "CMake on behalf of Mario Emmenlauer" <[hidden email] on behalf of [hidden email]> wrote: > > > I've googled this issue for a while now but found only few > references (1,2) and no solution. I'd like to enforce that > find_package() will only accept static or shared libraries. > I would then set this option based on BUILD_SHARED_LIBS=(ON|OFF). > > I.e. I'd love to have something like: > if(BUILD_SHARED_LIBS) > BUILD_TYPE="SHARED" > else() > BUILD_TYPE="STATIC" > endif() > find_package(XXX ${BUILD_TYPE}) > find_package(YYY ${BUILD_TYPE}) > find_package(ZZZ ${BUILD_TYPE}) > ... > > > It seems that this does not exist? I could also not find a > good workaround. The best I can find is to use 'NAMES' and > add the static or shared library names manually. > > This is not very suitable, because I have a project with more > than 30 dependencies. The project should either build (fully) > static or (fully) shared. I can not easily maintain lists of > 30 static and shared library names on several platforms. > > Is there a solution or good workaround? > > All the best, > > Mario Emmenlauer > > > (1) https://cmake.org/pipermail/cmake/2012-September/052059.html > (2) https://cmake.org/pipermail/cmake/2010-December/041326.html > > > -- > BioDataAnalysis GmbH, Mario Emmenlauer Tel. Buero: +49-89-74677203 > Balanstr. 43 mailto: memmenlauer * biodataanalysis.de > D-81669 München http://www.biodataanalysis.de/ > -- > > 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 > > Viele Gruesse, Mario Emmenlauer -- BioDataAnalysis GmbH, Mario Emmenlauer Tel. Buero: +49-89-74677203 Balanstr. 43 mailto: memmenlauer * biodataanalysis.de D-81669 München http://www.biodataanalysis.de/ -- 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 |
Yes. Seems OK.
For Windows, if libraries are all your owns, you can manage this by relaying on a specific prefix for static libraries. A commonly adopted naming is to add prefix "lib" for static libraries. Now, if you add to rely on external libraries, I don't see any general solution. On 22/03/2018 12:15, "Mario Emmenlauer" <[hidden email]> wrote: Dear Marc, this is a pretty neat idea! Let me quickly recapitulate: the library prefixes and suffixes for multiple platforms are: | static | shared | prefix | suffix | prefix | suffix --------------------------------------------------------------------- Linux | lib | .a | lib | .so MacOSX | lib | .a | lib | .dylib MinGW | lib | .a | lib | .dll.a/.dll MSVC | - | .lib | - | .lib/.dll Is that about correct? So it should work mostly everywhere with the note- worthy exception of MSVC, where the shared import library is not easily discriminated from the static library. Is there a good solution for MSVC too? All the best, Mario On 22.03.2018 09:41, CHEVRIER, Marc wrote: > Another possibility is to customize the variable CMAKE_FIND_LIBRARY_SUFFIXES. > For example, on linux: > * shared only: set (CMAKE_FIND_LIBRARY_SUFFIXES ".so") > * static only: set (CMAKE_FIND_LIBRARY_SUFFIXES ".a") > > On Windows, it is more problematic because static and "import" shared libraries have same extension: ".lib". > But, if, by chance, you have different prefixes to distinguish them, you can rely on variable CMAKE_FIND_LIBRARY_PREFIXES to manage that. > > > On 21/03/2018 10:56, "CMake on behalf of Mario Emmenlauer" <[hidden email] on behalf of [hidden email]> wrote: > > > I've googled this issue for a while now but found only few > references (1,2) and no solution. I'd like to enforce that > find_package() will only accept static or shared libraries. > I would then set this option based on BUILD_SHARED_LIBS=(ON|OFF). > > I.e. I'd love to have something like: > if(BUILD_SHARED_LIBS) > BUILD_TYPE="SHARED" > else() > BUILD_TYPE="STATIC" > endif() > find_package(XXX ${BUILD_TYPE}) > find_package(YYY ${BUILD_TYPE}) > find_package(ZZZ ${BUILD_TYPE}) > ... > > > It seems that this does not exist? I could also not find a > good workaround. The best I can find is to use 'NAMES' and > add the static or shared library names manually. > > This is not very suitable, because I have a project with more > than 30 dependencies. The project should either build (fully) > static or (fully) shared. I can not easily maintain lists of > 30 static and shared library names on several platforms. > > Is there a solution or good workaround? > > All the best, > > Mario Emmenlauer > > > (1) https://cmake.org/pipermail/cmake/2012-September/052059.html > (2) https://cmake.org/pipermail/cmake/2010-December/041326.html > > > -- > BioDataAnalysis GmbH, Mario Emmenlauer Tel. Buero: +49-89-74677203 > Balanstr. 43 mailto: memmenlauer * biodataanalysis.de > D-81669 München http://www.biodataanalysis.de/ > -- > > 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 > > Viele Gruesse, Mario Emmenlauer -- BioDataAnalysis GmbH, Mario Emmenlauer Tel. Buero: +49-89-74677203 Balanstr. 43 mailto: memmenlauer * biodataanalysis.de D-81669 München http://www.biodataanalysis.de/ -- 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 |
In reply to this post by Mario Emmenlauer
Why not install shared libraries in one location and static libraries in another?
> On Mar 21, 2018, at 4:55 AM, Mario Emmenlauer <[hidden email]> wrote: > > > I've googled this issue for a while now but found only few > references (1,2) and no solution. I'd like to enforce that > find_package() will only accept static or shared libraries. > I would then set this option based on BUILD_SHARED_LIBS=(ON|OFF). > > I.e. I'd love to have something like: > if(BUILD_SHARED_LIBS) > BUILD_TYPE="SHARED" > else() > BUILD_TYPE="STATIC" > endif() > find_package(XXX ${BUILD_TYPE}) > find_package(YYY ${BUILD_TYPE}) > find_package(ZZZ ${BUILD_TYPE}) > ... > > > It seems that this does not exist? I could also not find a > good workaround. The best I can find is to use 'NAMES' and > add the static or shared library names manually. > > This is not very suitable, because I have a project with more > than 30 dependencies. The project should either build (fully) > static or (fully) shared. I can not easily maintain lists of > 30 static and shared library names on several platforms. > > Is there a solution or good workaround? > > All the best, > > Mario Emmenlauer > > > (1) https://cmake.org/pipermail/cmake/2012-September/052059.html > (2) https://cmake.org/pipermail/cmake/2010-December/041326.html > > > -- > BioDataAnalysis GmbH, Mario Emmenlauer Tel. Buero: +49-89-74677203 > Balanstr. 43 mailto: memmenlauer * biodataanalysis.de > D-81669 München http://www.biodataanalysis.de/ > -- > > 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 |
Our why doesn't cmake set a long needed standard here of .dll.lib and be done with this nonsense? On Thu, Mar 22, 2018, 11:58 PM P F via CMake <[hidden email]> wrote: Why not install shared libraries in one location and static libraries in another? -- 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 |
In reply to this post by CMake mailing list
Dear PF, thanks! I think this is a quite sensible approach and I will do as you suggest. I did not consider it at first because there are some packages that can install static and shared side-by-side. But I agree that your suggestion is ore pragmatic and also less error-prone. All the best, Mario On 23.03.2018 00:57, P F wrote: > Why not install shared libraries in one location and static libraries in another? > >> On Mar 21, 2018, at 4:55 AM, Mario Emmenlauer <[hidden email]> wrote: >> >> >> I've googled this issue for a while now but found only few >> references (1,2) and no solution. I'd like to enforce that >> find_package() will only accept static or shared libraries. >> I would then set this option based on BUILD_SHARED_LIBS=(ON|OFF). >> >> I.e. I'd love to have something like: >> if(BUILD_SHARED_LIBS) >> BUILD_TYPE="SHARED" >> else() >> BUILD_TYPE="STATIC" >> endif() >> find_package(XXX ${BUILD_TYPE}) >> find_package(YYY ${BUILD_TYPE}) >> find_package(ZZZ ${BUILD_TYPE}) >> ... >> >> >> It seems that this does not exist? I could also not find a >> good workaround. The best I can find is to use 'NAMES' and >> add the static or shared library names manually. >> >> This is not very suitable, because I have a project with more >> than 30 dependencies. The project should either build (fully) >> static or (fully) shared. I can not easily maintain lists of >> 30 static and shared library names on several platforms. >> >> Is there a solution or good workaround? >> >> All the best, >> >> Mario Emmenlauer >> >> >> (1) https://cmake.org/pipermail/cmake/2012-September/052059.html >> (2) https://cmake.org/pipermail/cmake/2010-December/041326.html >> >> >> -- >> BioDataAnalysis GmbH, Mario Emmenlauer Tel. Buero: +49-89-74677203 >> Balanstr. 43 mailto: memmenlauer * biodataanalysis.de >> D-81669 München http://www.biodataanalysis.de/ >> -- >> >> 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 > > Viele Gruesse, Mario Emmenlauer -- BioDataAnalysis GmbH, Mario Emmenlauer Tel. Buero: +49-89-74677203 Balanstr. 43 mailto: memmenlauer * biodataanalysis.de D-81669 München http://www.biodataanalysis.de/ -- 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 |
In reply to this post by Ray Donnelly
Two thumbs up for this! :-) On 23.03.2018 03:14, Ray Donnelly wrote: > Our why doesn't cmake set a long needed standard here of .dll.lib and be done with this nonsense? > > On Thu, Mar 22, 2018, 11:58 PM P F via CMake <[hidden email] <mailto:[hidden email]>> wrote: > > Why not install shared libraries in one location and static libraries in another? > > > On Mar 21, 2018, at 4:55 AM, Mario Emmenlauer <[hidden email] <mailto:[hidden email]>> wrote: > > > > > > I've googled this issue for a while now but found only few > > references (1,2) and no solution. I'd like to enforce that > > find_package() will only accept static or shared libraries. > > I would then set this option based on BUILD_SHARED_LIBS=(ON|OFF). > > > > I.e. I'd love to have something like: > > if(BUILD_SHARED_LIBS) > > BUILD_TYPE="SHARED" > > else() > > BUILD_TYPE="STATIC" > > endif() > > find_package(XXX ${BUILD_TYPE}) > > find_package(YYY ${BUILD_TYPE}) > > find_package(ZZZ ${BUILD_TYPE}) > > ... > > > > > > It seems that this does not exist? I could also not find a > > good workaround. The best I can find is to use 'NAMES' and > > add the static or shared library names manually. > > > > This is not very suitable, because I have a project with more > > than 30 dependencies. The project should either build (fully) > > static or (fully) shared. I can not easily maintain lists of > > 30 static and shared library names on several platforms. > > > > Is there a solution or good workaround? > > > > All the best, > > > > Mario Emmenlauer > > > > > > (1) https://cmake.org/pipermail/cmake/2012-September/052059.html > > (2) https://cmake.org/pipermail/cmake/2010-December/041326.html > > > > > > -- > > BioDataAnalysis GmbH, Mario Emmenlauer Tel. Buero: +49-89-74677203 > > Balanstr. 43 mailto: memmenlauer * biodataanalysis.de <http://biodataanalysis.de> > > D-81669 München http://www.biodataanalysis.de/ > > -- > > > > Powered by www.kitware.com <http://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 <http://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 > Viele Gruesse, Mario Emmenlauer -- BioDataAnalysis GmbH, Mario Emmenlauer Tel. Buero: +49-89-74677203 Balanstr. 43 mailto: memmenlauer * biodataanalysis.de D-81669 München http://www.biodataanalysis.de/ -- 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 |
Free forum by Nabble | Edit this page |