[CMake] Fwd: set_target_properties and language specific COMPILE_FLAGS

Chuck Atkins chuck.atkins at kitware.com
Fri Aug 1 14:37:01 EDT 2014


Hi Nick,

You could split your target in to two object libraries that combine into a
singe "real" library:

add_library(foo_f OBJECT ${FOO_F_SOURCES})
# set necessary compile flags specific to the Fortran components
# on the foo_f target

add_library(foo_c OBJECT ${FOO_C_SOURCES})
# set necessary compile flags specific to the C components
# on the foo_c target

# Combine into a "real" library
add_library(foo $<TARGET_OBJECTS:foo_f> $<TARGET_OBJECTS:foo_c>)

See http://www.cmake.org/Wiki/CMake/Tutorials/Object_Library

- Chuck


On Fri, Aug 1, 2014 at 12:54 PM, Nicolas Bock <nicolasbock at gmail.com> wrote:

> Hi,
>
> I am building a library containing Fortran and C sources. I would like
> to add language specific compile flags without affecting the global
> compile flags:
>
> set_target_properties( foo PROPERTIES C_FLAGS "-fopenmp" Fortran_FLAGS
> "-openmp" )
>
> However, it seems there is only COMPILE_FLAGS which presumably affects
> both languages.
>
> Thanks already,
>
> nick
> --
>
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20140801/9cc37984/attachment.html>


More information about the CMake mailing list