FetchContent_Declare() is sensible to the position of the SYSTEM argument
Hi
I am using cmake 3.25.1.
The following CMakeLists.txt
works perfectly:
cmake_minimum_required(VERSION 3.25)
project(cmake_system)
include(FetchContent)
FetchContent_Declare(
fmt
SYSTEM TRUE
GIT_TAG 9.1.0
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
)
FetchContent_MakeAvailable(fmt)
But if I make a little change:
FetchContent_Declare(
fmt
GIT_TAG 9.1.0
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
SYSTEM TRUE # the position of this parameter has changed
)
I then get an error:
CMake Error at C:/Program Files/CMake/share/cmake-3.25/Modules/FetchContent.cmake:1616 (message):
Build step for fmt failed: 1
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.25/Modules/FetchContent.cmake:1756:EVAL:2 (__FetchContent_directPopulate)
C:/Program Files/CMake/share/cmake-3.25/Modules/FetchContent.cmake:1756 (cmake_language)
C:/Program Files/CMake/share/cmake-3.25/Modules/FetchContent.cmake:1970 (FetchContent_Populate)
CMakeLists.txt:13 (FetchContent_MakeAvailable)
I would assume both calls to FetchContent_Declare()
to work the same, especially when the documentation shows the SYSTEM argument at the end:
FetchContent_Declare(
<name>
<contentOptions>...
[SYSTEM]
[OVERRIDE_FIND_PACKAGE |
FIND_PACKAGE_ARGS args...]
)
If this a bug in the code or did I fail to read the doc correctly?
Edited by Bktero