Re: [cmake-developers] A policy for Policies
Hi there, I suspect I'm the culprit in this case. To give a bit of context, I think the original recommendation was to the CMake ML (http://cmake.3232098.n2.nabble.com/Help-with-Policy-CMP0026-disallow-LOCATION-target-property-td7589336.html) and the other instance was a recent StackOverflow answer (http://stackoverflow.com/a/30669105/2556117). I'd hardly class the SO answer as a recommendation... but that's by the by :-) As a CMake user, I have a couple of observations here. I don't think any amount of documentation will entirely solve this. Compare the docs for policies (http://www.cmake.org/cmake/help/v3.3/manual/cmake-policies.7.html) with those for file(GLOB ...) (http://www.cmake.org/cmake/help/v3.3/command/file.html) and link_directories (http://www.cmake.org/cmake/help/v3.3/command/link_directories.html) All of these discourage the use of these features in some way (probably most noticeable for file(GLOB ...) due to the highlighting), but there are often answers on SO which recommend them. Having said that, I think the docs for policies is the least likely to be read of the three. I'm only guessing, but I expect users will be more likely to hit the page for the specific policy they're interested in, along with the page for the cmake_policy command (http://www.cmake.org/cmake/help/v3.3/command/cmake_policy.html). None of these pages gives even a hint that setting a policy to OLD is discouraged. From my own perspective, runtime warnings would be the best way to encourage me to use a different option other than setting a policy to OLD. Again as an outsider, if setting CMP0002 to OLD to allow duplicate target names is a guaranteed bug regardless of OS or compiler, I can't see a reason to continue supporting it. Cheers, Fraser. On 08/06/2015 21:52, Brad King wrote: On 06/08/2015 04:43 PM, Stephen Kelly wrote: In fact, I added that in response to someone on SO recommending setting policies to OLD and pointed them to the commit and the generated docs, and they're still recommending the same thing as SO answers. Policies are alive too long to be credible pending error-conditions. They look like - and are treated as - feature toggles. Given the existing docs you quoted I don't think any further docs such as release notes will help. We would need to add a runtime warning to draw attention to pending removal. It would be different than the current not set warning and instead be not set to NEW. -Brad -- 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-developers
Re: [CMake] Help with Policy CMP0026 (disallow LOCATION target property)
Yup - fair enough. I downgrade my Alternatively to As a last resort. Thanks, Fraser. On 30/12/2014 12:13, Stephen Kelly wrote: Fraser Hutchison wrote: Alternatively, you can tell CMake to allow the use of the LOCATION target property by setting the relevant policy to use the old behaviour temporarily Please don't do that. Please don't encourage others to do it either. Policies are not feature toggles. http://www.cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cd4fa896 Thanks, Steve. -- 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] Help with Policy CMP0026 (disallow LOCATION target property)
Hi Paul, I'd have thought the following replacement would work the same: function(stageobj target dir) add_custom_target(stage_${target} ALL COMMAND "${CMAKE_COMMAND}" -E make_directory "${DESTDIR}/${dir}" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$TARGET_FILE:${target}" "${DESTDIR}/${dir}" COMMENT "Staging ${target} to ${DESTDIR}/${dir}" VERBATIM) add_dependencies(stage_${target} ${target}) endfunction() Alternatively, you can tell CMake to allow the use of the LOCATION target property by setting the relevant policy to use the old behaviour temporarily: function(stageobj target dir) cmake_policy(PUSH) if(POLICY CMP0026) cmake_policy(SET CMP0026 OLD) endif() get_property(targetpath TARGET ${target} PROPERTY LOCATION) cmake_policy(POP) ... endfunction() Cheers, Fraser. On 24/12/2014 13:04, Paul Smith wrote: On Tue, 2014-12-23 at 16:59 -0500, David Cole wrote: Are you sure there's a problem using TARGET_FILE in your original context? You should be able to use that in a custom command in your custom stage_tgt target... You have to give the name of the target for the TARGET_FILE generator _expression_, so it should work for any target that cmake knows about. Can you point to a simplified reproducible case where this does not work? Maybe there's some other complication in your real project that is making it seem like it's not working but I think it should. Can you send us any code? Thanks for the reply David. The complication is that the rule I'm trying to create that copies files uses the destination file as the target, so I'm using the target name in the OUTPUT section of add_custom_command. Basically, my current implementation is like this: function(stageobj target dir) get_property(targetpath TARGET ${target} PROPERTY LOCATION) get_filename_component(targetname ${targetpath} NAME) add_custom_command(OUTPUT "${DESTDIR}/${dir}/${targetname}" COMMAND "${CMAKE_COMMAND}" -E make_directory "${DESTDIR}/${dir}" COMMAND "${CMAKE_COMMAND}" -E copy "${targetpath}" "${DESTDIR}/${dir}" DEPENDS ${target} COMMENT "Staging ${target} to ${DESTDIR}/${dir}" VERBATIM) add_custom_target("stage_${target}" ALL DEPENDS "${DESTDIR}/${dir}/${target}") endfunction() This has the very nice feature that it's a real rule, and it only fires if needed (that is, ${target} has been updated since the last time we copied it). But, I can't replace "${targetname}" in the OUTPUT section with a generator _expression_, because they don't seem to be allowed there: CMake Error at CMake/Stage.cmake:93 (add_custom_command): add_custom_command called with OUTPUT containing a "". This character is not allowed. Thoughts or alternatives are welcome... -- 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-developers] Patch for new warning caused by CMP0054
On 20/11/2014 13:59, Brad King wrote: The latter will be merged to 'release' for 3.1.0-rc3. Thanks very much. Fraser. -- 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-developers
[cmake-developers] Patch for new warning caused by CMP0054
Hi there, CMake 3.1 (both release candidates) now generate a CMP0054 warning when configuring the following CMakeLists.txt in a clean build folder with MSVC as the generator: cmake_minimum_required(VERSION 2.8) enable_language(ASM_MASM) The warning is: CMake Warning (dev) at E:/Program Files (x86)/CMake 3/share/cmake-3.1/Modules/CMakeFindBinUtils.cmake:33 (if): Policy CMP0054 is not set: Only interpret if() arguments as variables or keywords when unquoted. Run "cmake --help-policy CMP0054" for policy details. Use the cmake_policy command to set the policy and suppress this warning. Quoted variables like "MSVC" will no longer be dereferenced when the policy is set to NEW. Since the policy is not set the OLD behavior will be used. I can see the file in question has been updated (presumably since RC2) to not quote the left-hand variables: http://www.cmake.org/gitweb?p=cmake.git;a=blob;f=Modules/CMakeFindBinUtils.cmake;h=50cb9721272f98bc2ffe73e95ae57c3156251188;hb=HEAD but even with these updates, the quoted "MSVC" args generate the warning. I've attached a trivial patch removing all remaining instances of quoted "MSVC"s. Cheers, Fraser. From 9c0cd531876c60ad12e5df443bc3026a97a04404 Mon Sep 17 00:00:00 2001 From: Fraser Hutchison fraser.hutchi...@maidsafe.net Date: Tue, 18 Nov 2014 22:55:52 + Subject: [PATCH] Removed quoted instances of MSVC to avoid generating warnings via CMP0054. --- Modules/CMakeFindBinUtils.cmake | 10 +- Modules/Compiler/AppleClang-CXX.cmake | 2 +- Modules/Compiler/Clang-CXX.cmake | 2 +- Modules/Compiler/Clang.cmake | 4 ++-- Modules/Platform/Windows-Clang.cmake | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index 50cb972..d2991d2 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -30,11 +30,11 @@ # License text for the above reference.) # if it's the MS C/CXX compiler, search for link -if(CMAKE_C_SIMULATE_ID STREQUAL MSVC - OR CMAKE_CXX_SIMULATE_ID STREQUAL MSVC - OR CMAKE_Fortran_SIMULATE_ID STREQUAL MSVC - OR CMAKE_C_COMPILER_ID STREQUAL MSVC - OR CMAKE_CXX_COMPILER_ID STREQUAL MSVC +if(CMAKE_C_SIMULATE_ID STREQUAL MSVC + OR CMAKE_CXX_SIMULATE_ID STREQUAL MSVC + OR CMAKE_Fortran_SIMULATE_ID STREQUAL MSVC + OR CMAKE_C_COMPILER_ID STREQUAL MSVC + OR CMAKE_CXX_COMPILER_ID STREQUAL MSVC OR (CMAKE_GENERATOR MATCHES Visual Studio AND NOT CMAKE_VS_PLATFORM_NAME STREQUAL Tegra-Android)) diff --git a/Modules/Compiler/AppleClang-CXX.cmake b/Modules/Compiler/AppleClang-CXX.cmake index 0372e18..0cabca4 100644 --- a/Modules/Compiler/AppleClang-CXX.cmake +++ b/Modules/Compiler/AppleClang-CXX.cmake @@ -1,6 +1,6 @@ include(Compiler/Clang) __compiler_clang(CXX) -if(NOT CMAKE_CXX_SIMULATE_ID STREQUAL MSVC) +if(NOT CMAKE_CXX_SIMULATE_ID STREQUAL MSVC) set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN -fvisibility-inlines-hidden) endif() diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake index 780a072..bc88405 100644 --- a/Modules/Compiler/Clang-CXX.cmake +++ b/Modules/Compiler/Clang-CXX.cmake @@ -1,7 +1,7 @@ include(Compiler/Clang) __compiler_clang(CXX) -if(NOT CMAKE_CXX_SIMULATE_ID STREQUAL MSVC) +if(NOT CMAKE_CXX_SIMULATE_ID STREQUAL MSVC) set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN -fvisibility-inlines-hidden) endif() diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake index eeba119..b964fce 100644 --- a/Modules/Compiler/Clang.cmake +++ b/Modules/Compiler/Clang.cmake @@ -18,8 +18,8 @@ if(__COMPILER_CLANG) endif() set(__COMPILER_CLANG 1) -if(CMAKE_C_SIMULATE_ID STREQUAL MSVC -OR CMAKE_CXX_SIMULATE_ID STREQUAL MSVC) +if(CMAKE_C_SIMULATE_ID STREQUAL MSVC +OR CMAKE_CXX_SIMULATE_ID STREQUAL MSVC) macro(__compiler_clang lang) endmacro() else() diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake index 4c936fe..d37b969 100644 --- a/Modules/Platform/Windows-Clang.cmake +++ b/Modules/Platform/Windows-Clang.cmake @@ -18,8 +18,8 @@ if(__WINDOWS_CLANG) endif() set(__WINDOWS_CLANG 1) -if(CMAKE_C_SIMULATE_ID STREQUAL MSVC -OR CMAKE_CXX_SIMULATE_ID STREQUAL MSVC) +if(CMAKE_C_SIMULATE_ID STREQUAL MSVC +OR CMAKE_CXX_SIMULATE_ID STREQUAL MSVC) include(Platform/Windows-MSVC) macro(__windows_compiler_clang lang) __windows_compiler_msvc(${lang}) -- 1.9.4.msysgit.1 -- 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: CM
Re: [CMake] Useful extensions for CMake blog post
Indeed! On 05/09/2014 20:09, David Cole via CMake wrote: Wow. -- 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] [CMAKE] Getting compilation date through CMake
Hi Jon, You'd have to invoke the command prompt to execute this I think. On Windows this should be the value of the COMSPEC environment variable, so your command would be something like: execute_process(COMMAND $ENV{COMSPEC} /c date /t OUTPUT_VARIABLE _output ) However, this is Windows-specific. If you can specify CMake version 2.8.11 as a minimum, you could use the string(TIMESTAMP ...) command instead: string(TIMESTAMP _output "%d/%m/%Y") Bear in mind that these only execute when CMake runs (i.e. at configure time) rather than at build time, so strictly-speaking you're not actually grabbing the compile date. Cheers, Fraser. On 05/12/2013 19:32, Jon Haitz Legarreta wrote: Hi there, I was trying to get the compilation time through a CMake-executed command in order to know the compilation time of a given project. In my custom.cmake file I was using execute_process(COMMAND date -t OUTPUT_VARIABLE _output ) It turns out that the _output variable is empty when I compile my project. However, the command works well from the command line. I'm working on a Win 7 64-bit machine. I wanted to avoid using an extra C/C++ code file to get the current time. Am I missing something? Thank you, JON HAITZ -- 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://www.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: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] ExternalProject_Add examples
There's a StackOverflow answer I did a while back which gives an example of ExternalProject_Add for GTest: http://stackoverflow.com/a/9695234/2556117 It maybe needs updated, and I don't think I ever tried it on OSX, but it should hopefully be an OK starting point. (If not - hack away at my answer!) Cheers, Fraser. On 24/10/2013 09:35, Witold E Wolski wrote: Would also like to start configuring external dependencies with ExternalProject_Add So some examples would be pretty useful to me. So did you ended up collecting some examples? Sure, you posted in this links to repositories, but finding the ExternalProject_Add in these huge projects with hundreds of CMakeLists.txt is not easy if they are not in the top-level CMakeLists.txt and they are not there. My dependencies are gtest - Cmake glog - Cmake tbb - configure make vigra - Cmkae based soci - Cmake based pwiz regards On 18 March 2012 00:24, Luigi Calori l.cal...@cineca.it wrote: On 17/03/2012 22.11, Marcus D. Hanwell wrote: On Sat, Mar 17, 2012 at 5:03 PM, Bill Lorensenbill.loren...@gmail.com wrote: Folks, I've recently created a number of super builds using CMake's External Project mechanism. Each external project requires some sort of download, configuration, build and possibly install. The CMake defines needed to correctly access the results of the external project vary significantly. The trickiest part is find the proper download, configuration and CMake defines. For example, for the Point Cloud Library (http://pointclouds.org/) I created these external projects: VTK - git, cmake, make; VTK_DIR FLANN - zip, cmake, make install; FLANN_LIBRARY, FLANN_INCUDE_DIR Eigen - .tar.bz2,; EIGEN_INCLUDE_DIR Qhull - git, cmake, make;QHULL_LIBRARY,QHULL_INCLUDE_DIR Boost - .tar.gz, bootstrap.sh, b2; BOOST_ROOT GTest - .zip, cmake, make; GTEST_ROOT,GTEST_INCLUDE_DIR Slicer4 has many more. Should we start collecting sample ExternalProject_Add files for external projects? We have talked about doing this too (I have Eigen, Boost, GTest and others for example). The standard CMake based projects hardly seem worth it, but it depends on what you want to do with them I suppose. For the work we are doing in chemistry we have been working on an experimental superbuild that uses a common prefix in the build tree to install to, and then all we need pass in is CMAKE_PREFIX_PATH - this can make the logic significantly easier for dependent CMake projects as it will always search within the prefix first. I did something similar, trying to collet all the build of stuff that I had to do in a single place powered by cmake Used CMAKE_PREFIX_PATH and a single source place where all the builds download and expand you can have a look at https://hpc-forge.cineca.it/svn/CmakeBuilds/lib/ It's just for my use only, so really dirty and not properly checked, I' m also looking for good starting point for common stuff like Qt, boost and others (I' tried to collect in the folder Packages the tricky part of building the components,) I' ve tried to define a dependency graph but it' still messy anyway I would really appreciate a place where to share good recipies for CMake building packeges Thanks Luigi The Qt external project was pretty tricky too, and we are using that in several places along with smaller libraries like libxml2. Marcus -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake -- Luigi Calori SuperComputing Applications and Innovation Department CINECA - via Magnanelli, 6/3, 40033 Casalecchio di Reno (Bologna) - ITALY Tel: +39 051 6171509 Fax: +39 051 6132198 hpc.cineca.it -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.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: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] set_directory_properties() Isn't
Hi Rob, The DEFINITIONS directory property is read-only. COMPILE_DEFINITIONS or the configuration-specific versions are mutable I believe. Cheers, Fraser. On 30/08/2013 22:30, Stewart, Robert wrote: I'm effectively doing the following, with CMake 2.8, but it doesn't work. What am I missing? get_directory_property(before DEFINITIONS) set_directory_properties(PROPERTIES DEFINITIONS -DFOO) get_directory_property(after DEFINITIONS) before and after are the same, and before isn't -DFOO. _ Rob Stewart Software Engineer Dev Tools Components Susquehanna International Group, LLP IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses. -- 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://www.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: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Is it possible to show dependent files in Visual Studio folders for ADD_CUSTOM_TARGET?
I think this is what the SOURCES arg is for. You could just duplicate the list of DEPENDS files as the SOURCES argument too: add_custom_target(LIB_NAME DEPENDS ${LIST_OF_HEADERS} SOURCES ${LIST_OF_HEADERS}) Cheers, Fraser. On 19/01/2013 10:08, Jose Luis Blanco wrote: Hello all, I hope you can help me answering whether the following is possible with CMake: We have a set of C++ libraries, some of which are header-only. Obviously those ones don't really need to be built, but it's interesting to define targets for them anyway to define dependencies in other executables libraries that depend on them. Right now, my approach to define header-only libs is like: add_custom_target(LIB_NAME DEPENDS ${LIST_OF_HEADERS}) But then the Visual Studio (or CodeBlock) folders don't show any of the header files, only the CMakeLists.txt file and the CMake rules folder. I've tried with explicit calls to SOURCE_GROUP() without results. I would be great to have the headers shown in the project folder for quickly opening them for editing, launching all solution files searches, etc. Any idea on how to achieve this? Is it possible without modifying CMake sources? Cheers, Jose Luis -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Accepted way to add -fPIC onto CMAKE_CXX_FLAGS?
I'm not a Linux guy, so hopefully someone else more knowledgeable can chime in here, but if you want to add to your CMAKE_CXX_FLAGS, you need to avoid creating a semi-colon-separated list by moving the quote mark: set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") Also, "LINUX" is not defined by default using CMake, so unless you're detecting Linux and setting "LINUX" to true somewhere before this, the if block will be skipped. UNIX is defined by default, but this includes OSX, so if you really want just Linux, use something like if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") Finally, I guess "CMAKE_CSS_FLAGS" is a typo? Cheers, Fraser. On 18/06/2012 22:09, Michael Jackson wrote: Linux really wants to have -fPIC for some of my code and I am trying to detect linux and then add this flag for my project but I am having no luck. if (LINUX) set(CMAKE_CXX_FLAGS ${CMAKE_CSS_FLAGS} "-fPIC") endif() Is this NOT the way I should be doing this? It doesn't really "fell" correct but nothing else (including this) seems to work. Help? Thanks ___ Mike JacksonPrincipal Software Engineer BlueQuartz SoftwareDayton, Ohio mike.jack...@bluequartz.net www.bluequartz.net -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Visual Studio 2012 Beta: unable to compile individual files
Yeah - I can reproduce this too (better late than never - sorry!) I've upvoted your bug report Ben. Cheers, Fraser. On 12/06/2012 19:55, Ben Medina wrote: I've filed a bug with Microsoft: https://connect.microsoft.com/VisualStudio/feedback/details/748640/cannot-compile-individual-files-if-project-contains-full-path-to-file On Tue, Jun 12, 2012 at 11:20 AM, Ben Medina ben.med...@gmail.com wrote: Thanks! Here are the results: - Using the VS2010 generator, the project files have relative paths. VS2012RC can load 2010 project files without modifying them. If I do this, compilation of individual files is successful. - Using the VS11 generator, the project files have absolute paths, and compilation of individual files fails. So can the same relative path workaround be done for the VS11 generator? - Ben On Tue, Jun 12, 2012 at 8:54 AM, Brad King brad.k...@kitware.com wrote: On 06/12/2012 11:51 AM, Brad King wrote: http://www.cmake.org/Bug/view.php?id=12570 The main change to address it is here: http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d931ce9f I forgot to point out that this change is not in CMake 2.8.8 but will be in 2.8.9. -Brad -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] flags for shared/static lib
You can use: set_target_properties(${target}-static PROPERTIES COMPILE_DEFINITIONS RR_STATIC) For full details, run: cmake --help-property COMPILE_DEFINITIONS Cheers, Fraser. On 12/06/2012 23:39, Totte Karlsson wrote: Hi, I have a CMakeLists.txt that creates both a shared and static lib. In short it looks something like this: add_definitions(-DEXPORT_RR) add_library(${target} SHARED ${rrSources}) add_library(${target}-static STATIC ${rrSources}) The problem being that for the static version, the flag -DRR_STATIC should be defined. How can one achieve that? -totte -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] flags for shared/static lib
I assume they do the same thing too in this case, but I defer to David since he works for Kitware and knows the source code, whereas I don't and don't :-) On 13/06/2012 00:56, Totte Karlsson wrote: On 6/12/2012 4:23 PM, Fraser Hutchison wrote: You can use: |set_target_properties(${target}-static PROPERTIES COMPILE_DEFINITIONS RR_STATIC)| I got the following tip from D Cole to use set_property(TARGET ${target}-static PROPERTY COMPILE_DEFINITIONS RR_STATIC) I assume set_target_properties will do exactly the same. Actually, set_target_props looks better in my context so I'll use that. Thanks! For full details, run: |cmake --help-property COMPILE_DEFINITIONS| Cheers, Fraser. On 12/06/2012 23:39, Totte Karlsson wrote: Hi, I have a CMakeLists.txt that creates both a shared and static lib. In short it looks something like this: add_definitions(-DEXPORT_RR) add_library(${target} SHARED ${rrSources}) add_library(${target}-static STATIC ${rrSources}) The problem being that for the static version, the flag -DRR_STATIC should be defined. How can one achieve that? -totte -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Overriding CMAKE_LANG_FLAGS on a per target basis for Visual Studio project generation
Hi Dan, I don't think it's possible to set compiler flags on a per-configuration, per-target basis without splitting your project. There was a very similar discussion recently [1],[2] which indicated a couple of options. However the first option can't be used on a per-configuration basis, which I imagine you'd need since you'll be wanting /MTd and /MDd for debug builds. So you're left with using add_subdirectory() along with a separate CMakeLists.txt for this subdirectory which defines the flags appropriate for its targets, and which can have entirely different flags to its parent. Cheers, Fraser. [1] http://www.cmake.org/pipermail/cmake/2012-April/049927.html [2] http://www.cmake.org/pipermail/cmake/2012-April/049938.html On 20/04/2012 08:31, Dan Peterson wrote: I love cmake, but I am still a bit of a novice, so perhaps there is a better way to approach this problem. I am building a library using cmake. On Windows I need to be able to build two versions: one that links statically to the CRT (/MT) and one that links dynamically to the CRT (/MD). I would like to avoid setting properties on directories (not sure if it would work anyway) or doing anything that requires me to split my project into two pieces. I know there is a general solution to the CRT linkage problem by setting CMAKE_LANG_FLAGS globally (see http://stackoverflow.com/questions/1618927/cmake-microsoft-visual-studio-and-monolithic-runtimes). It works great, but I cannot figure out a way to accomplish the same thing on a per target basis. My CMakeLists.txt for this library is similar to the following: INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR} ) SET( MYLIB_SRCS foo.h bar.h baz.h foo.cpp ) IF( WIN32 ) ADD_LIBRARY( MylibMD STATIC ${MYLIB_SRCS} ) ADD_LIBRARY( MylibMT STATIC ${MYLIB_SRCS} ) # Statically link to Visual C++ CRT FOREACH( Flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO ) IF( ${Flag_var} MATCHES /MD ) STRING( REGEX REPLACE /MD /MT ${Flag_var}MT ${${Flag_var}} ) SET_TARGET_PROPERTIES( MylibMT PROPERTIES ${Flag_var} ${${Flag_var}MT} ) # I also tried this # SET_PROPERTY( TARGET MylibMT PROPERTY ${Flag_var} ${${Flag_var}MT} ) ENDIF( ${Flag_var} MATCHES /MD ) ENDFOREACH( Flag_var ) ELSE( WIN32 ) ADD_LIBRARY( Mylib STATIC ${MYLIB_SRCS} ) ENDIF( WIN32 ) I tried adding this in with COMPILE_FLAGS and other properties. I also tried multiple things like the following in place of the for loop: SET_TARGET_PROPERTIES( MylibMT PROPERTIES STATIC_LIBRARY_FLAGS_DEBUG /MTd STATIC_LIBRARY_FLAGS_RELEASE /MT STATIC_LIBRARY_FLAGS_MINSIZEREL /MT STATIC_LIBRARY_FLAGS_RELWITHDEBINFO /MT ) I found this thread on the mailing list: http://www.cmake.org/pipermail/cmake/2010-August/039046.html, but couldn't make any use of it, unless it would work to remove all CRT linkage from the CMAKE_LANG_FLAGS and then add it back via COMPILE_FLAGS or something else; but COMPILE_FLAGS doesn't seem to have a per configuration variant. Please let me know if it is even possible to accomplish what I am trying to do. Thanks. -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Forcing project to be included in a solution?
David's original answer does what you require. Simply include |add_custom_target(Foo ...)| and don't include |add_dependencies(Bar Foo)|. If your project is also called Bar, then Bar.sln will include Foo.vcproj and Bar.vcproj, but Foo will not be built when invoking Build Solution. Cheers, Fraser. On 04/04/2012 21:33, Robert Dailey wrote: Sorry I think we are not on the same page. My custom target is: Foo My C++ executable target is: Bar I don't want Bar depend on Foo, because I do not want Foo's commands to execute when I build Bar. However, because Bar does not depend on Foo, Foo.vcproj will not be part of Bar.sln. I need a way to make sure that Foo.vcproj opens with Bar.sln without creating that dependency. I hope this makes a little more sense. On Wed, Apr 4, 2012 at 2:01 PM, David Cole david.c...@kitware.com mailto:david.c...@kitware.com wrote: Your original message said you didn't want to make it a dependency. So, why then use add_dependencies ...? On Wed, Apr 4, 2012 at 3:00 PM, David Cole david.c...@kitware.com mailto:david.c...@kitware.com wrote: Well, add_dependencies means that the custom target will be built *before* the target that needs it. So it becomes part of ALL if the other target is part of ALL. I thought nothing depended on it, that's why I offered the leave out ALL advice. If something depends on it, then it's going to be executed before the thing that depends on it... On Wed, Apr 4, 2012 at 2:35 PM, Robert Dailey rcdailey.li...@gmail.com mailto:rcdailey.li...@gmail.com wrote: I add the custom targets as a dependency with add_dependencies(), and I create the targets with add_custom_target(), I don't specify ALL. In my test with Visual Studio 2008, building the parent project results in these custom targets being built as well. According to your instruction, this should not happen, correct? On Wed, Apr 4, 2012 at 12:10 PM, David Cole david.c...@kitware.com mailto:david.c...@kitware.com wrote: Sure, just use add_custom_target without the ALL argument. If you don't use ALL, then the project is completely disconnected from ALL_BUILD and everything else, and will only be triggered when you explicitly build that target/project. HTH, David On Wed, Apr 4, 2012 at 12:53 PM, Robert Dailey rcdailey.li...@gmail.com mailto:rcdailey.li...@gmail.com wrote: Hi, I have a custom target that just runs some commands that have nothing to do with building source. For convenience, when generating visual studio projects, I'd like for that target to be included in the SLN generated by project() but I don't want to make it a dependency, since that would force it to build when I build any other project in the solution (I think). Is there a way to make a vcproj be included in a sln without it building as part of the dependency chain? Thanks in advance. -- Powered by www.kitware.com http://www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Use of ADD_CUSTOM_COMMAND
Hi Gib, Try the following: GET_TARGET_PROPERTY(FUBAR_EXE fubar LOCATION) ADD_CUSTOM_COMMAND(TARGET fubar POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${FUBAR_EXE} somepath) Cheers, Fraser. On 20/04/2011 03:31, Gib Bogle wrote: I'm a real cmake novice, and I find the cmake documentation hard to follow, because it assumes that you know what you're doing (and I obviously don't) and doesn't provide examples. I simply want to add to CMakeLists.txt an instruction to copy the executable created to another directory. I gather that I want to use ADD_CUSTOM_COMMAND, and naively I thought this might do it: ADD_CUSTOM_COMMAND( TARGET fubar POST_BUILD COMMAND copy fubar.exe somepath/fubar.exe) but although this doesn't trigger a cmake error, it doesn't do anything either, and doesn't even seem to change Makefile. Can someone point me in the right direction? I'm using MinGW tools on Windows. Thanks Gib ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake