summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Modules/FetchContent.cmake6
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/cmComputeLinkInformation.cxx16
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx10
-rw-r--r--Tests/RunCMake/FetchContent/ManualSourceDirectory.cmake8
-rw-r--r--Tests/RunCMake/FetchContent/ManualSourceDirectoryMissing-result.txt1
-rw-r--r--Tests/RunCMake/FetchContent/ManualSourceDirectoryMissing-stderr.txt2
-rw-r--r--Tests/RunCMake/FetchContent/ManualSourceDirectoryMissing.cmake8
-rw-r--r--Tests/RunCMake/FetchContent/RunCMakeTest.cmake7
-rw-r--r--Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase.cmake55
-rw-r--r--Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_BUILT_ONLY-check.cmake4
-rw-r--r--Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_Funcs.cmake2
-rw-r--r--Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_KNOWN_LOCATION-check.cmake4
-rw-r--r--Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_NONE-check.cmake4
14 files changed, 111 insertions, 18 deletions
diff --git a/Modules/FetchContent.cmake b/Modules/FetchContent.cmake
index acf2a94..40cc362 100644
--- a/Modules/FetchContent.cmake
+++ b/Modules/FetchContent.cmake
@@ -1052,6 +1052,12 @@ function(FetchContent_Populate contentName)
# The source directory has been explicitly provided in the cache,
# so no population is required. The build directory may still be specified
# by the declared details though.
+
+ if(NOT EXISTS "${FETCHCONTENT_SOURCE_DIR_${contentNameUpper}}")
+ message(FATAL_ERROR "Manually specified source directory is missing:\n"
+ " FETCHCONTENT_SOURCE_DIR_${contentNameUpper} --> ${FETCHCONTENT_SOURCE_DIR_${contentNameUpper}}")
+ endif()
+
set(${contentNameLower}_SOURCE_DIR "${FETCHCONTENT_SOURCE_DIR_${contentNameUpper}}")
cmake_parse_arguments(savedDetails "" "BINARY_DIR" "" ${contentDetails})
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 0b18af6..f6d6305 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,7 +1,7 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 18)
-set(CMake_VERSION_PATCH 20201004)
+set(CMake_VERSION_PATCH 20201005)
#set(CMake_VERSION_RC 0)
set(CMake_VERSION_IS_DIRTY 0)
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index 4a331fb..201a9d9 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -1293,11 +1293,17 @@ void cmComputeLinkInformation::AddFrameworkItem(std::string const& item)
// add runtime information
this->AddLibraryRuntimeInfo(full_fw);
- // Add the item using the -framework option.
- this->Items.emplace_back(std::string("-framework"), false);
- cmOutputConverter converter(this->Makefile->GetStateSnapshot());
- fw = converter.EscapeForShell(fw);
- this->Items.emplace_back(fw, false);
+ if (this->GlobalGenerator->IsXcode()) {
+ // Add framework path - it will be handled by Xcode after it's added to
+ // "Link Binary With Libraries" build phase
+ this->Items.emplace_back(item, true);
+ } else {
+ // Add the item using the -framework option.
+ this->Items.emplace_back(std::string("-framework"), false);
+ cmOutputConverter converter(this->Makefile->GetStateSnapshot());
+ fw = converter.EscapeForShell(fw);
+ this->Items.emplace_back(fw, false);
+ }
}
void cmComputeLinkInformation::AddDirectoryItem(std::string const& item)
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index acae2b6..f1a1ce6 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -3579,8 +3579,16 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
for (auto const& libItem : configItemMap[configName]) {
auto const& libName = *libItem;
if (libName.IsPath) {
- libPaths.Add(this->XCodeEscapePath(libName.Value.Value));
const auto libPath = GetLibraryOrFrameworkPath(libName.Value.Value);
+ if (cmSystemTools::StringEndsWith(libPath.c_str(), ".framework")) {
+ const auto fwName =
+ cmSystemTools::GetFilenameWithoutExtension(libPath);
+ const auto fwDir = cmSystemTools::GetParentDirectory(libPath);
+ libPaths.Add("-F " + this->XCodeEscapePath(fwDir));
+ libPaths.Add("-framework " + fwName);
+ } else {
+ libPaths.Add(this->XCodeEscapePath(libName.Value.Value));
+ }
if ((!libName.Target || libName.Target->IsImported()) &&
IsLinkPhaseLibraryExtension(libPath)) {
// Create file reference for embedding
diff --git a/Tests/RunCMake/FetchContent/ManualSourceDirectory.cmake b/Tests/RunCMake/FetchContent/ManualSourceDirectory.cmake
new file mode 100644
index 0000000..83fcc4b
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/ManualSourceDirectory.cmake
@@ -0,0 +1,8 @@
+include(FetchContent)
+
+FetchContent_Declare(
+ WithProject
+ SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/ADirThatDoesNotExist
+)
+
+FetchContent_MakeAvailable(WithProject)
diff --git a/Tests/RunCMake/FetchContent/ManualSourceDirectoryMissing-result.txt b/Tests/RunCMake/FetchContent/ManualSourceDirectoryMissing-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/ManualSourceDirectoryMissing-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/FetchContent/ManualSourceDirectoryMissing-stderr.txt b/Tests/RunCMake/FetchContent/ManualSourceDirectoryMissing-stderr.txt
new file mode 100644
index 0000000..7ecb06b
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/ManualSourceDirectoryMissing-stderr.txt
@@ -0,0 +1,2 @@
+ *Manually specified source directory is missing:
++ *FETCHCONTENT_SOURCE_DIR_WITHPROJECT --> .*/ADirThatDoesNotExist
diff --git a/Tests/RunCMake/FetchContent/ManualSourceDirectoryMissing.cmake b/Tests/RunCMake/FetchContent/ManualSourceDirectoryMissing.cmake
new file mode 100644
index 0000000..0e24c1a
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/ManualSourceDirectoryMissing.cmake
@@ -0,0 +1,8 @@
+include(FetchContent)
+
+FetchContent_Declare(
+ WithProject
+ SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/WithProject
+)
+
+FetchContent_MakeAvailable(WithProject)
diff --git a/Tests/RunCMake/FetchContent/RunCMakeTest.cmake b/Tests/RunCMake/FetchContent/RunCMakeTest.cmake
index ad9e48e..3eb331f 100644
--- a/Tests/RunCMake/FetchContent/RunCMakeTest.cmake
+++ b/Tests/RunCMake/FetchContent/RunCMakeTest.cmake
@@ -15,6 +15,13 @@ run_cmake(MakeAvailable)
run_cmake(MakeAvailableTwice)
run_cmake(MakeAvailableUndeclared)
+run_cmake_with_options(ManualSourceDirectory
+ -D "FETCHCONTENT_SOURCE_DIR_WITHPROJECT=${CMAKE_CURRENT_LIST_DIR}/WithProject"
+)
+run_cmake_with_options(ManualSourceDirectoryMissing
+ -D "FETCHCONTENT_SOURCE_DIR_WITHPROJECT=${CMAKE_CURRENT_LIST_DIR}/ADirThatDoesNotExist"
+)
+
function(run_FetchContent_DirOverrides)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/DirOverrides-build)
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
diff --git a/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase.cmake b/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase.cmake
index 22a181f..7abc58b 100644
--- a/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase.cmake
+++ b/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase.cmake
@@ -9,16 +9,28 @@ int func2();
int func3();
int func4();
int func5();
+int func6();
+int func7();
+]])
+set(prototypes_objc [[
+#import <CoreFoundation/CoreFoundation.h>
]])
set(impl [[
{
printf("%p %p\n", compress, res_close);
- return func1() + func2() + func3() + func4() + func5();
+ return func1() + func2() + func3() + func4() + func5() + func6() + func7();
+}
+]])
+set(impl_objc [[
+{
+ CFStringRef cfStr = CFSTR("This is a string");
+ printf("%p %p %ld\n", compress, res_close, (long)CFStringGetLength(cfStr));
+ return func1() + func2() + func3() + func4() + func5() + func6() + func7();
}
]])
-file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/mainOuter.c
- "${prototypes}\nint main(int argc, char** argv) ${impl}"
+file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/mainOuter.m
+ "${prototypes}\n${prototypes_objc}\nint main(int argc, char** argv) ${impl_objc}"
)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/funcOuter.c
@@ -31,7 +43,28 @@ foreach(i RANGE 1 5)
)
endforeach()
-add_executable(app1 mainOuter.c)
+file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/ExternalFrameworks/CMakeLists.txt
+[[
+cmake_minimum_required(VERSION 3.18)
+project(ExternalFrameworks)
+add_library(staticFrameworkExt STATIC func6.c)
+add_library(sharedFrameworkExt SHARED func7.c)
+set_target_properties(staticFrameworkExt PROPERTIES FRAMEWORK TRUE)
+set_target_properties(sharedFrameworkExt PROPERTIES FRAMEWORK TRUE)
+]]
+)
+
+foreach(i RANGE 6 7)
+ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/ExternalFrameworks/func${i}.c
+ "int func${i}() { return 32 + ${i}; }\n"
+ )
+endforeach()
+
+add_custom_target(prebuildDependencies ALL
+ COMMAND ${CMAKE_COMMAND} -S ${CMAKE_CURRENT_BINARY_DIR}/ExternalFrameworks -B ${CMAKE_CURRENT_BINARY_DIR}/ExternalFrameworks/build -G Xcode
+ COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/ExternalFrameworks/build --target staticFrameworkExt sharedFrameworkExt --config Debug
+)
+add_executable(app1 mainOuter.m)
add_library(static1 STATIC funcOuter.c)
add_library(shared1 SHARED funcOuter.c)
add_library(module1 MODULE funcOuter.c)
@@ -40,6 +73,13 @@ add_library(staticFramework1 STATIC funcOuter.c)
add_library(sharedFramework1 SHARED funcOuter.c)
set_target_properties(staticFramework1 PROPERTIES FRAMEWORK TRUE)
set_target_properties(sharedFramework1 PROPERTIES FRAMEWORK TRUE)
+add_dependencies(app1 prebuildDependencies)
+add_dependencies(static1 prebuildDependencies)
+add_dependencies(shared1 prebuildDependencies)
+add_dependencies(module1 prebuildDependencies)
+add_dependencies(obj1 prebuildDependencies)
+add_dependencies(staticFramework1 prebuildDependencies)
+add_dependencies(sharedFramework1 prebuildDependencies)
add_library(static2 STATIC func1.c)
add_library(shared2 SHARED func2.c)
@@ -49,9 +89,10 @@ add_library(sharedFramework2 SHARED func5.c)
set_target_properties(staticFramework2 PROPERTIES FRAMEWORK TRUE)
set_target_properties(sharedFramework2 PROPERTIES FRAMEWORK TRUE)
-# Pick a couple of libraries that are always present in the Xcode SDK
+# Pick some external libraries that are always present in the Xcode SDK
find_library(libz z REQUIRED)
find_library(libresolv resolv REQUIRED)
+find_library(CoreFoundation CoreFoundation REQUIRED)
add_library(imported2 UNKNOWN IMPORTED)
set_target_properties(imported2 PROPERTIES IMPORTED_LOCATION ${libz})
@@ -59,6 +100,7 @@ set_target_properties(imported2 PROPERTIES IMPORTED_LOCATION ${libz})
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/foundLibs.cmake "
set(libz \"${libz}\")
set(libresolv \"${libresolv}\")
+set(CoreFoundation \"${CoreFoundation}\")
")
set(mainTargets
@@ -78,6 +120,9 @@ set(linkToThings
sharedFramework2
imported2
${libresolv}
+ ${CoreFoundation}
+ "${CMAKE_CURRENT_BINARY_DIR}/ExternalFrameworks/build/Debug/sharedFrameworkExt.framework"
+ "${CMAKE_CURRENT_BINARY_DIR}/ExternalFrameworks/build/Debug/staticFrameworkExt.framework"
)
foreach(mainTarget IN LISTS mainTargets)
diff --git a/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_BUILT_ONLY-check.cmake b/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_BUILT_ONLY-check.cmake
index 2b7edf5..d07a25b 100644
--- a/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_BUILT_ONLY-check.cmake
+++ b/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_BUILT_ONLY-check.cmake
@@ -6,7 +6,7 @@ include(${RunCMake_TEST_BINARY_DIR}/foundLibs.cmake)
foreach(mainTarget IN ITEMS app1 shared1 module1 sharedFramework1)
checkFlags(OTHER_LDFLAGS ${mainTarget}
- "obj2;${libz};${libresolv}"
+ "obj2;${libz};${libresolv};CoreFoundation;sharedFrameworkExt;staticFrameworkExt"
"static2;shared2;staticFramework2;sharedFramework2"
)
endforeach()
@@ -14,6 +14,6 @@ endforeach()
foreach(mainTarget IN ITEMS static1 staticFramework1)
checkFlags(OTHER_LIBTOOLFLAGS ${mainTarget}
"obj2"
- "static2;shared2;staticFramework2;sharedFramework2;${libz};${libresolv}"
+ "static2;shared2;staticFramework2;sharedFramework2;${libz};${libresolv};CoreFoundation;sharedFrameworkExt;staticFrameworkExt"
)
endforeach()
diff --git a/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_Funcs.cmake b/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_Funcs.cmake
index 601e52f..e72bf4d 100644
--- a/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_Funcs.cmake
+++ b/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_Funcs.cmake
@@ -1,3 +1,5 @@
+cmake_minimum_required(VERSION 3.18...3.19)
+
macro(returnOnError errorMsg)
if(NOT "${errorMsg}" STREQUAL "")
set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}\n${errorMsg}" PARENT_SCOPE)
diff --git a/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_KNOWN_LOCATION-check.cmake b/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_KNOWN_LOCATION-check.cmake
index b0d2f7f..e1484e7 100644
--- a/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_KNOWN_LOCATION-check.cmake
+++ b/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_KNOWN_LOCATION-check.cmake
@@ -7,13 +7,13 @@ include(${RunCMake_TEST_BINARY_DIR}/foundLibs.cmake)
foreach(mainTarget IN ITEMS app1 shared1 module1 sharedFramework1)
checkFlags(OTHER_LDFLAGS ${mainTarget}
"obj2"
- "static2;shared2;staticFramework2;sharedFramework2;${libz};${libresolv}"
+ "static2;shared2;staticFramework2;sharedFramework2;${libz};${libresolv};CoreFoundation;sharedFrameworkExt;staticFrameworkExt"
)
endforeach()
foreach(mainTarget IN ITEMS static1 staticFramework1)
checkFlags(OTHER_LIBTOOLFLAGS ${mainTarget}
"obj2"
- "static2;shared2;staticFramework2;sharedFramework2;${libz};${libresolv}"
+ "static2;shared2;staticFramework2;sharedFramework2;${libz};${libresolv};CoreFoundation;sharedFrameworkExt;staticFrameworkExt"
)
endforeach()
diff --git a/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_NONE-check.cmake b/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_NONE-check.cmake
index 3074881..2601676 100644
--- a/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_NONE-check.cmake
+++ b/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_NONE-check.cmake
@@ -6,7 +6,7 @@ include(${RunCMake_TEST_BINARY_DIR}/foundLibs.cmake)
foreach(mainTarget IN ITEMS app1 shared1 module1 sharedFramework1)
checkFlags(OTHER_LDFLAGS ${mainTarget}
- "static2;shared2;staticFramework2;sharedFramework2;obj2;${libz};${libresolv}"
+ "static2;shared2;staticFramework2;sharedFramework2;obj2;${libz};${libresolv};CoreFoundation;sharedFrameworkExt;staticFrameworkExt"
""
)
endforeach()
@@ -14,6 +14,6 @@ endforeach()
foreach(mainTarget IN ITEMS static1 staticFramework1)
checkFlags(OTHER_LIBTOOLFLAGS ${mainTarget}
"obj2"
- "static2;shared2;staticFramework2;sharedFramework2;${libz};${libresolv}"
+ "static2;shared2;staticFramework2;sharedFramework2;${libz};${libresolv};CoreFoundation;sharedFrameworkExt;staticFrameworkExt"
)
endforeach()