[CMake] Ninja generator and showIncludes
Hello. I have been searching for a way to prevent the Ninja generator from issuing the showIncludes command to cl. With our update to the latest CMake (3.8.2) on Windows (7 enterprise, at work) with the latest MSVC (2017 community), we now have a ton of messages saying Note: including file: which makes it difficult to see the actual compilation warnings and errors. Turned to Google and found some information about localization potentially being a problem, so I uninstalled MSVC 2017 which was in the French version and installed the English one. Turns out that only made the include messages English. :) I searched the documentation for a target property that I could use but did not find anything. I thought of using target compile flag, but not sure how I would remove a flag. Searched the mailing list for some info, but most of what I have found does not answer my question. For instance : http://cmake.org/pipermail/cmake-developers/2013-November/020782.html I also looked in the bug tracker and there does not seem to be any issue relating to that, so my guess is I am doing something wrong. So if anyone else has had that problem and/or has a solution for me, I'd appreciate any insight. Thanks. Ghyslain Leclerc -- 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: http://public.kitware.com/mailman/listinfo/cmake
[CMake] Segmentation fault
Hello, I think I have found a “bug” in CMake and as suggested in the Mantis Bug Tracker, I am writing here on the list before actually filing the bug report in case it’s actually not a bug. I have also searched in the already filed bugs for a few minutes to see if it already exists and it does not seem to. Here is the bug: I have used the following call in my CMakeLists.txt: set_property( TARGET cli PROPERTY LINK_LIBRARIES ${CUR_LINK_LIBS} ) When the CUR_LINK_LIBS variable is empty, CMake crashed with a segmentation fault. Naively, I would have expected a CMake error saying incorrect number of arguments or something like that, which CMake does all the time. Maybe this is normal behaviour for set_property. I am running CMake 3.2.3 compiled/installed via Macports on OSX 10.10.4 and Xcode 6.4. Thanks, Ghyslain -- 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: http://public.kitware.com/mailman/listinfo/cmake
[CMake] Multiple targets
Hello, We have a modular in-house library that we use for our software. Let’s call it lib_x. Let’s call a few of the modules (we have 7 I think) mod_y, mod_z, mod_u and mod_v. Let’s say I have two applications that use all of this and call them app_1 and app_2. The way I have setup our CMake builds is that I first find out what modules of lib_x the applications app_1 and app_2 depend on. Then I build a single library lib_x which include the selected modules and finally, I build each app independently and link against the single library. For instance, let’s say app_1 depends on mod_y and mod_z and app_2 depends on mod_y, mod_z and mod_u. Then, I would build lib_x with everything for modules y, z and u (excluding module v) and build app_1 and app_2 linking against lib_x Might not be explained properly (my apologies), willing to answer any questions on that. I am looking into changing/modernizing our build system. From what I understand, instead of building everything into a single library, I could build separate libraries, export them as targets and link against them. (Pretty sure I could have done that before, but just coming around to do it.) Am I wrong ? Am I completely missing the point ? If I am not and it is a reasonable approach, is there a place where a tutorial is available ? I am trying really hard to read the documentation on export command and targets and such, but I am having a real hard time when trying to actually implement anything concrete. I first attempted to do this: include_directories( "${LIB_ROOT_DIR}/include" ) add_library( general ${GENERAL_SRCS} ${GENERAL_HDRS} ${LIB_ROOT_DIR}/include/hdqrt/always_inline.h ${LIB_ROOT_DIR}/include/hdqrt/debug.h ${LIB_ROOT_DIR}/include/hdqrt/Error.h ${LIB_ROOT_DIR}/include/hdqrt/warn_stop.h ${LIB_ROOT_DIR}/include/hdqrt/warn_restart.h ) set_property( TARGET general PROPERTY CXX_STANDARD 14 ) export( TARGETS general FILE general.cmake ) but then, the general.cmake file is nowhere to be found. And if I test in another (parent) CMakeLists.txt to see if the target is defined, it is not. Sorry if this is a silly question. Trying to figure this out. Thanks in advance. Ghyslain-- 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: http://public.kitware.com/mailman/listinfo/cmake
Re: [CMake] Linking to Qt static libraries fails using cmake but not qmake (both OSX and Linux)
Hi, I have just run into this problem a few weeks ago. My explanation might not be perfect, but from what I understand, it is related to the fact that the libraries which Qt depends upon have to be available for static linking to your application. Those dependencies are “magically” brought in by qmake, but the CMake find package for Qt does not bring those in. There have been some attempts, from what I gather, but nothing official for static linking of Qt applications with CMake. Thus, my approach has been to find the system libraries myself using CMake and add them to the target_link_libraries() command. Not much fun or robust (from my perspective), but works. I have been able to statically compile and run the application on a colleague’s computer (where Qt was not installed at all). There is also the concern of the plugins, mainly the platform plugins concept of Qt, which have to be compiled into your application. If I understand correctly, when you request static linking from qmake (+= static), qmake creates a cpp file and adds it to your project. This file simply contains code to insure that the plugins are compiled and can be linked against. For CMake, you have to manually add these includes. I do it in the main.cpp file or whatever file your main is in. Here are links to the earlier discussion: https://www.mail-archive.com/cmake%40cmake.org/msg51188.html https://www.mail-archive.com/cmake%40cmake.org/msg51170.html Stephen Kelly is much more knowledgable then me on this. He usually responds pretty fast to the list (he helped me a lot on that). Hope my explanations are not too confusing and that they help a little. Best of luck. Ghyslain This has been driving me crazy for a while now. Occurs for both OSX and Linux. OSX Mavericks 10.9.5, openSUSE Linux 12.3 CMake 3.1.1 Qt 5.4.1 (both shared and static builds, compiled from source) Using cmake to compile and link the simple Qt HelloWorld app against Qt shared libraries works just fine. Using the same cmake file and specifying the Qt static libraries instead, it fails in the linking (OSX: Undefined symbols for architecture x86_64, ld: symbol(s) not found for architecture x86_64?; LINUX: undefined reference to ?, collect2 error: ld returned 1 exit status) Message would seem to point towards static libraries not compiled 64 bit. But, if I use qmake to generate the makefile to use with the Qt static libraries, it compiles and links with no problem. No symbol problem here. Seems to indicate the static libraries are fine. Since using qmake seems to work fine I can?t pin down what the problem is with cmake. Can anyone shed some light on this? Source, CMakeLists.txt, and qmake .pro contents below. I?ve also attached failed linking output from OSX and linux cmake/make. main.cpp: #include #include int main(int argc, char **argv) { QApplication app (argc, argv); QPushButton button ("Hello world !"); button.show(); return app.exec(); } CMakeLists.txt: cmake_minimum_required(VERSION 2.8.11) project(helloworld) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) find_package(Qt5Widgets REQUIRED) add_executable(helloworld main.cpp) target_link_libraries(helloworld Qt5::Widgets) main.pro: SOURCES = main.cpp CONFIG += qt warn_on release QT += core widgets gui 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: http://public.kitware.com/mailman/listinfo/cmake
Re: [CMake] Mixed linking
Stephen Kelly wrote: Ah, right the platform plugin issue. This is likely the reason for not running on OSX. CMake 3.1 learned a new feature specifically so that this would become easier in the future: http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/7970 qmake generates a file like the above for you and compiles it and links it into your application for you in the static version. With http://www.cmake.org/cmake/help/v3.1/prop_tgt/INTERFACE_SOURCES.html Qt can do the same, but someone would have to patch Qt to do so. Something for the future... :) Thanks for all the insight. I have been looking at this and quite a few posts (mostly from you !) to try and understand. I think I get most of it. That being said, I finally got a static executable for my application on my mac. What I did is build my application using qmake, get the linker command and manually find every library using cmake in order to recreate the linker command from qmake (I don’t think it makes a difference, but I’m not sure so I even kept the library order the same). For my application, this is what did it ended up with (some boiler plate removed). find_package( Qt5 COMPONENTS Widgets Sql PrintSupport REQUIRED ) find_library( DISKARBITRATION_LIBRARY DiskArbitration ) find_library( IOKIT_LIBRARY IOKit ) find_library( APPLICATIONSERVICES_LIBRARY ApplicationServices ) find_library( CORESERVICES_LIBRARY CoreServices ) find_library( COREFOUNDATION_LIBRARY CoreFoundation ) find_library( FOUNDATION_LIBRARY Foundation ) find_library( COCOA_LIBRARY Cocoa ) find_library( CARBON_LIBRARY Carbon ) find_library( OPENGL_LIBRARY OpenGL ) add_executable( calculum ${SRCS_LIST} ${UIS_LIST} ${HDRS_LIST} ) set( QT_INSTALL_DIR_GL "/sw/local/qt/" ) find_library( QCOCOA qcocoa PATHS "${QT_INSTALL_DIR_GL}/plugins/platforms" ) find_library( QDDS qdds PATHS "${QT_INSTALL_DIR_GL}/plugins/imageformats" ) find_library( QICNS qicns PATHS "${QT_INSTALL_DIR_GL}/plugins/imageformats" ) find_library( QICO qico PATHS "${QT_INSTALL_DIR_GL}/plugins/imageformats" ) find_library( QJP2 qjp2 PATHS "${QT_INSTALL_DIR_GL}/plugins/imageformats" ) find_library( QMNG qmng PATHS "${QT_INSTALL_DIR_GL}/plugins/imageformats" ) find_library( QTGA qtga PATHS "${QT_INSTALL_DIR_GL}/plugins/imageformats" ) find_library( QTIFF qtiff PATHS "${QT_INSTALL_DIR_GL}/plugins/imageformats" ) find_library( QWBMP qwbmp PATHS "${QT_INSTALL_DIR_GL}/plugins/imageformats" ) find_library( QWEBP qwebp PATHS "${QT_INSTALL_DIR_GL}/plugins/imageformats” ) # Note, GL are my initials. It was just to ensure no conflicts in names. Probably not necessary target_link_libraries( calculum ${DISKARBITRATION_LIBRARY} ${IOKIT_LIBRARY} ${APPLICATIONSERVICES_LIBRARY} ${CORESERVICES_LIBRARY} ${COREFOUNDATION_LIBRARY} ${FOUNDATION_LIBRARY} ${COCOA_LIBRARY} ${CARBON_LIBRARY} Qt5::Sql ${QCOCOA} cups /sw/local/qt/lib/libQt5PlatformSupport.a ${OPENGL_LIBRARY} Qt5::PrintSupport Qt5::Widgets ${QDDS} ${QICNS} ${QICO} ${QJP2} ${QMNG} ${QTGA} ${QTIFF} ${QWBMP} ${QWEBP} Qt5::Gui Qt5::Core z m ) This seems like a lot of work to get what I want… But if it does the job. The fun part will be to see what I need on Windows and then put conditionals around that and all. If I misunderstood something and there is an easier way to get a static executable from using static qt from CMake, please let me know. I am posting this in case someone searches for information on how to link static Qt using CMake. The title of my mail said Mixed linking, but it should probably really say static linking Qt5 using CMake, but I don’t know how to change it (I have seen on the list the formerly was …, but not sure if it’s appropriate or how to do it). Again, thanks for giving a bit of your time. Really appreciated. Ghyslain -- 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/openso
Re: [CMake] Mixed linking
Hello again. Thanks for the answers. To Stephen Kelly: >> Here are a few questions for the list (hoping someone more knowledgable >> than me will read this and help): >> >> 1) Am I right when I say CMake, Qt and static linking don?t mix ? >They should mix fine. Alright, I won't give up just yet. :-) >> I have tried on OS X. I have compiled a static version of Qt, making >> sure I explicitly enable every plugin I need. Then, I have used the >> following CMake code : >I recommend starting with a minimal testcase, make sure it runs, and add >things until it doesn't. Find the change that breaks. Thanks for the suggestion. Just did. Here is the code for CMake: # Some definitions to setup Qt set( CMAKE_INCLUDE_CURRENT_DIR ON ) set( CMAKE_AUTOMOC ON ) set( QT_STATIC TRUE ) add_definitions( -DQT_STATIC ) if( "${CMAKE_BUILD_TYPE}" MATCHES Release ) add_definitions(-DQT_NO_DEBUG_OUTPUT) endif() # Find Qt packages find_package( Qt5Widgets ) # Find Qt dependencies find_library( COREFOUNDATION_LIBRARY CoreFoundation ) find_library( COCOA_LIBRARY Cocoa ) find_library( CARBON_LIBRARY Carbon ) find_library( OPENGL_LIBRARY OpenGL ) include_directories( ${CMAKE_CURRENT_LIST_DIR} ) add_executable( helwrld main.cpp ) target_link_libraries( helwrld Qt5::Widgets ${COREFOUNDATION_LIBRARY} ${COCOA_LIBRARY} ${CARBON_LIBRARY} ${OPENGL_LIBRARY} "/sw/local/qt/lib/libqtharfbuzzng.a" z ) And here is the main.cpp file #include #include int main(int argc, char *argv[]) { QApplication a(argc, argv); QLabel *label = new QLabel("Hello Qt!"); label->show(); return a.exec(); } Don't know how to make it simpler. Using the code compiles and links, but still won't run. Maybe my Qt static compilation was missing something. I will try and look into that. To Norbert Pfeiler : > Currently you have to define ?QT_STATIC? and explicitly include your > required plugins in the code to get it working. Thanks for the tips. I looked up and now define QT_STATIC. But I just don't know how to include the plugins. Actually, I always get the error about the platform plugin (cocoa in my case). Any tips ? Thank you to all ! Ghyslain -- 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: http://public.kitware.com/mailman/listinfo/cmake
[CMake] Mixed linking
Hello, My apologies for the long post, but I think context helps a little. We have a set of applications (4 at the moment) which compile against ITK, VTK, DCMTK and Boost. All of those things are compiled statically. So is the application. We are developing on Windows, OS X and Linux boxes, but deploying almost only on Windows, so the cross-platform quality of the libraries is important to us and CMake makes it relatively easy to target all those platform. Without going into static vs dynamic territory, I’ll say that our choice is based on ease of deployment to the hospital network where IT has lots of control, but we do not. So far, because of our choice of static linking, deployment is basically renaming the old .exe to keep an archive of all software that has been run clinical, and then put the new executable in place. We’ve come to the stage where a GUI is something that would be practical. We have decided to go with Qt. We would like, if possible, to keep using static linking as a strategy, but as far as I can tell, trying to figure out how to use the new Qt5 macros, static linking of Qt is not exactly supported by CMake. Here are a few questions for the list (hoping someone more knowledgable than me will read this and help): 1) Am I right when I say CMake, Qt and static linking don’t mix ? I have tried on OS X. I have compiled a static version of Qt, making sure I explicitly enable every plugin I need. Then, I have used the following CMake code : find_package( Qt5Widgets ) find_package( Qt5Sql ) find_library( COREFOUNDATION_LIBRARY CoreFoundation ) find_library( COCOA_LIBRARY Cocoa ) find_library( CARBON_LIBRARY Carbon ) find_library( WEBKIT_LIBRARY WebKit ) find_library( IOKIT_LIBRARY IOKit ) find_library( OPENGL_LIBRARY OpenGL ) set( CMAKE_INCLUDE_CURRENT_DIR ON ) set( CMAKE_AUTOMOC ON ) add_executable( calculum ${SRCS_LIST} ${UIS_LIST} ${HDRS_LIST} ) target_link_libraries( calculum ${COREFOUNDATION_LIBRARY} ${COCOA_LIBRARY} ${OPENGL_LIBRARY} ${CARBON_LIBRARY} Qt5::Widgets Qt5::Sql "/sw/local/qt/plugins/platforms/libqcocoa.a" "/sw/local/qt/lib/libqtharfbuzzng.a" z ) qt5_use_modules( calculum Widgets Sql ) Even so, the executable won’t run. I have then tried using the BundleUtilities, but that still won’t work (although I am still figuring things out, so it might be misunderstanding on my part that’s the culprit) 2) If so, we will have to switch to dynamic linking for our GUI applications. In that case, is there a way to keep statically linking our other libraries (ITK, VTK, etc.) into our application and only dynamically link the Qt stuff ? If we can’t, it means we’ll have to create dynamic libraries of all our external libraries and link to them. Deployment will be much harder for us, given that we have zero experience with that. Can you point me towards some tutorials (or documentation, but sometimes, documentation only gets you so far without examples…) ? Thanks Ghyslain -- 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: http://public.kitware.com/mailman/listinfo/cmake
[CMake] Variable shadowing between scope, cache and command line argument
Hello, First post here. Sorry if its too long. Simply trying to be as clear as I can be. I am trying to make sense of the various ways to set a variable and how one can shadow the other. Long story short, I am trying to get the following behaviour for a variable in a script: 1 - check if MYVAR exists 1.1 - If it does, test its validity and set a second variable named MYVAR_VALID to TRUE or FALSE 2 - if MYVAR does not exist or if MYVAR_VALID is FALSE, inspect system for information and set MYVAR (with FORCE in the cache) and MYVAR_VALID (not in cache, but does not seem to make a difference). Hope this is written clearly enough to be understood. Sorry, english is not my first language. Anyhow, I get the following behaviour easily except in one case, which is the reason for my question. These are the cases I have tested : - Start with empty cache and call ccmake. Then, MYVAR does not exist. My script inspects the system, sets the value, sets MYVAR_VALID to TRUE and stops. On successive runs, the variable is defined and valid, so the system is not inspected again. Everything is fine. - Start with empty cache. Run it once, but can’t find a valid entry (or find a wrong one somehow, but that’s practically impossible since the code in my script to inspect the system and to test the variable are basically the same. I digress, sorry). Set MYVAR_VALID to FALSE. User can set the value to a valid one and on next run, the script will set MYVAR_VALID to TRUE and then, we are back to variable defined and valid. Everything is fine. - Start with "non-empty cache" because ccmake (or cmake) is called with -DMYVAR:PATH="/Users/“, for instance. If the value set on command line is fine, then MYVAR_VALID will be set to TRUE on the first run and no system inspection is necessary. The value is now set and valid. Everything is fine. Now, for my problem : - Start with "non-empty cache" because ccmake (or cmake) is called with -DMYVAR:PATH="/Users/“, for instance. But this time, the value is not a valid one. Then, the variable is defined but not valid. So on the first run, the script will inspect the system. If it can find a valid value, I would like my script to override the variable with the valid one. Then, set to valid and so on and so forth... I have not been able to do this. I can find the correct value, I can set the new value, but it is not used. I mean by that that I have inspected the CMakeCache.txt file and when I call ccmake, the cache contains the value set on the command line. Then, I launch my cmake script and output the values of MYVAR and MYVAR_VALID and they are respectively the one of the command line and FALSE. Then, I find the correct value for MYVAR and try and set it. When I inspect the cache, it seems the value has effectively been overwritten. But when I try to output the new variables, it seems to remain stuck at the value provided on the command line. I have tried using unset( MYVAR ) in scope, in the parent scope and in the CACHE before setting the new value. Still, the old value is outputted. The only way to get the new value is to close ccmake and launch it again. Now if you’re still following (I am sorry, a bit complicated to follow I’m afraid, trying to be thourough), I guess my question is: Is this normal behaviour ? Is there something I am missing or is it simply how CMake works and I should simply tell my users to either initially set the right value or restart their ccmake. I haven’t tested this on Windows with CMake-GUI yet. I might have time to do it a little later. Anyhow, if anybody has the courage to read through my mail and try and help me, thanks a million. Ghyslain -- 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: http://public.kitware.com/mailman/listinfo/cmake