FreeRDP/client/Mac/CMakeLists.txt

183 lines
7.6 KiB
CMake
Raw Normal View History

2013-08-08 23:49:24 +04:00
project(MacFreeRDP-library)
2012-10-19 07:10:45 +04:00
if(${CMAKE_VERSION} GREATER 2.8.12)
cmake_policy(SET CMP0026 OLD)
cmake_policy(SET CMP0045 OLD)
endif()
set(MODULE_NAME "MacFreeRDP-library")
2013-06-23 08:18:55 +04:00
set(MODULE_OUTPUT_NAME "MacFreeRDP")
2013-08-08 23:49:24 +04:00
set(MODULE_PREFIX "FREERDP_CLIENT_MAC_LIBRARY")
2013-03-11 08:35:15 +04:00
2012-10-19 07:10:45 +04:00
find_library(FOUNDATION_LIBRARY Foundation)
find_library(COCOA_LIBRARY Cocoa)
find_library(APPKIT_LIBRARY AppKit)
find_library(IOKIT_LIBRARY IOKit)
2012-11-01 07:30:52 +04:00
2013-05-31 22:57:48 +04:00
mark_as_advanced(COCOA_LIBRARY FOUNDATION_LIBRARY APPKIT_LIBRARY)
set(EXTRA_LIBS ${COCOA_LIBRARY} ${FOUNDATION_LIBRARY} ${APPKIT_LIBRARY} ${IOKIT_LIBRARY})
2013-05-31 22:57:48 +04:00
2013-06-23 08:18:55 +04:00
set(MACOSX_BUNDLE_INFO_STRING "${MODULE_OUTPUT_NAME}")
2012-10-19 07:10:45 +04:00
set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.freerdp.mac")
set(MACOSX_BUNDLE_BUNDLE_IDENTIFIER "FreeRDP-library.Mac")
set(MACOSX_BUNDLE_LONG_VERSION_STRING "MacFreeRDP library Version 1.1")
2013-06-23 08:18:55 +04:00
set(MACOSX_BUNDLE_BUNDLE_NAME "${MODULE_OUTPUT_NAME}")
set(MACOSX_BUNDLE_SHORT_VERSION_STRING 1.1.0)
set(MACOSX_BUNDLE_BUNDLE_VERSION 1.1.0)
set(MACOSX_BUNDLE_COPYRIGHT "Copyright 2013. All Rights Reserved.")
2013-03-11 08:35:15 +04:00
2013-08-08 23:49:24 +04:00
set(${MODULE_PREFIX}_XIBS PasswordDialog.xib)
set(${MODULE_PREFIX}_SOURCES "")
set(${MODULE_PREFIX}_OBJECTIVE_SOURCES
main.m
mf_client.m
MRDPCursor.m
MRDPView.m
Keyboard.m
Clipboard.m
2013-08-08 23:49:24 +04:00
PasswordDialog.m)
2013-04-12 02:09:28 +04:00
2013-08-08 23:49:24 +04:00
list(APPEND ${MODULE_PREFIX}_SOURCES ${${MODULE_PREFIX}_OBJECTIVE_SOURCES})
2013-04-12 02:09:28 +04:00
2013-08-08 23:49:24 +04:00
set(${MODULE_PREFIX}_HEADERS
mfreerdp.h
mf_client.h
MRDPCursor.h
MRDPView.h
Keyboard.h
Clipboard.h
2013-08-08 23:49:24 +04:00
PasswordDialog.h)
2013-08-08 23:49:24 +04:00
set(${MODULE_PREFIX}_RESOURCES "en.lproj/InfoPlist.strings")
# Include XIB file in Xcode resources.
if("${CMAKE_GENERATOR}" MATCHES "Xcode")
message(STATUS "Adding Xcode XIB resources for ${MODULE_NAME}")
2013-08-08 23:49:24 +04:00
set(${MODULE_PREFIX}_RESOURCES ${${MODULE_PREFIX}_RESOURCES} ${${MODULE_PREFIX}_XIBS})
2013-06-23 08:18:55 +04:00
endif()
2013-04-12 02:09:28 +04:00
add_library(${MODULE_NAME}
SHARED
2013-06-14 00:18:19 +04:00
../common/client.c
2013-08-08 23:49:24 +04:00
${${MODULE_PREFIX}_SOURCES}
${${MODULE_PREFIX}_HEADERS}
${${MODULE_PREFIX}_RESOURCES})
2013-06-23 08:18:55 +04:00
set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "${MODULE_OUTPUT_NAME}")
# configures the framework to always be looked for in the application bundle in the Frameworks sub-folder.
2013-08-08 23:49:24 +04:00
set_target_properties(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_INSTALL_PATH @executable_path/../Frameworks/)
2013-05-31 22:57:48 +04:00
set_target_properties(${MODULE_NAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${EXECUTABLE_OUTPUT_PATH}
2013-05-31 21:51:50 +04:00
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${EXECUTABLE_OUTPUT_PATH})
set_target_properties(${MODULE_NAME} PROPERTIES
FRAMEWORK TRUE
MACOSX_FRAMEWORK_IDENTIFIER com.awakecoding.${MODULE_NAME}
FRAMEWORK_VERSION 1.1.0
MACOSX_FRAMEWORK_SHORT_VERSION_STRING 1.1.0
MACOSX_FRAMEWORK_BUNDLE_BUNDLE_VERSION 1.1.0
INSTALL_NAME_DIR "@executable_path/../Frameworks"
2013-05-31 21:51:50 +04:00
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_BINARY_DIR}/Info.plist
BUILD_WITH_INSTALL_RPATH 1)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${EXTRA_LIBS} freerdp-client)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr freerdp)
2012-11-01 07:30:52 +04:00
2012-10-19 07:10:45 +04:00
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
2013-05-31 22:57:48 +04:00
# Set a list of the dependent targets used by the application. There should be a way to get this list automatically
# from cmake, but for now I put it down manually. I got the references by calling "otool -L MacFreeRDP-client"
set(DEPENDENCIES "")
foreach(LIB ${${MODULE_PREFIX}_LIBS})
get_target_property(LOCATION ${LIB} LOCATION)
if(NOT ${LOCATION} MATCHES ".*-NOTFOUND")
list(APPEND DEPENDENCIES ${LIB})
endif()
endforeach()
2013-03-11 08:35:15 +04:00
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Client/Mac")
if (${BUILD_SHARED_LIBS})
# Add a post-build event to copy the dependent libraries in the framework bundle
# Call install_name_tool to reassign the library install name
foreach(LIB ${DEPENDENCIES})
# message("adding post-build dependency: ${LIB}")
add_custom_command(TARGET ${MODULE_NAME} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy
"$<TARGET_FILE:${LIB}>"
"${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_OUTPUT_NAME}.framework/Contents/$<TARGET_FILE_NAME:${LIB}>"
COMMENT "Copying ${LIB} to output directory"
2013-06-23 08:18:55 +04:00
COMMAND install_name_tool -change "$<TARGET_SONAME_FILE:${LIB}>"
"@executable_path/../Frameworks/${MODULE_OUTPUT_NAME}.framework/Contents/$<TARGET_FILE_NAME:${LIB}>"
2016-08-14 04:27:19 +03:00
"${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_OUTPUT_NAME}.framework/${MODULE_OUTPUT_NAME}"
COMMENT Setting install name for ${LIB}
2013-06-23 08:18:55 +04:00
COMMAND "${CMAKE_COMMAND}" -E echo install_name_tool -change "$<TARGET_SONAME_FILE:${LIB}>"
"@executable_path/../Frameworks/${MODULE_OUTPUT_NAME}.framework/Contents/$<TARGET_FILE_NAME:${LIB}>"
2016-08-14 04:27:19 +03:00
"${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_OUTPUT_NAME}.framework/${MODULE_OUTPUT_NAME}")
endforeach()
# Call install_name_tool to reassign the library install names in dependent libraries
foreach(DEST ${DEPENDENCIES})
2013-06-23 08:18:55 +04:00
foreach(LIB ${DEPENDENCIES})
# message("adding post-build dependency: ${LIB}")
add_custom_command(TARGET ${MODULE_NAME} POST_BUILD
COMMAND install_name_tool -change "$<TARGET_SONAME_FILE:${LIB}>"
"@executable_path/../Frameworks/${MODULE_OUTPUT_NAME}.framework/Contents/$<TARGET_FILE_NAME:${LIB}>"
"${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_OUTPUT_NAME}.framework/Contents/$<TARGET_FILE_NAME:${DEST}>"
2013-06-23 08:18:55 +04:00
COMMENT Setting install name for ${LIB} in module ${DEST})
endforeach()
endforeach()
endif()
# Add post-build NIB file generation in unix makefiles. XCode handles this implicitly.
# if("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles")
message(STATUS "Adding post-build NIB file generation event for ${MODULE_NAME}")
# Make sure we can find the 'ibtool' program. If we can NOT find it we
# skip generation of this project
find_program(IBTOOL ibtool HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin")
if (${IBTOOL} STREQUAL "IBTOOL-NOTFOUND")
2013-06-23 08:18:55 +04:00
message(SEND_ERROR "ibtool can not be found and is needed to compile the .xib files. It should have been installed with
the Apple developer tools. The default system paths were searched in addition to ${OSX_DEVELOPER_ROOT}/usr/bin")
endif()
# Make sure the 'Resources' Directory is correctly created before we build
2013-06-23 08:18:55 +04:00
add_custom_command(TARGET ${MODULE_NAME} PRE_BUILD
COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_OUTPUT_NAME}.framework/Versions/${MACOSX_BUNDLE_SHORT_VERSION_STRING}/Resources)
# Compile the .xib files using the 'ibtool' program with the destination being the app package
foreach(xib ${${MODULE_PREFIX}_XIBS})
get_filename_component(XIB_WE ${xib} NAME_WE)
add_custom_command (TARGET ${MODULE_NAME} POST_BUILD
COMMAND ${IBTOOL} --errors --warnings --notices --output-format human-readable-text
2013-08-10 05:23:08 +04:00
--compile ${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_OUTPUT_NAME}.framework/Versions/${MACOSX_BUNDLE_SHORT_VERSION_STRING}/Resources/${XIB_WE}.nib ${CMAKE_CURRENT_SOURCE_DIR}/${xib}
COMMENT "Compiling ${xib}")
endforeach()
# endif()
2013-06-15 00:19:03 +04:00
# Copy the public header files into the framework
2013-08-08 23:49:24 +04:00
foreach(HEADER ${${MODULE_PREFIX}_HEADERS})
2013-06-23 08:18:55 +04:00
# message("adding post-build dependency: ${LIB}")
add_custom_command(TARGET ${MODULE_NAME} POST_BUILD
2013-08-09 00:38:50 +04:00
COMMAND ditto ${CMAKE_CURRENT_SOURCE_DIR}/${HEADER} ${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_OUTPUT_NAME}.framework/Headers/
2013-06-23 08:18:55 +04:00
COMMENT Copying public header files to ${MODULE_NAME})
2013-06-15 00:19:03 +04:00
endforeach()
2013-06-15 00:19:03 +04:00
# Copy the FreeRDP header files into the framework
add_custom_command(TARGET ${MODULE_NAME} POST_BUILD
COMMAND ditto ${CMAKE_SOURCE_DIR}/include/freerdp ${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_OUTPUT_NAME}.framework/Headers/freerdp
COMMAND ditto ${CMAKE_SOURCE_DIR}/winpr/include/winpr ${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_OUTPUT_NAME}.framework/Headers/winpr
2013-06-23 08:18:55 +04:00
COMMENT Copying FreeRDP header files to ${MODULE_NAME})
2013-06-23 08:18:55 +04:00
add_subdirectory(cli)