2008-03-25 18:27:18 +03:00
|
|
|
cmake_minimum_required (VERSION 2.6)
|
2012-08-13 21:47:32 +04:00
|
|
|
project(BundleTest)
|
|
|
|
set(MACOSX_BUNDLE_INFO_STRING "bundle_info_string")
|
|
|
|
set(CMAKE_MacOSX_Content_COMPILE_OBJECT "\"${CMAKE_COMMAND}\" -E copy_if_different <SOURCE> <OBJECT>")
|
2006-03-28 17:54:01 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
add_custom_command(
|
2006-03-28 17:54:01 +04:00
|
|
|
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/randomResourceFile.plist"
|
|
|
|
COMMAND /bin/cp
|
|
|
|
ARGS "${CMAKE_CURRENT_SOURCE_DIR}/randomResourceFile.plist.in"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/randomResourceFile.plist")
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set_source_files_properties(
|
2006-03-28 17:54:01 +04:00
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/randomResourceFile.plist"
|
|
|
|
PROPERTIES
|
|
|
|
MACOSX_PACKAGE_LOCATION Resources
|
|
|
|
)
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set_source_files_properties(
|
2006-03-28 17:54:01 +04:00
|
|
|
SomeRandomFile.txt
|
2008-08-27 20:53:19 +04:00
|
|
|
"${BundleTest_SOURCE_DIR}/../../ChangeLog.txt"
|
2006-03-28 17:54:01 +04:00
|
|
|
PROPERTIES
|
|
|
|
MACOSX_PACKAGE_LOCATION MacOS
|
|
|
|
)
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}/foobar")
|
2006-03-03 20:58:48 +03:00
|
|
|
|
2008-09-02 19:07:04 +04:00
|
|
|
# Test building a bundle linking to a shared library where the
|
2010-08-18 00:11:33 +04:00
|
|
|
# shared library links to CoreFoundation, but the executable does not
|
|
|
|
# explicitly link to CoreFoundation, but the executable does *depend*
|
|
|
|
# on CoreFoundation. There should be a link failure for the executable
|
2008-09-02 19:07:04 +04:00
|
|
|
# if CMake's dependency chaining for libraries with "-framework
|
|
|
|
# blah" style dependencies gets broken...
|
|
|
|
#
|
2012-08-13 21:47:32 +04:00
|
|
|
add_library(BundleTestLib SHARED BundleLib.cxx)
|
|
|
|
target_link_libraries(BundleTestLib "-framework CoreFoundation")
|
2008-09-02 19:07:04 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
add_executable(BundleTest
|
2006-03-28 17:54:01 +04:00
|
|
|
MACOSX_BUNDLE
|
|
|
|
BundleTest.cxx
|
|
|
|
SomeRandomFile.txt
|
2008-08-27 20:53:19 +04:00
|
|
|
"${BundleTest_SOURCE_DIR}/../../ChangeLog.txt"
|
2006-03-28 17:54:01 +04:00
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/randomResourceFile.plist"
|
|
|
|
)
|
2012-08-13 21:47:32 +04:00
|
|
|
target_link_libraries(BundleTest BundleTestLib)
|
2008-09-02 19:07:04 +04:00
|
|
|
#
|
2012-08-13 21:47:32 +04:00
|
|
|
# DO NOT: target_link_libraries(BundleTest "-framework CoreFoundation")
|
2010-08-18 00:11:33 +04:00
|
|
|
# (see above comments about CoreFoundation)
|
2008-09-02 19:07:04 +04:00
|
|
|
#
|
2006-03-03 20:58:48 +03:00
|
|
|
|
|
|
|
# Test bundle installation.
|
2012-08-13 21:47:32 +04:00
|
|
|
#install(TARGETS BundleTestLib DESTINATION Applications/BundleTestExe.app/Contents/Plugins)
|
|
|
|
install(TARGETS BundleTestLib DESTINATION Applications/SecondBundleExe.app/Contents/Plugins)
|
|
|
|
install(TARGETS BundleTest DESTINATION Applications)
|
2006-03-03 20:58:48 +03:00
|
|
|
|
|
|
|
# Test whether bundles respect the output name. Since the library is
|
|
|
|
# installed into a location that uses this output name this will fail if the
|
|
|
|
# bundle does not respect the name. Also the executable will not be found by
|
|
|
|
# the test driver if this does not work.
|
2012-08-13 21:47:32 +04:00
|
|
|
set_target_properties(BundleTest PROPERTIES OUTPUT_NAME BundleTestExe)
|
2006-03-03 20:58:48 +03:00
|
|
|
|
|
|
|
# Test executable versioning if it is supported.
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT XCODE)
|
|
|
|
set_target_properties(BundleTest PROPERTIES VERSION 1)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2005-07-13 23:43:40 +04:00
|
|
|
|
2006-03-03 20:58:48 +03:00
|
|
|
# Make sure the executable can find its installed library.
|
2012-08-13 21:47:32 +04:00
|
|
|
set_target_properties(BundleTestLib PROPERTIES
|
2006-03-03 20:58:48 +03:00
|
|
|
INSTALL_NAME_DIR "@executable_path/../Plugins")
|
2006-03-10 18:12:26 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
include(CPack)
|
2006-03-10 18:12:26 +03:00
|
|
|
|
2006-03-29 22:33:49 +04:00
|
|
|
# test the framework find stuff
|
2012-08-13 21:47:32 +04:00
|
|
|
if(EXISTS /usr/lib/libtcl.dylib
|
2007-08-24 21:30:41 +04:00
|
|
|
AND EXISTS /System/Library/Frameworks/Tcl.framework)
|
2012-08-13 21:47:32 +04:00
|
|
|
set(TCL NOTFOUND)
|
|
|
|
find_library(TCL tcl)
|
|
|
|
message("frame: ${TCL}")
|
|
|
|
if(NOT "${TCL}" MATCHES .framework)
|
|
|
|
message(FATAL_ERROR "Could not find tcl framework, found ${TCL}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
set(TCL NOTFOUND)
|
|
|
|
set(CMAKE_FIND_FRAMEWORK LAST)
|
|
|
|
find_library(TCL tcl)
|
|
|
|
if("${TCL}" MATCHES .framework)
|
|
|
|
message(FATAL_ERROR "Found framework and should have found dylib ${TCL}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
set(TCL NOTFOUND)
|
|
|
|
set(CMAKE_FIND_FRAMEWORK NEVER)
|
|
|
|
find_library(TCL tcl)
|
|
|
|
if("${TCL}" MATCHES .framework)
|
|
|
|
message(FATAL_ERROR "Found framework and should have found dylib ${TCL}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
message("not frame: ${TCL}")
|
|
|
|
set(TCL NOTFOUND)
|
|
|
|
set(CMAKE_FIND_FRAMEWORK FIRST)
|
|
|
|
find_library(TCL tcl)
|
|
|
|
if(NOT "${TCL}" MATCHES .framework)
|
|
|
|
message(FATAL_ERROR "Could not find tcl framework, found ${TCL}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
message("frame: ${TCL}")
|
|
|
|
endif(EXISTS /usr/lib/libtcl.dylib
|
2007-08-24 21:30:41 +04:00
|
|
|
AND EXISTS /System/Library/Frameworks/Tcl.framework)
|
2006-07-07 00:05:54 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
subdirs(BundleSubDir)
|