summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/target_link_libraries-LINK_LIBRARY
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2022-02-10 22:57:14 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2022-02-15 09:53:33 (GMT)
commita2cfa2da4f53a5e9c78e6cf7332c6a308ef38af2 (patch)
tree28ddbbd9f07ad92b87fbe439c2ead74041c74f44 /Tests/RunCMake/target_link_libraries-LINK_LIBRARY
parent40178f3c908795a993148553a04be25748942efc (diff)
downloadCMake-a2cfa2da4f53a5e9c78e6cf7332c6a308ef38af2.zip
CMake-a2cfa2da4f53a5e9c78e6cf7332c6a308ef38af2.tar.gz
CMake-a2cfa2da4f53a5e9c78e6cf7332c6a308ef38af2.tar.bz2
GenEx/LINK_LIBRARY: Add features for framework support on Apple
Diffstat (limited to 'Tests/RunCMake/target_link_libraries-LINK_LIBRARY')
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/RunCMakeTest.cmake18
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/apple_framework.cmake61
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/foo.h9
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/foo.mm7
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/main.mm14
5 files changed, 109 insertions, 0 deletions
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/RunCMakeTest.cmake
index 9ebbdb7..9582e11 100644
--- a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/RunCMakeTest.cmake
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/RunCMakeTest.cmake
@@ -79,3 +79,21 @@ if ((RunCMake_GENERATOR MATCHES "Makefiles|Ninja|Xcode"
unset(RunCMake_TEST_OUTPUT_MERGE)
endif()
+
+# Apple framework features
+if(APPLE AND (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang"))
+ run_cmake(apple_framework)
+ run_cmake_target(apple_framework framework main-framework)
+ run_cmake_target(apple_framework reexport_framework main-reexport_framework)
+ run_cmake_target(apple_framework weak_framework main-weak_framework)
+
+ run_cmake_target(apple_framework target-framework main-target-framework)
+ run_cmake_target(apple_framework target-reexport_framework main-target-reexport_framework)
+ run_cmake_target(apple_framework target-weak_framework main-target-weak_framework)
+endif()
+
+if (CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND CMAKE_C_COMPILER_VERSION GREATER_EQUAL "12")
+ run_cmake_target(apple_framework needed_framework main-needed_framework)
+
+ run_cmake_target(apple_framework target-needed_framework main-target-needed_framework)
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/apple_framework.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/apple_framework.cmake
new file mode 100644
index 0000000..e9a93e9
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/apple_framework.cmake
@@ -0,0 +1,61 @@
+
+enable_language(OBJCXX)
+
+
+# feature FRAMEWORK
+add_library(foo-framework SHARED foo.mm)
+target_link_libraries(foo-framework PRIVATE "$<LINK_LIBRARY:FRAMEWORK,Foundation>")
+
+add_executable(main-framework main.mm)
+target_link_libraries(main-framework PRIVATE "$<LINK_LIBRARY:FRAMEWORK,Foundation>" foo-framework)
+
+
+# feature NEEDED_FRAMEWORK
+add_library(foo-needed_framework SHARED foo.mm)
+target_link_libraries(foo-needed_framework PRIVATE "$<LINK_LIBRARY:NEEDED_FRAMEWORK,Foundation>")
+
+add_executable(main-needed_framework main.mm)
+target_link_libraries(main-needed_framework PRIVATE "$<LINK_LIBRARY:FRAMEWORK,Foundation>" foo-needed_framework)
+
+
+# feature REEXPORT_FRAMEWORK
+add_library(foo-reexport_framework SHARED foo.mm)
+target_link_libraries(foo-reexport_framework PRIVATE "$<LINK_LIBRARY:REEXPORT_FRAMEWORK,Foundation>")
+
+add_executable(main-reexport_framework main.mm)
+target_link_libraries(main-reexport_framework PRIVATE "$<LINK_LIBRARY:FRAMEWORK,Foundation>" foo-reexport_framework)
+
+
+# feature WEAK_FRAMEWORK
+add_library(foo-weak_framework SHARED foo.mm)
+target_link_libraries(foo-weak_framework PRIVATE "$<LINK_LIBRARY:WEAK_FRAMEWORK,Foundation>")
+
+add_executable(main-weak_framework main.mm)
+target_link_libraries(main-weak_framework PRIVATE "$<LINK_LIBRARY:FRAMEWORK,Foundation>" foo-weak_framework)
+
+
+##
+## Consumption of target specified as FRAMEWORK
+add_library(target-framework SHARED foo.mm)
+set_target_properties(target-framework PROPERTIES FRAMEWORK TRUE)
+target_link_libraries(target-framework PRIVATE "$<LINK_LIBRARY:FRAMEWORK,Foundation>")
+
+
+# feature FRAMEWORK
+add_executable(main-target-framework main.mm)
+target_link_libraries(main-target-framework PRIVATE "$<LINK_LIBRARY:FRAMEWORK,Foundation>" "$<LINK_LIBRARY:FRAMEWORK,target-framework>")
+
+
+# feature NEEDED_FRAMEWORK
+add_executable(main-target-needed_framework main.mm)
+target_link_libraries(main-target-needed_framework PRIVATE "$<LINK_LIBRARY:FRAMEWORK,Foundation>" "$<LINK_LIBRARY:NEEDED_FRAMEWORK,target-framework>")
+
+
+# feature REEXPORT_FRAMEWORK
+add_executable(main-target-reexport_framework main.mm)
+target_link_libraries(main-target-reexport_framework PRIVATE "$<LINK_LIBRARY:FRAMEWORK,Foundation>" "$<LINK_LIBRARY:REEXPORT_FRAMEWORK,target-framework>")
+
+
+# feature WEAK_FRAMEWORK
+add_executable(main-target-weak_framework main.mm)
+target_link_libraries(main-target-weak_framework PRIVATE "$<LINK_LIBRARY:FRAMEWORK,Foundation>" "$<LINK_LIBRARY:REEXPORT_FRAMEWORK,target-framework>")
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/foo.h b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/foo.h
new file mode 100644
index 0000000..b3fb084
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/foo.h
@@ -0,0 +1,9 @@
+#import <Foundation/Foundation.h>
+
+@interface Foo : NSObject {
+ NSNumber* age;
+}
+
+@property (nonatomic, retain) NSNumber* age;
+
+@end
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/foo.mm b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/foo.mm
new file mode 100644
index 0000000..2d452a8
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/foo.mm
@@ -0,0 +1,7 @@
+#import "foo.h"
+
+@implementation Foo
+
+@synthesize age;
+
+@end
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/main.mm b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/main.mm
new file mode 100644
index 0000000..7c85551
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/main.mm
@@ -0,0 +1,14 @@
+#import <Foundation/Foundation.h>
+#import "foo.h"
+#include <iostream>
+
+int main(int argc, char **argv)
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ Foo *theFoo = [[Foo alloc] init];
+ theFoo.age = [NSNumber numberWithInt:argc];
+ NSLog(@"%d\n",[theFoo.age intValue]);
+ std::cout << [theFoo.age intValue] << std::endl;
+ [pool release];
+ return 0;
+}