summaryrefslogtreecommitdiffstats
path: root/Help
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-03-10 13:12:34 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2015-03-10 13:12:34 (GMT)
commitad6fbb88bbeb4db17f0f060525c638f0b7b01a33 (patch)
tree042b3405a12e583fc496c7be6cdd2af53af8c323 /Help
parentcce9671b4fea099c5109569108bca2dafe92a97e (diff)
parent232a6883a1fe480def1743af6d711097b98b026e (diff)
downloadCMake-ad6fbb88bbeb4db17f0f060525c638f0b7b01a33.zip
CMake-ad6fbb88bbeb4db17f0f060525c638f0b7b01a33.tar.gz
CMake-ad6fbb88bbeb4db17f0f060525c638f0b7b01a33.tar.bz2
Merge topic 'target-language-genex'
232a6883 Help: Add release notes for target-language-genex. 9e168941 File(GENERATE): Process genex evaluation files for each language. b734fa44 Genex: Allow COMPILE_LANGUAGE when processing include directories. 0b945ea9 Genex: Allow COMPILE_LANGUAGE when processing compile definitions. 5c559f11 Genex: Enable use of COMPILE_LANGUAGE for compile options. e387ce7d Genex: Add a COMPILE_LANGUAGE generator expression. 4a0128f4 VS6: Compute CMAKE_*_FLAGS and COMPILE_DEFINITIONS* only when needed
Diffstat (limited to 'Help')
-rw-r--r--Help/manual/cmake-generator-expressions.7.rst44
-rw-r--r--Help/release/dev/target-language-genex.rst9
2 files changed, 53 insertions, 0 deletions
diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst
index c47a7c4..d38cf7e 100644
--- a/Help/manual/cmake-generator-expressions.7.rst
+++ b/Help/manual/cmake-generator-expressions.7.rst
@@ -93,6 +93,46 @@ Available logical expressions are:
for the 'head' target, an error is reported. See the
:manual:`cmake-compile-features(7)` manual for information on
compile features.
+``$<COMPILE_LANGUAGE:lang>``
+ ``1`` when the language used for compilation unit matches ``lang``,
+ otherwise ``0``. This expression 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):
+
+ .. code-block:: cmake
+
+ add_executable(myapp main.cpp foo.c bar.cpp)
+ target_compile_options(myapp
+ PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>
+ )
+
+ This generator expression has limited use because it is not possible to
+ use it with the Visual Studio generators. Portable buildsystems would
+ not use this expression, and would create separate libraries for each
+ source file language instead:
+
+ .. code-block:: cmake
+
+ add_library(myapp_c foo.c)
+ add_library(myapp_cxx foo.c)
+ target_compile_options(myapp_cxx PUBLIC -fno-exceptions)
+ 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
=========================
@@ -174,6 +214,10 @@ Available informational expressions are:
``$<INSTALL_PREFIX>``
Content of the install prefix when the target is exported via
:command:`install(EXPORT)` and empty otherwise.
+``$<COMPILE_LANGUAGE>``
+ The compile language of source files when evaluating compile options. See
+ the unary version for notes about portability of this generator
+ expression.
Output Expressions
==================
diff --git a/Help/release/dev/target-language-genex.rst b/Help/release/dev/target-language-genex.rst
new file mode 100644
index 0000000..ed4cb5e
--- /dev/null
+++ b/Help/release/dev/target-language-genex.rst
@@ -0,0 +1,9 @@
+target-language-genex
+---------------------
+
+* A new ``COMPILE_LANGUAGE`` generator expression was introduced to
+ allow specification of compile options for target files based on the
+ :prop_sf:`LANGUAGE` of each source file. Due to limitations of the
+ underlying native build tools, this feature has varying support across
+ generators. See the :manual:`cmake-generator-expressions(7)` manual
+ for details.