mirror of
https://github.com/fmtlib/fmt.git
synced 2025-09-25 14:10:55 +02:00
[cmake] fix MASTER_PROJECT heuristic; only enable install if master project (#4536)
SOURCE vs CURRENT_SOURCE is unreliable. `DEFINED PROJECT_NAME` is a much more portable way of determination. Also, installation shouldn't default to on if it is a subproject.
This commit is contained in:
@@ -9,7 +9,9 @@ endif ()
|
|||||||
# or if it is the master project.
|
# or if it is the master project.
|
||||||
if (NOT DEFINED FMT_MASTER_PROJECT)
|
if (NOT DEFINED FMT_MASTER_PROJECT)
|
||||||
set(FMT_MASTER_PROJECT OFF)
|
set(FMT_MASTER_PROJECT OFF)
|
||||||
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
# NOTE: source vs current_source detection is unreliable
|
||||||
|
# this heuristic is more generally applicable esp w.r.t FetchContent
|
||||||
|
if (NOT DEFINED PROJECT_NAME)
|
||||||
set(FMT_MASTER_PROJECT ON)
|
set(FMT_MASTER_PROJECT ON)
|
||||||
message(STATUS "CMake version: ${CMAKE_VERSION}")
|
message(STATUS "CMake version: ${CMAKE_VERSION}")
|
||||||
endif ()
|
endif ()
|
||||||
@@ -161,7 +163,7 @@ option(FMT_WERROR "Halt the compilation with an error on compiler warnings."
|
|||||||
|
|
||||||
# Options that control generation of various targets.
|
# Options that control generation of various targets.
|
||||||
option(FMT_DOC "Generate the doc target." ${FMT_MASTER_PROJECT})
|
option(FMT_DOC "Generate the doc target." ${FMT_MASTER_PROJECT})
|
||||||
option(FMT_INSTALL "Generate the install target." ON)
|
option(FMT_INSTALL "Generate the install target." ${FMT_MASTER_PROJECT})
|
||||||
option(FMT_TEST "Generate the test target." ${FMT_MASTER_PROJECT})
|
option(FMT_TEST "Generate the test target." ${FMT_MASTER_PROJECT})
|
||||||
option(FMT_FUZZ "Generate the fuzz target." OFF)
|
option(FMT_FUZZ "Generate the fuzz target." OFF)
|
||||||
option(FMT_CUDA_TEST "Generate the cuda-test target." OFF)
|
option(FMT_CUDA_TEST "Generate the cuda-test target." OFF)
|
||||||
|
Reference in New Issue
Block a user