diff options
author | Brad King <brad.king@kitware.com> | 2018-01-16 14:33:12 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2018-01-16 14:33:23 (GMT) |
commit | b4dfe1d8163055f9f40a4c18f5eccccb28f06559 (patch) | |
tree | 43bfa7f2daa92077ac51e4256887684cf419d477 /Help | |
parent | 7accd7ebe2b6e9999e427c23a81c6e6811033a1d (diff) | |
parent | 506fda1cf026a88378589009b62ca8bf633c5197 (diff) | |
download | CMake-b4dfe1d8163055f9f40a4c18f5eccccb28f06559.zip CMake-b4dfe1d8163055f9f40a4c18f5eccccb28f06559.tar.gz CMake-b4dfe1d8163055f9f40a4c18f5eccccb28f06559.tar.bz2 |
Merge topic 'extend-compile-language-genex'
506fda1c Genex: Enable COMPILE_LANGUAGE for INCLUDE_DIRECTORIES with VS and Xcode
c2f79c98 Genex: Enable COMPILE_LANGUAGE for COMPILE_DEFINITIONS with VS and Xcode
0795d25b cmVisualStudio10TargetGenerator: Factor out include dir computation
1ab4d186 cmLocalVisualStudio7Generator: Clarify variable name of compiled language
07e1a743 cmLocalVisualStudio7Generator: Clarify condition for target that compiles
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1657
Diffstat (limited to 'Help')
-rw-r--r-- | Help/manual/cmake-generator-expressions.7.rst | 42 | ||||
-rw-r--r-- | Help/release/dev/extend-compile-language-genex.rst | 15 |
2 files changed, 32 insertions, 25 deletions
diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst index dc5621a..0f6d4cf 100644 --- a/Help/manual/cmake-generator-expressions.7.rst +++ b/Help/manual/cmake-generator-expressions.7.rst @@ -97,21 +97,35 @@ Available logical expressions are: compile features and a list of supported compilers. ``$<COMPILE_LANGUAGE:lang>`` ``1`` when the language used for compilation unit matches ``lang``, - otherwise ``0``. This expression may be used to specify compile options for - source files of a particular language in a target. For example, to specify - the use of the ``-fno-exceptions`` compile option (compiler id checks - elided): + otherwise ``0``. This expression may be used to specify compile options, + compile definitions, and include directories for source files of a + particular language in a target. For example: .. code-block:: cmake - add_executable(myapp main.cpp foo.c bar.cpp) + add_executable(myapp main.cpp foo.c bar.cpp zot.cu) target_compile_options(myapp PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions> ) + target_compile_definitions(myapp + PRIVATE $<$<COMPILE_LANGUAGE:CXX>:COMPILING_CXX> + $<$<COMPILE_LANGUAGE:CUDA>:COMPILING_CUDA> + ) + target_include_directories(myapp + PRIVATE $<$<COMPILE_LANGUAGE:CXX>:/opt/foo/cxx_headers> + ) + + This specifies the use of the ``-fno-exceptions`` compile option, + ``COMPILING_CXX`` compile definition, and ``cxx_headers`` include + directory for C++ only (compiler id checks elided). It also specifies + a ``COMPILING_CUDA`` compile definition for CUDA. - Note that with :ref:`Visual Studio Generators` there is no way to represent + Note that with :ref:`Visual Studio Generators` and :generator:`Xcode` there + is no way to represent target-wide compile definitions or include directories + separately for ``C`` and ``CXX`` languages. + Also, with :ref:`Visual Studio Generators` there is no way to represent target-wide flags separately for ``C`` and ``CXX`` languages. Under these - generators, target-wide flags for both C and C++ sources will be evaluated + generators, expressions for both C and C++ sources will be evaluated using ``CXX`` if there are any C++ sources and otherwise using ``C``. A workaround is to create separate libraries for each source file language instead: @@ -124,20 +138,6 @@ Available logical expressions are: add_executable(myapp main.cpp) target_link_libraries(myapp myapp_c myapp_cxx) - The ``Makefile`` and ``Ninja`` based generators can also use this - expression to specify compile-language specific compile definitions - and include directories: - - .. code-block:: cmake - - add_executable(myapp main.cpp foo.c bar.cpp) - target_compile_definitions(myapp - PRIVATE $<$<COMPILE_LANGUAGE:CXX>:COMPILING_CXX> - ) - target_include_directories(myapp - PRIVATE $<$<COMPILE_LANGUAGE:CXX>:/opt/foo/cxx_headers> - ) - Informational Expressions ========================= diff --git a/Help/release/dev/extend-compile-language-genex.rst b/Help/release/dev/extend-compile-language-genex.rst index 0a0a669..7c09376 100644 --- a/Help/release/dev/extend-compile-language-genex.rst +++ b/Help/release/dev/extend-compile-language-genex.rst @@ -1,7 +1,14 @@ extend-compile-language-genex ----------------------------- -* The ``COMPILE_LANGUAGE`` :manual:`generator expression - <cmake-generator-expressions(7)>` may now be used with - :ref:`Visual Studio Generators` in :prop_tgt:`COMPILE_OPTIONS` - and :command:`file(GENERATE)`. +* :ref:`Visual Studio Generators` learned to support the ``COMPILE_LANGUAGE`` + :manual:`generator expression <cmake-generator-expressions(7)>` in + target-wide :prop_tgt:`COMPILE_DEFINITIONS`, + :prop_tgt:`INCLUDE_DIRECTORIES`, :prop_tgt:`COMPILE_OPTIONS`, and + :command:`file(GENERATE)`. + +* The :generator:`Xcode` generator learned to support the ``COMPILE_LANGUAGE`` + :manual:`generator expression <cmake-generator-expressions(7)>` in + target-wide :prop_tgt:`COMPILE_DEFINITIONS` and + :prop_tgt:`INCLUDE_DIRECTORIES`. It previously supported only + :prop_tgt:`COMPILE_OPTIONS` and :command:`file(GENERATE)`. |