summaryrefslogtreecommitdiff
path: root/Tests/FindPackageModeMakefileTest
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2019-10-28 08:25:18 +1100
committerCraig Scott <craig.scott@crascit.com>2019-10-29 07:14:08 +1100
commitc37f4eff5e299212544089f692dc8b090992d7b8 (patch)
treee85ac52452dfc9925b6c8817927bf30253039a66 /Tests/FindPackageModeMakefileTest
parent92eb3a4475e92d993b901c06d967210912390ada (diff)
downloadcmake-c37f4eff5e299212544089f692dc8b090992d7b8.tar.gz
FindPackageModeMakefileTest: macOS needs isysroot flag
macOS/Xcode no longer populate /usr/include. Building with the compiler directly instead of using /usr/bin/c++ can result in missing headers without the -isysroot flag. Relates: #19885
Diffstat (limited to 'Tests/FindPackageModeMakefileTest')
-rw-r--r--Tests/FindPackageModeMakefileTest/CMakeLists.txt8
-rw-r--r--Tests/FindPackageModeMakefileTest/Makefile.in3
2 files changed, 10 insertions, 1 deletions
diff --git a/Tests/FindPackageModeMakefileTest/CMakeLists.txt b/Tests/FindPackageModeMakefileTest/CMakeLists.txt
index 23832dacee..8a87a8c97d 100644
--- a/Tests/FindPackageModeMakefileTest/CMakeLists.txt
+++ b/Tests/FindPackageModeMakefileTest/CMakeLists.txt
@@ -19,6 +19,14 @@ if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Makefile" AND
# configure a FindFoo.cmake so it knows where the library can be found
configure_file(FindFoo.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FindFoo.cmake @ONLY)
+ # Need the -isysroot flag on recentish macOS after command line tools
+ # no longer provide headers in /usr/include
+ if(APPLE AND CMAKE_OSX_SYSROOT)
+ set(__EXTRA_OSX_SYSROOT_FLAGS "-isysroot ${CMAKE_OSX_SYSROOT}")
+ else()
+ set(__EXTRA_OSX_SYSROOT_FLAGS "")
+ endif()
+
# now set up the test:
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/cmakeExecutable.mk"
CONTENT "CMAKE = \"$<TARGET_FILE:cmake>\"\n"
diff --git a/Tests/FindPackageModeMakefileTest/Makefile.in b/Tests/FindPackageModeMakefileTest/Makefile.in
index 8e7ff72aa2..5ef67d031c 100644
--- a/Tests/FindPackageModeMakefileTest/Makefile.in
+++ b/Tests/FindPackageModeMakefileTest/Makefile.in
@@ -5,6 +5,7 @@ CMAKE_CURRENT_BINARY_DIR = "@CMAKE_CURRENT_BINARY_DIR@"
CMAKE_CXX_COMPILER = "@CMAKE_CXX_COMPILER@"
CMAKE_CXX_COMPILER_ID = "@CMAKE_CXX_COMPILER_ID@"
CMAKE_CXX_FLAGS = @CMAKE_CXX_FLAGS@
+__EXTRA_OSX_SYSROOT_FLAGS = @__EXTRA_OSX_SYSROOT_FLAGS@
CMAKE_FOO = $(CMAKE) --find-package -DCMAKE_MODULE_PATH=$(CMAKE_CURRENT_BINARY_DIR) -DNAME=Foo -DLANGUAGE=CXX -DCOMPILER_ID=$(CMAKE_CXX_COMPILER_ID)
@@ -15,7 +16,7 @@ all: pngtest
main.o: clean main.cpp
@$(CMAKE_FOO) -DMODE=COMPILE >$(tmp)
@foo="`cat $(tmp)`"; \
- printf '"%s" %s %s -c main.cpp\n' $(CMAKE_CXX_COMPILER) "$(CMAKE_CXX_FLAGS)" "$$foo" >$(tmp)
+ printf '"%s" %s %s %s -c main.cpp\n' $(CMAKE_CXX_COMPILER) "$(CMAKE_CXX_FLAGS)" "$(__EXTRA_OSX_SYSROOT_FLAGS)" "$$foo" >$(tmp)
@cat $(tmp)
@sh $(tmp)
@rm -f $(tmp)