parent
eefde565b0
commit
550d0a8e15
@ -1,7 +1,6 @@
|
|||||||
CMAKE_CACHEFILE_DIR
|
CMAKE_CACHEFILE_DIR
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
The directory with the ``CMakeCache.txt`` file.
|
This variable is used internally by CMake, and may not be set during
|
||||||
|
the first configuration of a build tree. When it is set, it has the
|
||||||
This is the full path to the directory that has the ``CMakeCache.txt``
|
same value as :variable:`CMAKE_BINARY_DIR`. Use that variable instead.
|
||||||
file in it. This is the same as :variable:`CMAKE_BINARY_DIR`.
|
|
||||||
|
@ -0,0 +1,69 @@
|
|||||||
|
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||||
|
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||||
|
|
||||||
|
|
||||||
|
# Do NOT include this module directly into any of your code. It is used by
|
||||||
|
# the try_compile() implementation to work around a specific issue with
|
||||||
|
# conflicting flags when building for Apple platforms.
|
||||||
|
if(NOT APPLE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
cmake_policy(PUSH)
|
||||||
|
cmake_policy(SET CMP0054 NEW) # if() quoted variables not dereferenced
|
||||||
|
|
||||||
|
function(__cmake_internal_workaround_headerpad_flag_conflict _LANG)
|
||||||
|
|
||||||
|
# Until we can avoid hard-coding -Wl,-headerpad_max_install_names in the
|
||||||
|
# linker flags, we need to remove it here for cases where we know it will
|
||||||
|
# conflict with other flags, generate a warning and be ignored.
|
||||||
|
set(regex "(^| )(-fembed-bitcode(-marker|=(all|bitcode|marker))?|-bundle_bitcode)($| )")
|
||||||
|
set(remove_headerpad NO)
|
||||||
|
|
||||||
|
# Check arbitrary flags that the user or project has set. These compiler
|
||||||
|
# flags get added to the linker command line.
|
||||||
|
if("${CMAKE_${_LANG}_FLAGS}" MATCHES "${regex}")
|
||||||
|
set(remove_headerpad YES)
|
||||||
|
endif()
|
||||||
|
if(NOT remove_headerpad)
|
||||||
|
get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
||||||
|
if(is_multi_config)
|
||||||
|
# Only one of these config-specific variables will be set by try_compile()
|
||||||
|
# and the rest will be unset, but we can't easily tell which one is set.
|
||||||
|
# No harm to just add them all here, empty ones won't add flags to check.
|
||||||
|
foreach(config IN LISTS CMAKE_CONFIGURATION_TYPES)
|
||||||
|
if("${CMAKE_${_LANG}_FLAGS_${config}}" MATCHES "${regex}")
|
||||||
|
set(remove_headerpad YES)
|
||||||
|
break()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
else()
|
||||||
|
if("${CMAKE_${_LANG}_FLAGS_${CMAKE_BUILD_TYPE}}" MATCHES "${regex}")
|
||||||
|
set(remove_headerpad YES)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# The try_compile() command passes compiler flags to check in a way that
|
||||||
|
# results in them being added to add_definitions(). Those don't end up on
|
||||||
|
# the linker command line, so we don't need to check them here.
|
||||||
|
|
||||||
|
if(remove_headerpad)
|
||||||
|
foreach(flag IN ITEMS
|
||||||
|
CMAKE_${_LANG}_LINK_FLAGS
|
||||||
|
CMAKE_SHARED_LIBRARY_CREATE_${_LANG}_FLAGS
|
||||||
|
CMAKE_SHARED_MODULE_CREATE_${_LANG}_FLAGS)
|
||||||
|
string(REPLACE "-Wl,-headerpad_max_install_names" "" ${flag} "${${flag}}")
|
||||||
|
set(${flag} "${${flag}}" PARENT_SCOPE)
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
get_property(__enabled_languages GLOBAL PROPERTY ENABLED_LANGUAGES)
|
||||||
|
foreach(__lang IN LISTS __enabled_languages)
|
||||||
|
__cmake_internal_workaround_headerpad_flag_conflict(${__lang})
|
||||||
|
endforeach()
|
||||||
|
unset(__lang)
|
||||||
|
unset(__enabled_languages)
|
||||||
|
|
||||||
|
cmake_policy(POP)
|
@ -0,0 +1,7 @@
|
|||||||
|
^Not searching for unused variables given on the command line\.
|
||||||
|
Available configure presets:
|
||||||
|
|
||||||
|
"zzzzzz" - Sleepy
|
||||||
|
"aaaaaaaa" - Screaming
|
||||||
|
"mmmmmm"
|
||||||
|
"no-generator"$
|
@ -0,0 +1,18 @@
|
|||||||
|
enable_language(C)
|
||||||
|
|
||||||
|
include(CheckCompilerFlag)
|
||||||
|
|
||||||
|
# Confirm we can check the conflicting flag directly. This should pass with
|
||||||
|
# or without the workaround.
|
||||||
|
check_compiler_flag(C "-fembed-bitcode" result1)
|
||||||
|
if(NOT result1)
|
||||||
|
message(FATAL_ERROR "False negative when -fembed-bitcode tested directly")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Check conflicting flag set by user or project won't cause a false negative
|
||||||
|
# when testing a valid flag. This only passes with the workaround.
|
||||||
|
set(CMAKE_C_FLAGS -fembed-bitcode)
|
||||||
|
check_compiler_flag(C "-O" result2)
|
||||||
|
if(NOT result2)
|
||||||
|
message(FATAL_ERROR "False negative when -fembed-bitcode set in CMAKE_C_FLAGS")
|
||||||
|
endif()
|
@ -0,0 +1,17 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
project(PchIncludedAllLanguages C CXX)
|
||||||
|
|
||||||
|
if(CMAKE_CXX_COMPILE_OPTIONS_USE_PCH)
|
||||||
|
add_definitions(-DHAVE_PCH_SUPPORT)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_executable(main
|
||||||
|
main.cpp
|
||||||
|
empty.c
|
||||||
|
pch-included.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_precompile_headers(main PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/pch.h>)
|
||||||
|
|
||||||
|
enable_testing()
|
||||||
|
add_test(NAME main COMMAND main)
|
@ -0,0 +1,4 @@
|
|||||||
|
^CMake Error at FileSetFramework\.cmake:[0-9]+ \(target_sources\):
|
||||||
|
target_sources FILE_SETs may not be added to FRAMEWORK targets
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
CMakeLists\.txt:[0-9]+ \(include\)$
|
@ -0,0 +1,7 @@
|
|||||||
|
enable_language(C)
|
||||||
|
|
||||||
|
add_library(lib1 SHARED lib1.c)
|
||||||
|
set_property(TARGET lib1 PROPERTY FRAMEWORK ON)
|
||||||
|
target_sources(lib1
|
||||||
|
PUBLIC FILE_SET HEADERS BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} FILES h1.h
|
||||||
|
)
|
@ -1,4 +0,0 @@
|
|||||||
^CMake Error at FileSetNoExistInterface\.cmake:[0-9]+ \(set_property\):
|
|
||||||
Header set "a" has not yet been created\.
|
|
||||||
Call Stack \(most recent call first\):
|
|
||||||
CMakeLists\.txt:[0-9]+ \(include\)$
|
|
@ -1,4 +0,0 @@
|
|||||||
^CMake Error at FileSetNoExistPrivate\.cmake:[0-9]+ \(set_property\):
|
|
||||||
Header set "a" has not yet been created\.
|
|
||||||
Call Stack \(most recent call first\):
|
|
||||||
CMakeLists\.txt:[0-9]+ \(include\)$
|
|
@ -1,7 +0,0 @@
|
|||||||
enable_language(C)
|
|
||||||
|
|
||||||
add_library(lib1 STATIC empty.c)
|
|
||||||
set_property(TARGET lib1 PROPERTY HEADER_SETS "a")
|
|
||||||
|
|
||||||
# Error happens at configure-time, so this doesn't help.
|
|
||||||
target_sources(lib1 PRIVATE FILE_SET a TYPE HEADERS)
|
|
@ -1,4 +0,0 @@
|
|||||||
^CMake Error at FileSetNoScope\.cmake:[0-9]+ \(target_sources\):
|
|
||||||
target_sources File set "a" is not in HEADER_SETS or INTERFACE_HEADER_SETS
|
|
||||||
Call Stack \(most recent call first\):
|
|
||||||
CMakeLists\.txt:[0-9]+ \(include\)$
|
|
@ -1,6 +0,0 @@
|
|||||||
enable_language(C)
|
|
||||||
|
|
||||||
add_library(lib1 STATIC empty.c)
|
|
||||||
target_sources(lib1 PRIVATE FILE_SET a TYPE HEADERS BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} FILES h1.h)
|
|
||||||
set_property(TARGET lib1 PROPERTY HEADER_SETS)
|
|
||||||
target_sources(lib1 PRIVATE FILE_SET a TYPE HEADERS FILES h2.h)
|
|
@ -0,0 +1,5 @@
|
|||||||
|
^CMake Error at FileSetReadOnlyInterface\.cmake:[0-9]+ \(set_property\):
|
||||||
|
INTERFACE_HEADER_SETS property is read-only
|
||||||
|
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
CMakeLists\.txt:[0-9]+ \(include\)$
|
@ -0,0 +1,5 @@
|
|||||||
|
^CMake Error at FileSetReadOnlyPrivate\.cmake:[0-9]+ \(set_property\):
|
||||||
|
HEADER_SETS property is read-only
|
||||||
|
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
CMakeLists\.txt:[0-9]+ \(include\)$
|
@ -0,0 +1,4 @@
|
|||||||
|
enable_language(C)
|
||||||
|
|
||||||
|
add_library(lib1 STATIC empty.c)
|
||||||
|
set_property(TARGET lib1 PROPERTY HEADER_SETS "a")
|
Loading…
Reference in new issue