Re: [CMake] Idea: generic task-driven make-like targets with CMake

2015-12-09 Thread Kevin Wojniak
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  
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

Re: [CMake] Idea: generic task-driven make-like targets with CMake

2015-12-09 Thread Tamás Kenéz
[getting offtopic] Well, not because of this script but for any serious
development on Windows I think it's a good idea to use the *nix shell
provided by the Windows Git installation, it feels quite native. Together
with cbucher's ConsoleZ you get a very convenient environment for
cmake/command-line centered development, even when working with VS IDE.

On Wed, Dec 9, 2015 at 6:43 PM, Kevin Wojniak  wrote:

> 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 
>> 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

2015-12-08 Thread Kevin Wojniak
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

2015-12-08 Thread Nils Gladitz

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

Re: [CMake] Idea: generic task-driven make-like targets with CMake

2015-12-08 Thread Kevin Wojniak
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

Re: [CMake] Idea: generic task-driven make-like targets with CMake

2015-12-08 Thread Tamás Kenéz
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  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