summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-02-22 13:28:20 (GMT)
committerKitware Robot <kwrobot@kitware.com>2024-02-22 13:28:41 (GMT)
commit6ea634dc332cdb81d5a83e551459a20338d6f9c1 (patch)
tree3048586f6aabf845491bbf6b555dcfb07dbff5d7
parent63600a8ca641563dae8c4a6f19b365392d6a0ed4 (diff)
parentfb14a54a2555f65595f81cd3c702f21b74947926 (diff)
downloadCMake-6ea634dc332cdb81d5a83e551459a20338d6f9c1.zip
CMake-6ea634dc332cdb81d5a83e551459a20338d6f9c1.tar.gz
CMake-6ea634dc332cdb81d5a83e551459a20338d6f9c1.tar.bz2
Merge topic 'doc-BUILD_SHARED_LIBS-top-level' into release-3.29
fb14a54a25 Help: Advise calling option(BUILD_SHARED_LIBS) early enough Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !9280
-rw-r--r--Help/variable/BUILD_SHARED_LIBS.rst9
1 files changed, 9 insertions, 0 deletions
diff --git a/Help/variable/BUILD_SHARED_LIBS.rst b/Help/variable/BUILD_SHARED_LIBS.rst
index dbb08f7..0e80f42 100644
--- a/Help/variable/BUILD_SHARED_LIBS.rst
+++ b/Help/variable/BUILD_SHARED_LIBS.rst
@@ -32,3 +32,12 @@ often create a cache entry for it using the :command:`option` command:
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
This provides a switch that users can control, e.g., with :option:`cmake -D`.
+If adding such an option to the project, do so in the top level
+``CMakeLists.txt`` file, before any :command:`add_library` calls.
+Note that if bringing external dependencies directly into the build, such as
+with :module:`FetchContent` or a direct call to :command:`add_subdirectory`,
+and one of those dependencies has such a call to
+:command:`option(BUILD_SHARED_LIBS ...) <option>`, the top level project must
+also call :command:`option(BUILD_SHARED_LIBS ...) <option>` before bringing in
+its dependencies. Failure to do so can lead to different behavior between the
+first and subsequent CMake runs.