Re: [CMake] Idea: generic task-driven make-like targets with CMake
Looks interesting Tamas! Too bad shell scripts don’t work natively on Windows :) Kevin On 8 Dec 2015, at 16:59, Tamás Kenéz wrote: Kevin, I have a shell script for such tasks, see https://gist.github.com/tamaskenez/d4509f240f4224eb9853. Feel free to use it if that's what you need. It extends the `cmake` command by executing multiple, related `cmake` calls with one command. See docs in gist. Your 'make release' example looks like this: cmakex cr -Hsourcedir -Bbuilddir # Configure Release with additional options you can do many tasks with one command cmakex cbitdr -Hsourcedir -Bbuilddir -GXcode # Configure, Build, Install, Test Debug & Release using Xcode Tamas On Tue, Dec 8, 2015 at 7:44 PM, Kevin Wojniak <kain...@kainjow.com> wrote: Functionality like add_custom_target combined with script mode is close, but not quite there. add_custom_target already requires a build directory and a generator, so it’s too late. Script mode requires setting variables on the command line, so it’s too verbose. For example: if(“${ACTION}” STREQUAL “release”) execute_process(…) endif() cmake -P myscript.cmake -DACTION=release I suppose you could have multiple *.cmake files for each task, and those could then call the master file with necessary variables set, but then you’d need one file per task and that could become excessive. Kevin On 8 Dec 2015, at 10:22, Nils Gladitz wrote: On 08.12.2015 19:04, Kevin Wojniak wrote: add_task(release COMMAND ${CMAKE_COMMAND} -E make_directory “build_dir” COMMAND ${CMAKE_COMMAND} -E chdir “build_dir” ${CMAKE_COMMAND} “-DCMAKE_BUILD_TYPE=Release”, “..” ) There is add_custom_target(). You can e.g. add_custom_target(release ${CMAKE_COMMAND} -E echo foobar) and with the Makefiles generator run "make release" and with visual studio trigger the build of the "release" project. For scripting you can use cmake in script mode with -P. e.g. given a script file release.cmake: message("Hello World") add_custom_target(release ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/release.cmake) Nils -- 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 -- 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] Idea: generic task-driven make-like targets with CMake
The one thing I’ve found I still have to replace with CMake is the ability to specify generic “make” targets that do various tasks, such as a release build using the same build directory, run tests, grab dependencies. For example, with Make I can do: release: mkdir -p build_dir cd build_dir && cmake -DCMAKE_BUILD_TYPE=Release .. And all I need to run is: make release But this obviously doesn’t work with native MSVC builds. So, then you’re stuck duplicating this logic with Batch or PowerShell scripts, or using a scripting language such as Python or Ruby. Now, Ruby with Rake is a very nice replacement, so this can become: task :release do FileUtils.mkdir_p “build_dir” Dir.chdir “build_dir” do sh “cmake”, “-DCMAKE_BUILD_TYPE=Release”, “..” end end And I can run on all platforms where Ruby/Rake are available: rake release However, Rake/Ruby is a heavy requirement to run these tasks which are very simple for most projects. Plus, you cannot use CMake logic such as compiler/platform detection if you need it outside of CMake. Is there any way to do this cleanly with CMake tools? If not, what if a simple “ctask” tool was added that offered this basic functionality. For example, within my CMakeLists.txt file I could have tasks defined like: add_task(release COMMAND ${CMAKE_COMMAND} -E make_directory “build_dir” COMMAND ${CMAKE_COMMAND} -E chdir “build_dir” ${CMAKE_COMMAND} “-DCMAKE_BUILD_TYPE=Release”, “..” ) Then, this could be executed as: ctask release Tasks could depend on other tasks with a DEPENDS argument, just like normal CMake targets. Thoughts? Kevin -- 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] Idea: generic task-driven make-like targets with CMake
Functionality like add_custom_target combined with script mode is close, but not quite there. add_custom_target already requires a build directory and a generator, so it’s too late. Script mode requires setting variables on the command line, so it’s too verbose. For example: if(“${ACTION}” STREQUAL “release”) execute_process(…) endif() cmake -P myscript.cmake -DACTION=release I suppose you could have multiple *.cmake files for each task, and those could then call the master file with necessary variables set, but then you’d need one file per task and that could become excessive. Kevin On 8 Dec 2015, at 10:22, Nils Gladitz wrote: On 08.12.2015 19:04, Kevin Wojniak wrote: add_task(release COMMAND ${CMAKE_COMMAND} -E make_directory “build_dir” COMMAND ${CMAKE_COMMAND} -E chdir “build_dir” ${CMAKE_COMMAND} “-DCMAKE_BUILD_TYPE=Release”, “..” ) There is add_custom_target(). You can e.g. add_custom_target(release ${CMAKE_COMMAND} -E echo foobar) and with the Makefiles generator run "make release" and with visual studio trigger the build of the "release" project. For scripting you can use cmake in script mode with -P. e.g. given a script file release.cmake: message("Hello World") add_custom_target(release ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/release.cmake) Nils -- 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-developers] Patch for some GUI Mac fixes
These 3 patches fix the Install menu not showing for Qt5 builds, the Install buttons not behaving like the other (standard) buttons, and fixes the search field not being shown on OS X when the window is at minimum size. gui-mac.patch Description: Binary data Kevin -- 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] CMake 3.1 and add_executable() without sources
Hi, I am wondering now that 3.1 is out if using add_executable() without sources and later using target_sources() is a new supported way of creating targets? The docs don’t actually say the sources are optional and you can later use target_sources(). We currently have several macros we reuse for multiple targets across multiple projects but currently require 2 separate macros per functionality to specify target sources (via a shared per-target global variable - yuck) and another for linker options. With 3.1 we can combine these into a single macro without the global var which simplifies our CMakeLists files greatly. But before I start doing this, I want to make sure this an acceptable way going forward. Thanks, Kevin -- 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] Copying another target's executable into OS X app bundle with CMake 3
Hi, we have several projects setup where the main target has a dependency on a smaller target and the smaller target’s executable gets copied into the main target’s OS X app bundle. We’ve been doing this with a combination of getting the target’s LOCATION property and making that path a source of the main target and setting its MACOSX_PACKAGE_LOCATION property. However with CMake 3’s policy change we’re trying to replace usage of this. Unfortunately it looks like we have to now use add_custom_command() and $TARGET_FILE:…. This works, but I’m wondering if there’s a better way to accomplish what I’m after? It’d be great if CMake had some command that takes generator expressions but places targets into a bundle. We don’t use the “install” targets as we need the bundles to be setup with the executables for debugging. Also it’d be very hand to have a generator expression to get the target’s bundle folder. To do that now we have to use $TARGET_FILE_DIR:${TARGET}/..” but it’d be nice and clean to have something like $TARGET_BUNDLE:… Thanks, Kevin -- 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] Sorting Xcode source groups
The way source groups are sorted in Xcode seems off. Here’s a sample file (using v2.8.12): cmake_minimum_required(VERSION 2.8) project(SourceGroupTest) set(SOURCES ./Zebra/file.c ./Snake/file.c ./Dog/file.c ) source_group(Snake REGULAR_EXPRESSION Snake/.*) source_group(Zebra REGULAR_EXPRESSION Zebra/.*) source_group(Dog REGULAR_EXPRESSION Dog/.*) add_executable(${PROJECT_NAME} ${SOURCES}) Full download here: https://www.dropbox.com/s/ikrlhslqk3yvsay/XcodeSourceGroups.zip I would expect that the order of the groups be Snake, Zebra, Dog, however it's Zebra, Snake, Dog. I played around with this and it seems that the order of SOURCES dictates the order of the groups. If I rearrange the listings of the files in SOURCES, it affects the group order. But this seems counterintuitive. Shouldn’t the groups by sorted based on the order of calls to source_group()? Kevin -- 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
[CMake] List CMake source files for external use
Hi, been searching for a while on this and can't find an answer. Maybe I'm just using the wrong keywords.. I have a CMakeLists.txt file that creates a two libraries. I want to generate a list of source files that are used in each library so that I can run a script on these files. I cannot find a good way to do this. My best idea right now is to move the part of the CMake file that configures the SOURCES variable into a separate .cmake file and run CMake in script mode on that with a flag to output the variable. But that seems slightly hackish, and I don't like separating the file into two. Is there a better way? How do programs such as Qt Creator go about reading a CMake file and gathering all the source files? Thanks, Kevin -- 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