1 cmake_minimum_required (VERSION 2.6)
3 set(MACOSX_BUNDLE_INFO_STRING "bundle_info_string")
4 set(CMAKE_MacOSX_Content_COMPILE_OBJECT "\"${CMAKE_COMMAND}\" -E copy_if_different <SOURCE> <OBJECT>")
6 if(CMAKE_GENERATOR STREQUAL "Xcode" AND
7 "${CMAKE_SYSTEM_NAME};${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Darwin;arm64")
8 # Tell Xcode to pretend the linker signed binaries so that
9 # editing with install_name_tool preserves ad-hoc signatures.
10 # See CMake Issue 21854.
11 # This option is supported by codesign on macOS 11 or higher.
12 set(CMAKE_XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS "-o linker-signed")
16 OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/randomResourceFile.plist"
18 ARGS "${CMAKE_CURRENT_SOURCE_DIR}/randomResourceFile.plist.in"
19 "${CMAKE_CURRENT_BINARY_DIR}/randomResourceFile.plist")
21 set_source_files_properties(
22 "${CMAKE_CURRENT_BINARY_DIR}/randomResourceFile.plist"
24 MACOSX_PACKAGE_LOCATION Resources
27 set_source_files_properties(
29 "${BundleTest_SOURCE_DIR}/../../README.rst"
31 MACOSX_PACKAGE_LOCATION Other
34 set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}/foobar")
36 # Test building a bundle linking to a shared library where the
37 # shared library links to CoreFoundation, but the executable does not
38 # explicitly link to CoreFoundation, but the executable does *depend*
39 # on CoreFoundation. There should be a link failure for the executable
40 # if CMake's dependency chaining for libraries with "-framework
41 # blah" style dependencies gets broken...
43 add_library(BundleTestLib SHARED BundleLib.cxx)
44 target_link_libraries(BundleTestLib "-framework CoreFoundation")
46 add_executable(BundleTest
50 "${BundleTest_SOURCE_DIR}/../../README.rst"
51 "${CMAKE_CURRENT_BINARY_DIR}/randomResourceFile.plist"
53 target_link_libraries(BundleTest BundleTestLib)
55 # DO NOT: target_link_libraries(BundleTest "-framework CoreFoundation")
56 # (see above comments about CoreFoundation)
59 # Test bundle installation.
60 #install(TARGETS BundleTestLib DESTINATION Applications/BundleTestExe.app/Contents/Plugins)
61 install(TARGETS BundleTestLib DESTINATION Applications/SecondBundleExe.app/Contents/Plugins)
62 install(TARGETS BundleTest DESTINATION Applications)
64 # Test whether bundles respect the output name. Since the library is
65 # installed into a location that uses this output name this will fail if the
66 # bundle does not respect the name. Also the executable will not be found by
67 # the test driver if this does not work.
68 set_target_properties(BundleTest PROPERTIES OUTPUT_NAME BundleTestExe)
70 # Test executable versioning if it is supported.
72 set_target_properties(BundleTest PROPERTIES VERSION 1)
75 # Make sure the executable can find its installed library.
76 set_target_properties(BundleTestLib PROPERTIES
77 INSTALL_NAME_DIR "@executable_path/../Plugins")
81 # test the framework find stuff
82 if(EXISTS /usr/lib/libtcl.dylib
83 AND EXISTS /System/Library/Frameworks/Tcl.framework)
86 message("frame: ${TCL}")
87 if(NOT "${TCL}" MATCHES .framework)
88 message(FATAL_ERROR "Could not find tcl framework, found ${TCL}")
91 set(CMAKE_FIND_FRAMEWORK LAST)
93 if("${TCL}" MATCHES .framework)
94 message(FATAL_ERROR "Found framework and should have found dylib ${TCL}")
97 set(CMAKE_FIND_FRAMEWORK NEVER)
99 if("${TCL}" MATCHES .framework)
100 message(FATAL_ERROR "Found framework and should have found dylib ${TCL}")
102 message("not frame: ${TCL}")
104 set(CMAKE_FIND_FRAMEWORK FIRST)
105 find_library(TCL tcl)
106 if(NOT "${TCL}" MATCHES .framework)
107 message(FATAL_ERROR "Could not find tcl framework, found ${TCL}")
109 message("frame: ${TCL}")
110 endif(EXISTS /usr/lib/libtcl.dylib
111 AND EXISTS /System/Library/Frameworks/Tcl.framework)
113 subdirs(BundleSubDir)