[CMake] macros with arguments

2015-05-19 Thread Tom Kacvinsky
HI,

Background:  trying to build several executables that have the same target
link libraries, compile flags, etc..., but different source files.  Rather
than duplicate all of the necessary bits for each target, I thought I'd
write a macro that takes in arguments (the target name and list of files).

But I am am unsure (based on the cmake documentation for macro()) as how to
pick out the target and list of files so I can do the right thing with
add_executable.

Any ideas?

Thanks,

Tom
-- 

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] macros with arguments

2015-05-19 Thread Tom Kacvinsky
On Tue, May 19, 2015 at 1:28 PM, Tom Kacvinsky  wrote:

> HI,
>
> Background:  trying to build several executables that have the same target
> link libraries, compile flags, etc..., but different source files.  Rather
> than duplicate all of the necessary bits for each target, I thought I'd
> write a macro that takes in arguments (the target name and list of files).
>
> But I am am unsure (based on the cmake documentation for macro()) as how
> to pick out the target and list of files so I can do the right thing with
> add_executable.
>
> Any ideas?
>
> Thanks,
>
> Tom
>

I figured this out.

macro(macro_name target_name)
add_executable(${target_name} ${ARGN})
target_link_libraries(${target_name} ...)
endmacro(macro_name)

Sorry for the noise

Tom
-- 

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