summaryrefslogtreecommitdiff
path: root/XMPFilesPlugins/PluginTemplate/build/CMakeLists.txt
blob: d08a99a2e44f8d269d846775086b032935daaf5a (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# =================================================================================================
# ADOBE SYSTEMS INCORPORATED
# Copyright 2020 Adobe Systems Incorporated
# All Rights Reserved
#
# NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms
# of the Adobe license agreement accompanying it.
# =================================================================================================

# ==============================================================================
# define minimum cmake version
# For Android always build with make 3.6
if(ANDROID)
	cmake_minimum_required(VERSION 3.5.2)
else(ANDROID)
	cmake_minimum_required(VERSION 3.15.5)
endif(ANDROID)

SET(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Configurations" FORCE)
# Enable folder grouping of projects in IDEs
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

# ==============================================================================
# This project
# ==============================================================================
set(PRODUCT_NAME PluginTemplate)
set(TARGET_NAME ${PRODUCT_NAME})

if(CMAKE_CL_64)
	project(${TARGET_NAME}64)
    set(BITS 64)
else()
	project(${TARGET_NAME})
    set(BITS 32)
endif()

# ==============================================================================
# Shared config
# ==============================================================================
# setup some values before calling shared config
set(XMP_THIS_PROJECT_RELATIVEPATH "../../..")

include(${CMAKE_CURRENT_SOURCE_DIR}/${XMP_THIS_PROJECT_RELATIVEPATH}/build/XMP_Config.cmake)

# ==============================================================================
# Add or overwite shared config variables
# ==============================================================================
# Windows specific
if(WIN32)
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_WINDOWS")
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_WINDOWS")
	SET(CMAKE_EXE_LINKER_FLAGS /NODEFAULTLIB:LIBCMT)
endif()

# all platform
set(CXX_FLAGS_DEBUG "-D_DEBUG=1 -DDEBUG=1")
set(CXX_FLAGS_RELEASE "-DNDEBUG=1")

# ==============================================================================
# Locations
# ==============================================================================
SetPluginOutputPath()

# ==============================================================================
# For convenience we define the sources as a variable. You can add 
# header files and cpp/c files and CMake will sort them out
# ==============================================================================

AddPluginApiFiles("../../..")

list (APPEND COMMON_SOURCE_FILES ${XMPROOT_DIR}/source/UnicodeConversions.cpp)
list (APPEND COMMON_SOURCE_FILES ${XMPROOT_DIR}/source/PerfUtils.cpp)
list (APPEND COMMON_SOURCE_FILES ${XMPROOT_DIR}/source/XMP_ProgressTracker.cpp)
if(UNIX)
	list(APPEND COMMON_SOURCE_FILES ${XMPROOT_DIR}/source/Host_IO-POSIX.cpp)
else()
	list(APPEND COMMON_SOURCE_FILES ${XMPROOT_DIR}/source/Host_IO-Win.cpp)
endif()
source_group("Source Files\\common" FILES ${COMMON_SOURCE_FILES})

list(APPEND SOURCE_FILES
	${SOURCE_ROOT}/Template_Handler.cpp
	)
source_group("Source Files" FILES ${SOURCE_FILES})

# resources
AddPluginResourceFiles()

# merge list elements
list(APPEND SOURCE_FILES ${API_INCLUDE_FILES} ${API_SOURCE_FILES} ${COMMON_SOURCE_FILES} ${SOURCE_FILES} ${RESOURCE_FILES})

# include directories
include_directories(
	${XMPROOT_DIR}
	${XMPROOT_DIR}/public/include
)
if(UNIX)
	if(APPLE)
		set(XMPCORE_LIB "XMPCoreStatic")
	else(APPLE)
		set(XMPCORE_LIB "staticXMPCore")
	endif(APPLE)
else(UNIX)
	if(WIN32)
		set(XMPCORE_LIB "XMPCoreStatic")
	endif(WIN32)
endif(UNIX)
#setting up XMP_BUILDMODE_DIR variable
SetupInternalBuildDirectory()
#link directories
link_directories(${XMPROOT_DIR}/public/libraries/${XMP_PLATFORM_FOLDER})
# ==============================================================================
# Define what to do, lib, exe, etc
set(DEPENDENCY_LIST "LIB:$(XMPCORE_LIB)")
AddLibraryAndDependencies("${TARGET_NAME}" "${XMP_BUILD_STATIC}" "YES" "SHARED" "SOURCE_FILES" "DEPENDENCY_LIST")
# ==============================================================================
# Link dependencies

if(WIN32)
	target_link_libraries(
		${TARGET_NAME}
		${XMPCORE_LIB}
		${XMP_PLATFORM_LINK}
	)
else(WIN32)
	if(UNIX AND NOT APPLE)
		target_link_libraries(
			${TARGET_NAME}
			${XMPROOT_DIR}/public/libraries/${XMP_PLATFORM_FOLDER}/${XMP_BUILDMODE_DIR}/${XMPCORE_LIB}.ar 
			${XMP_PLATFORM_LINK}
		)
	else(UNIX AND NOT APPLE)
		target_link_libraries(
			${TARGET_NAME}
			${XMPCORE_LIB}
		)
	endif()
endif()

set(FRAMEWORK_LIST "Mac:CoreFoundation" "Mac:Foundation" "Mac:CoreServices"  "Mac:${XMP_PLATFORM_LINK}")
AddMacFramework(${TARGET_NAME} FRAMEWORK_LIST)


SetWinLinkFlags(${TARGET_NAME} "" "${TARGET_NAME}")

if(APPLE)
	set_target_properties(${TARGET_NAME} PROPERTIES BUILD_WITH_INSTALL_RPATH ON BUILD_WITH_INSTALL_NAME_DIR ON INSTALL_NAME_DIR "@executable_path/../Frameworks")
endif()

set(DEPEND_LIBS "")
CreatePlugin(${TARGET_NAME} ${XMPPLUGIN_OUTPUT_DIR} "${PROJECT_ROOT}/resource/txt/*.txt" XMP_PLUGIN_DEPENDENCIES DEPEND_LIBS)

# ==============================================================================
# Post build
# ==============================================================================

if (UNIX)
	if(APPLE)
		add_custom_command (TARGET ${TARGET_NAME} POST_BUILD 
			COMMAND cp -f ${PROJECT_ROOT}/resource/txt/MODULE_IDENTIFIER.txt ${XMPPLUGIN_OUTPUT_DIR}/${TARGET_NAME}.xpi/Versions/A/Resources/MODULE_IDENTIFIER.txt
			COMMAND cp -f ${PROJECT_ROOT}/resource/txt/XMPPLUGINUIDS-${BITS}.txt ${XMPPLUGIN_OUTPUT_DIR}/${TARGET_NAME}.xpi/Versions/A/Resources/XMPPLUGINUIDS.txt
			COMMENT "Copy resource")
	else()
		if((${CMAKE_BUILD_TYPE} MATCHES "Debug") OR (${CMAKE_BUILD_TYPE} MATCHES "debug") )
			add_custom_command (TARGET ${TARGET_NAME}
				POST_BUILD
				COMMAND ls -l ${XMPPLUGIN_OUTPUT_DIR}/${TARGET_NAME}.xpi
			)
		else()
			add_custom_command (TARGET ${TARGET_NAME}
				POST_BUILD
				COMMAND strip ${XMPPLUGIN_OUTPUT_DIR}/${TARGET_NAME}.xpi
				COMMAND ls -l ${XMPPLUGIN_OUTPUT_DIR}/${TARGET_NAME}.xpi
			)
		endif()
		add_custom_command (TARGET ${TARGET_NAME} POST_BUILD 
			COMMAND mkdir -p ${XMPPLUGIN_OUTPUT_DIR}/${TARGET_NAME}.resources
			COMMAND cp -f ${PROJECT_ROOT}/resource/txt/MODULE_IDENTIFIER.txt ${XMPPLUGIN_OUTPUT_DIR}/${TARGET_NAME}.resources/MODULE_IDENTIFIER.txt
			COMMAND cp -f ${PROJECT_ROOT}/resource/txt/XMPPLUGINUIDS-${BITS}.txt ${XMPPLUGIN_OUTPUT_DIR}/${TARGET_NAME}.resources/XMPPLUGINUIDS.txt
			COMMENT "Copy resource")
	endif()
endif()

#disable cmake warning "Manually-specified variables were not used by the project"
set(ignore "${XMP_CMAKEFOLDER_NAME}") 

# ==============================================================================
# configuration feedback
# ==============================================================================

message (STATUS "===========================================================================")
message (STATUS " ${TARGET_NAME}		")
message (STATUS "===========================================================================")