summaryrefslogtreecommitdiffstats
path: root/Help/command/enable_language.rst
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2024-03-30 03:48:50 (GMT)
committerCraig Scott <craig.scott@crascit.com>2024-04-02 12:00:38 (GMT)
commit97464aa9701cc4bebb6d0a44c0201c3476489c3e (patch)
tree5fbbc4104613762d7903702b40b68e18d8c77443 /Help/command/enable_language.rst
parentd166e7d740bfb53c18221f1126e984b668923208 (diff)
downloadCMake-97464aa9701cc4bebb6d0a44c0201c3476489c3e.zip
CMake-97464aa9701cc4bebb6d0a44c0201c3476489c3e.tar.gz
CMake-97464aa9701cc4bebb6d0a44c0201c3476489c3e.tar.bz2
enable_language(): Fail if called before project()
Fixes: #25550
Diffstat (limited to 'Help/command/enable_language.rst')
-rw-r--r--Help/command/enable_language.rst16
1 files changed, 10 insertions, 6 deletions
diff --git a/Help/command/enable_language.rst b/Help/command/enable_language.rst
index 2f1cc23..d587310 100644
--- a/Help/command/enable_language.rst
+++ b/Help/command/enable_language.rst
@@ -9,15 +9,19 @@ Enable languages (CXX/C/OBJC/OBJCXX/Fortran/etc)
Enables support for the named languages in CMake. This is the same as
the :command:`project` command but does not create any of the extra
-variables that are created by the project command.
+variables that are created by the :command:`project` command.
.. include:: SUPPORTED_LANGUAGES.txt
-This command must be called in file scope, not in a function call.
-Furthermore, it must be called in the highest directory common to all
-targets using the named language directly for compiling sources or
-indirectly through link dependencies. It is simplest to enable all
-needed languages in the top-level directory of a project.
+The following restrictions apply to where ``enable_language()`` may be called:
+
+* It must be called in file scope, not in a function call.
+* It must not be called before the first call to :command:`project`.
+ See policy :policy:`CMP0165`.
+* It must be called in the highest directory common to all targets
+ using the named language directly for compiling sources or
+ indirectly through link dependencies. It is simplest to enable all
+ needed languages in the top-level directory of a project.
The ``OPTIONAL`` keyword is a placeholder for future implementation and
does not currently work. Instead you can use the :module:`CheckLanguage`