Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Tests / BundleTest / CMakeLists.txt
blob5ccf2bf85d4f33eed3ca98b159eb20c8f7e25576
1 cmake_minimum_required (VERSION 2.6)
2 PROJECT(BundleTest)
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 ADD_CUSTOM_COMMAND(
7   OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/randomResourceFile.plist"
8   COMMAND /bin/cp
9   ARGS "${CMAKE_CURRENT_SOURCE_DIR}/randomResourceFile.plist.in"
10   "${CMAKE_CURRENT_BINARY_DIR}/randomResourceFile.plist")
12 SET_SOURCE_FILES_PROPERTIES(
13   "${CMAKE_CURRENT_BINARY_DIR}/randomResourceFile.plist"
14   PROPERTIES
15   MACOSX_PACKAGE_LOCATION Resources
16   )
18 SET_SOURCE_FILES_PROPERTIES(
19   SomeRandomFile.txt
20   "${BundleTest_SOURCE_DIR}/../../ChangeLog.txt"
21   PROPERTIES
22   MACOSX_PACKAGE_LOCATION MacOS
23   )
25 SET(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}/foobar")
27 # Test building a bundle linking to a shared library where the
28 # shared library links to Carbon, but the executable does not
29 # explicitly link to Carbon, but the executable does *depend*
30 # on Carbon. There should be a link failure for the executable
31 # if CMake's dependency chaining for libraries with "-framework
32 # blah" style dependencies gets broken...
34 ADD_LIBRARY(BundleTestLib SHARED BundleLib.cxx)
35 TARGET_LINK_LIBRARIES(BundleTestLib "-framework Carbon")
37 ADD_EXECUTABLE(BundleTest
38   MACOSX_BUNDLE
39   BundleTest.cxx
40   SomeRandomFile.txt
41   "${BundleTest_SOURCE_DIR}/../../ChangeLog.txt"
42   "${CMAKE_CURRENT_BINARY_DIR}/randomResourceFile.plist"
43   )
44 TARGET_LINK_LIBRARIES(BundleTest BundleTestLib)
46 # DO NOT: TARGET_LINK_LIBRARIES(BundleTest "-framework Carbon")
47 #   (see above comments about Carbon)
50 # Test bundle installation.
51 #INSTALL(TARGETS BundleTestLib DESTINATION Applications/BundleTestExe.app/Contents/Plugins)
52 INSTALL(TARGETS BundleTestLib DESTINATION Applications/SecondBundleExe.app/Contents/Plugins)
53 INSTALL(TARGETS BundleTest DESTINATION Applications)
55 # Test whether bundles respect the output name.  Since the library is
56 # installed into a location that uses this output name this will fail if the
57 # bundle does not respect the name.  Also the executable will not be found by
58 # the test driver if this does not work.
59 SET_TARGET_PROPERTIES(BundleTest PROPERTIES OUTPUT_NAME BundleTestExe)
61 # Test executable versioning if it is supported.
62 IF(NOT XCODE)
63   SET_TARGET_PROPERTIES(BundleTest PROPERTIES VERSION 1)
64 ENDIF(NOT XCODE)
66 # Make sure the executable can find its installed library.
67 SET_TARGET_PROPERTIES(BundleTestLib PROPERTIES
68   INSTALL_NAME_DIR "@executable_path/../Plugins")
70 INCLUDE(CPack)
72 # test the framework find stuff
73 IF(EXISTS /usr/lib/libtcl.dylib
74     AND EXISTS /System/Library/Frameworks/Tcl.framework)
75   SET(TCL NOTFOUND)
76   FIND_LIBRARY(TCL tcl)
77   MESSAGE("frame: ${TCL}")
78   IF(NOT "${TCL}" MATCHES .framework)
79     MESSAGE(FATAL_ERROR "Could not find tcl framework, found ${TCL}")
80   ENDIF(NOT "${TCL}" MATCHES .framework)
81   SET(TCL NOTFOUND)
82   SET(CMAKE_FIND_FRAMEWORK LAST)
83   FIND_LIBRARY(TCL tcl)
84   IF("${TCL}" MATCHES .framework)
85     MESSAGE(FATAL_ERROR "Found framework and should have found dylib ${TCL}")
86   ENDIF("${TCL}" MATCHES .framework)
87   SET(TCL NOTFOUND)
88   SET(CMAKE_FIND_FRAMEWORK NEVER)
89   FIND_LIBRARY(TCL tcl)
90   IF("${TCL}" MATCHES .framework)
91     MESSAGE(FATAL_ERROR "Found framework and should have found dylib ${TCL}")
92   ENDIF("${TCL}" MATCHES .framework)
93   MESSAGE("not frame: ${TCL}")
94   SET(TCL NOTFOUND)
95   SET(CMAKE_FIND_FRAMEWORK FIRST)
96   FIND_LIBRARY(TCL tcl)
97   IF(NOT "${TCL}" MATCHES .framework)
98     MESSAGE(FATAL_ERROR "Could not find tcl framework, found ${TCL}")
99   ENDIF(NOT "${TCL}" MATCHES .framework)
100   MESSAGE("frame: ${TCL}")
101 ENDIF(EXISTS /usr/lib/libtcl.dylib
102   AND EXISTS /System/Library/Frameworks/Tcl.framework)
104 SUBDIRS(BundleSubDir)