summaryrefslogtreecommitdiffstats
path: root/Tests/CFBundleTest/CMakeLists.txt
blob: 8fd9efdc651e9a927dd51d4ecc0dc5c650cf5988 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#this is adapted from FireBreath (http://www.firebreath.org)

cmake_minimum_required(VERSION 2.8)

project(CFBundleTest)

include(PluginConfig.cmake)

message ("Creating Mac Browser Plugin project ${PROJECT_NAME}")
set(SOURCES
    np_macmain.cpp
    Localized.r
    ${CMAKE_CURRENT_BINARY_DIR}/Info.plist
    ${CMAKE_CURRENT_BINARY_DIR}/InfoPlist.strings
    ${CMAKE_CURRENT_BINARY_DIR}/Localized.rsrc
)

add_library( ${PROJECT_NAME} MODULE
    ${SOURCES}
    )

set (RCFILES ${CMAKE_CURRENT_SOURCE_DIR}/Localized.r)

configure_file(Info.plist.in ${CMAKE_CURRENT_BINARY_DIR}/Info.plist)
configure_file(InfoPlist.strings.in ${CMAKE_CURRENT_BINARY_DIR}/InfoPlist.strings)

# Compile the resource file
find_program(RC_COMPILER Rez NO_DEFAULT_PATHS PATHS /Developer/Tools)
if(NOT RC_COMPILER)
  message(FATAL_ERROR "could not find Rez to build resources from .r file...")
endif()

execute_process(COMMAND
    ${RC_COMPILER} ${RCFILES} -useDF -o ${CMAKE_CURRENT_BINARY_DIR}/Localized.rsrc
    )

set_source_files_properties(
    ${CMAKE_CURRENT_BINARY_DIR}/Localized.rsrc
    PROPERTIES GENERATED 1
    )
# note that for some reason, the makefile and xcode generators use a different
# property to indicate where the Info.plist file is :-/ For that reason, we
# specify it twice so it will work both places
set_target_properties(CFBundleTest PROPERTIES
    BUNDLE 1
    BUNDLE_EXTENSION plugin
    XCODE_ATTRIBUTE_WRAPPER_EXTENSION plugin  #sets the extension to .plugin
    XCODE_ATTRIBUTE_MACH_O_TYPE mh_bundle
    XCODE_ATTRIBUTE_INFOPLIST_FILE ${CMAKE_CURRENT_BINARY_DIR}/Info.plist
    MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_BINARY_DIR}/Info.plist
    LINK_FLAGS "-Wl,-exported_symbols_list,\"${CMAKE_CURRENT_SOURCE_DIR}/ExportList_plugin.txt\"")

set_source_files_properties(
    ${CMAKE_CURRENT_BINARY_DIR}/InfoPlist.strings
    ${CMAKE_CURRENT_BINARY_DIR}/Localized.rsrc
    PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/English.lproj")