diff options
author | Brad King <brad.king@kitware.com> | 2024-04-03 13:38:36 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2024-04-03 13:38:46 (GMT) |
commit | 7fde84352701a80500e5dcafae9cac32f9f5d437 (patch) | |
tree | 5e4495e9cc1ffd0c6e30a5b619dc0488dfc5fc17 /Help | |
parent | bf116544b3545188535b2bab4c2dbaf9153041d7 (diff) | |
parent | 97464aa9701cc4bebb6d0a44c0201c3476489c3e (diff) | |
download | CMake-7fde84352701a80500e5dcafae9cac32f9f5d437.zip CMake-7fde84352701a80500e5dcafae9cac32f9f5d437.tar.gz CMake-7fde84352701a80500e5dcafae9cac32f9f5d437.tar.bz2 |
Merge topic 'enable_language-before-project'
97464aa970 enable_language(): Fail if called before project()
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !9396
Diffstat (limited to 'Help')
-rw-r--r-- | Help/command/enable_language.rst | 16 | ||||
-rw-r--r-- | Help/manual/cmake-policies.7.rst | 1 | ||||
-rw-r--r-- | Help/policy/CMP0165.rst | 26 | ||||
-rw-r--r-- | Help/release/dev/enable_language-before-project.rst | 6 |
4 files changed, 43 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` diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index d874363..51b4ce6 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -57,6 +57,7 @@ Policies Introduced by CMake 3.30 .. toctree:: :maxdepth: 1 + CMP0165: enable_language() must not be called before project(). </policy/CMP0165> CMP0164: add_library() rejects SHARED libraries when not supported by the platform. </policy/CMP0164> CMP0163: The GENERATED source file property is now visible in all directories. </policy/CMP0163> CMP0162: Visual Studio generators add UseDebugLibraries indicators by default. </policy/CMP0162> diff --git a/Help/policy/CMP0165.rst b/Help/policy/CMP0165.rst new file mode 100644 index 0000000..7a79c44 --- /dev/null +++ b/Help/policy/CMP0165.rst @@ -0,0 +1,26 @@ +CMP0165 +------- + +.. versionadded:: 3.30 + +:command:`enable_language` must not be called before :command:`project`. + +In CMake 3.29 and below, if a project called :command:`enable_language` +before the first call to :command:`project`, the language would be enabled +but possibly using unset details that were expected to be set. +In CMake 3.30 and above, :command:`enable_language` prefers to reject this +case and stop with a fatal error instead if it detects that :command:`project` +has not yet been called. This policy provides compatibility for projects that +happened to work when :command:`enable_language` was called before +:command:`project` and have not been updated to call these commands in the +required order. + +The ``OLD`` behavior for this policy is to allow :command:`enable_language` +to be called before :command:`project`. The ``NEW`` behavior for this policy +is to fail with a fatal error in such cases. + +.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.30 +.. |WARNS_OR_DOES_NOT_WARN| replace:: warns +.. include:: STANDARD_ADVICE.txt + +.. include:: DEPRECATED.txt diff --git a/Help/release/dev/enable_language-before-project.rst b/Help/release/dev/enable_language-before-project.rst new file mode 100644 index 0000000..2b1fd1d --- /dev/null +++ b/Help/release/dev/enable_language-before-project.rst @@ -0,0 +1,6 @@ +enable_language-before-project +------------------------------ + +* The :command:`enable_language` command now fails with an error + if it is called before the first :command:`project` call. + See policy :policy:`CMP0165`. |