diff options
author | Gusts Kaksis <gusts.kaksis@sonarworks.com> | 2020-09-28 18:16:52 (GMT) |
---|---|---|
committer | Craig Scott <craig.scott@crascit.com> | 2020-10-02 12:13:00 (GMT) |
commit | ce2dee9e5bae37c8117087bb83add075c3c123b4 (patch) | |
tree | 51a3e6d9194afd96bbc2e6dbbe9b8a9fd3e7057a /Tests/RunCMake/XcodeProject | |
parent | 468bcc3291ac3f325b401046b2465d634d8e3947 (diff) | |
download | CMake-ce2dee9e5bae37c8117087bb83add075c3c123b4.zip CMake-ce2dee9e5bae37c8117087bb83add075c3c123b4.tar.gz CMake-ce2dee9e5bae37c8117087bb83add075c3c123b4.tar.bz2 |
Xcode: Don't add framework as -framework argument in linker info list
Diffstat (limited to 'Tests/RunCMake/XcodeProject')
5 files changed, 58 insertions, 11 deletions
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() |