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