CMake - CMake Digest, Vol 160, Issue 67

Send CMake mailing list submissions to cmake@cmake.org To subscribe or unsubscribe via the World Wide Web, visit https://cmake.org or, via email, send a message with subject or body 'help' to cmake-request@cmake.org You can reach the person managing the list at cmake-owner@cmake.org When replying, please edit your Subject line so it is more specific than "Re: Contents of CMake digest..." Today's Topics: 1. Re: Interface Libraries allow include directories but not link directories.. Why? (Jean-Micha?l Celerier) 2. Re: CMake, Mingw-w64 32 bit exception handling. (Arne Kjetil Andersen) ---------------------------------------------------------------------- Message: 1 Date: Thu, 24 Aug 2017 09:46:17 +0200 From: Jean-Micha?l Celerier To: Brian Davis Cc: cmake Mailing List Subject: Re: [CMake] Interface Libraries allow include directories but not link directories.. Why? Message-ID: Content-Type: text/plain; charset="utf-8" > Ok got it sorry to hear that certainly because, as soon as I hear > something that would be useful somehow I end up needing it the next day. > So sorry for us both. > > From what your are saying (and I will take your word for it) the CMake has > a another problem in not implementing "inherited build properties" > correctly. That is of course if that is what CMake is after with > add_library( targ INTERFACE) in the first place. > > I think that there is just no mechanism for "inherited build properties". >From the docs ( https://cmake.org), INTERFACE targets seems to be meant for header-only libraries. The "inheritance" mechanism in CMake is mainly setting variables in a given folder, but this is imho not flexible enough, and leads to problems when you want to use your library as a subfolder of another since you don't have an easy way to overwrite "child" variables from a parent scope unless the child scope carefully did set(CMAKE_CXX_FLAGS "-my-flags ${CMAKE_CXX_FLAGS}") every time. > Thanks for the heads up on yet more CMake does not do correctly. > > I am now climbing upon my "inherited build properties" soap box. It's > kinda slippery up here. > > On Wed, Aug 23, 2017 at 4:57 PM, Jean-Micha?l Celerier < > jeanmichael.celerier@gmail.com> wrote: > >> > Does that work for your needs? >> >> Sadly, no (but thanks!). While this is enough for the arguably common use >> case of include directories, compile flags, etc... there are plenty of >> things that won't work with this approach. >> >> e.g. none of this works for instance: >> >> project(foo) >> >> add_library(blah INTERFACE) >> set_property(TARGET blah PROPERTY SUFFIX ".mxe") >> set_property(TARGET blah PROPERTY CXX_STANDARD 14) >> set_property(TARGET blah PROPERTY INSTALL_RPATH "@loader_path/whatever") >> >> >> >> >> ------- >> Jean-Micha?l Celerier >> https://cmake.org >> >> On Wed, Aug 23, 2017 at 11:23 PM, Brian Davis wrote: >> >>> So there is some odd replies in the cmake mailing list possibly responses to wrong message, but this looked like a response to mine even if the initial reply to bit is not right from Nicholas. Anywho here goes: >>> >>> @Jean-Micha?l Celerier >>> >>> -- snip -- >>> >* - Says that custom functions such as add_{project}_library shouldn't be >>> *used and function definitions should be used as little as possible. Except >>> this just leads to extremely verbose CMakeLists where repeated properties >>> are defined again and again and again. >>> -- snip -- >>> >>> Yes add_project_library were my own and in the process of being deprecated. These were geared directly at two problems in cmake. >>> >>> 1) They were used to get CMake to support the concept of "inherited build properties". >>> >>> 2) As you stated and is still a problem the verbosity of CMake. Where IMO much could be collaped into one call >>> >>> >>> -- snip -- >>> I also never understood how to handle this. >>> -- snip -- >>> >>> I am afraid I don't ultimately have the answer either... I have do some ideas on possibly best course of action. >>> >>> >>> -- snip -- >>> I have a project where I want to define, say, -fsanitize=address, -DFOO_BAR >>> and the SUFFIX property on a specific set of 25 targets amongst ~100 >>> targets. What am I to do ? >>> >>> * set(CMAKE_CXX_FLAGS "-fsanitize=address") is "not modern CMake" (and also >>> would be harder to set / unset on specific targets). >>> * calling target_compile_options(...) 25 times ... well I mean, everyone >>> knows it's bad to duplicate code. Especially if the change is meant to be >>> only when a specific option() is enabled, or for debugging purposes >>> * creating a function that would set the correct flags, etc and then call >>> this function for each target is apparently "not modern CMake" either. >>> * creating and linking to "dummy" INTERFACE targets with the flags and >>> properties I want have an awful lot of limitations >>> >>> So what is the right course of actions here ? >>> -- snip -- >>> >>> I have started using add_library( targ INTERFACE ) to imperilment inherited build properties. Yes the naming convention and use/reuse/misuse of add_library is horrid (library) >>> >>> I just posted this which may help: >>> >>> https://cmake.org >>> >>> -- snip -- >>> Ideally I'd like to add "groups" to targets; e.g. "target Foo is a plugin >>> for $software", "target Bar is an integration test" and set per-group >>> options, flags, properties, etc. Like >>> >>> add_group(PluginGroup) >>> target_compile_definitions(PluginGroup -DBLAH) >>> set_property(GROUP PluginGroup PROPERTIES /* whatever in >>> cmake-properties*/) >>> set_group(myTarget PluginGroup) // applies everything to the target >>> -- snip -- >>> >>> I won't have all the syntax for what your trying but possibly try: >>> >>> add_library( PluginGroupInterface INTERFACE) >>> target_compile_definitions(PluginGroupInterface -DBLAH) >>> set_property(GROUP PluginGroup PROPERTIES /* whatever in >>> cmake-properties*/) >>> >>> I add interface, Interface, or _interface to my interface targets I use like this. Note here library in add library does not actually have to have a library (hence my statements to the horrid miss reuse of add_library for this functionality). It can just have build properties that you want a target to later inherit as far as I understand it or as far as I am miss using it if it is meant to be used some other way. >>> >>> then... >>> >>> add_executable( myTarget ) >>> >>> target_link_libraries( >>> myTarget >>> PluginGroupInterface >>> ) >>> >>> Does that work for your needs? >>> >>> >>> >>> -- snip -- >>> Best, >>> >>> ------- >>> Jean-Micha?l Celerier >>> >>> -- snip -- >>> >>> >>> -- >>> >>> Powered by www.kitware.com >>> >>> Please keep messages on-topic and check the CMake FAQ at: >>> https://cmake.org >>> >>> Kitware offers various services to support the CMake community. For more >>> information on each offering, please visit: >>> >>> CMake Support: https://cmake.org >>> CMake Consulting: https://cmake.org >>> CMake Training Courses: https://cmake.org >>> >>> Visit other Kitware open-source projects at >>> https://cmake.org >>> >>> Follow this link to subscribe/unsubscribe: >>> https://cmake.org >>> >> >> > > > -- > Brian J. Davis > -------------- next part -------------- An HTML attachment was scrubbed... URL: To: CMake MailingList Subject: Re: [CMake] CMake, Mingw-w64 32 bit exception handling. Message-ID: Content-Type: text/plain; charset="utf-8" On Wed, Aug 23, 2017 at 9:57 PM, Robert Maynard wrote: > A quick scan of CMake source code shows that we don't have any > references to gcc_eh anywhere. I way this could be occurring is > through CMake detection of the implicit libraries that a compiler > requires for each language. In particular it could be that C code for > mingw by default uses gcc_eh while C++ doesn't. The culprit could also > be a FindPackage* you are using. > Hi Robert and thanks for your reply. Yes I also did a scan of the cmake source code before sending the mail to the mailing list, and found no reference to gcc_eh. But I do find reference to that in the CMakeOutput.log file, and it seems to come from detection of implicit libraries. So based on this i started by removing all 3rd party libraries in my project and thought of adding one by one until the -lgcc_eh appeared in the linklibs.rsp, and you are right, adding proj.4 3rd party library to the build system seems to result in -lgcc_eh being added... Now to figure out how to prevent that from occurring in linklibs.rsp file for the test application that does not even use that particular 3rd party library. Thanks again for pointing me in the right direction. Best Regards, Arne Kjetil Andersen > > On Wed, Aug 23, 2017 at 4:55 AM, Arne Kjetil Andersen > wrote: > > Greetings. > > > > I'm a developer on a fairly large project where I'm using CMake version > > 3.9.1 > > > > I primarily work on linux, but also cross compiles for windows using > > Mingw-w64 on my linux box. > > > > I have encountered an issue which I'm having some trouble figuring out. > > Running through some of my tests where an exception is thrown (on > purpose) > > the 32 bit version compiled with Mingw-w64-g++ version 7.1.1 just calls > > terminate even though there are try catch blocks. Now mind you, this all > > works fine on the native linux compiled version of my tests, and also > the 64 > > bit windows version compiled with Mingw-w64-g++ version 7.1.1. > > > > Going through all the projects CMakeLists.txt I could not find any reason > > for this behavior, but tried to add -fexceptions as a compiler option in > the > > top most CMakeLists.txt file for the 32 bit mingw-w64 compiler. > > Unfortunately this made no difference. > > > > So investigating some more I took a look at the linklibs.rsp file > generated > > for that particular test executable, and noticed this entry: > > -lgcc_eh -lgcc_eh > > > > (yes it's twice, but that is not the issue, although that might be a > cmake > > bug?). > > (also note - this option is also present for the 64 bit build files for > > mingw-w64, but there it works as expected). > > > > Now, removing those two library link options from the linklibs.rsp file > > makes the 32 bit windows version of test application work as expected. I > am > > not sure what libgcc_eh.a actually does (tried searching for some > > information, but had little luck actually figuring that out), but > clearly it > > has something to do with exception handling. > > > > Now I figured I would create a small minimal example that would reproduce > > this issue outside my projects source tree. So basically created a small > > program that throws an exception, and catches that. Created a > CMakeLists.txt > > file with the same general options as my farily large project, and had > cmake > > generate the build files for 32 bit mingw-w64. Inspecting the > linklibs.rsp > > file I was surprised to see that "-lgcc_eh" were nowhere to be found, > and as > > such the 32 bit version of this test worked fine. > > > > So, my question is, does anyone know under which circumstances cmake will > > add -lgcc_eh to linklibs.rsp, and is there any way I can prevent cmake > from > > doing so for the 32 bit mingw-w64 compiler? > > > > Also, maybe I'm going about this issue the wrong way, and that my > findings > > mentioned above is not a good way of handling this. Or maybe this might > be a > > bug with the 32 bit mingw-w64 compiler? > > > > I should probably also mention that the 32 bit version of Mingw-w64 uses > the > > sjlj exception handling mechanism. > > > > Any help and pointers would be greatly appreciated - cause adding a step > in > > the developer documentation to go into the linklibs.rsp file to remove > > -lgcc_eh is kind of a last resort. > > > > Thanks for any input on this matter, and please let me know if attaching > > CMakeOutput.log or other files would be beneficial. > > > > Best Regards, > > Arne Kjetil Andersen > > > > > > -- > > > > Powered by www.kitware.com > > > > Please keep messages on-topic and check the CMake FAQ at: > > https://cmake.org > > > > Kitware offers various services to support the CMake community. For more > > information on each offering, please visit: > > > > CMake Support: https://cmake.org > > CMake Consulting: https://cmake.org > > CMake Training Courses: https://cmake.org > > > > Visit other Kitware open-source projects at > > https://cmake.org > > > > Follow this link to subscribe/unsubscribe: > > https://cmake.org > -- A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? -------------- next part -------------- An HTML attachment was scrubbed... URL: