FreeRDP/client/Mac/CMakeLists.txt

175 lines
7.6 KiB
CMake
Raw Normal View History

project(MacFreeRDP-library)
2012-10-19 07:10:45 +04:00
set(MODULE_NAME "MacFreeRDP-library")
2013-06-23 08:18:55 +04:00
set(MODULE_OUTPUT_NAME "MacFreeRDP")
set(MODULE_PREFIX "FREERDP_CLIENT_MAC-LIB")
2013-03-11 08:35:15 +04:00
2013-05-31 22:57:48 +04:00
# Import frameworks
2012-10-19 07:10:45 +04:00
find_library(FOUNDATION_LIBRARY Foundation)
find_library(COCOA_LIBRARY Cocoa)
find_library(APPKIT_LIBRARY AppKit)
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})
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
set(${MODULE_NAME}_RESOURCES "en.lproj/InfoPlist.strings")
2013-04-12 02:09:28 +04:00
# OS X Interface Builder files
file(GLOB ${MODULE_NAME}_XIBS *.xib)
2013-04-12 02:09:28 +04:00
# source files
file(GLOB ${MODULE_NAME}_SRC *.c *.m)
# header files
file(GLOB ${MODULE_NAME}_HEADERS *.h)
# Include XIB file in Xcode resources.
if("${CMAKE_GENERATOR}" MATCHES "Xcode")
message(STATUS "Adding Xcode XIB resources for ${MODULE_NAME}")
set(${MODULE_NAME}_RESOURCES ${${MODULE_NAME}_RESOURCES} ${${MODULE_NAME}_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
${${MODULE_NAME}_SRC}
2013-06-23 02:38:35 +04:00
${${MODULE_NAME}_HEADERS}
2013-03-11 08:35:15 +04:00
${${MODULE_NAME}_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-05-31 21:51:50 +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})
# Support for automatic reference counting requires non-fragile abi.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fobjc-nonfragile-abi")
2013-03-11 08:35:15 +04:00
set_target_properties(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_ARCHS "$(NATIVE_ARCH_ACTUAL)")
set(MODULE_VERSION, 1.1.0)
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_VERSION 1.1.0
2013-05-31 21:51:50 +04:00
INSTALL_NAME_DIR "@executable_path/../../Frameworks"
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)
2012-10-19 07:10:45 +04:00
set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS MONOLITHIC ${MONOLITHIC_BUILD}
MODULE freerdp
2013-01-19 02:32:58 +04:00
MODULES freerdp-core freerdp-cache freerdp-gdi freerdp-codec freerdp-primitives freerdp-rail freerdp-utils)
2012-10-19 07:10:45 +04:00
2012-11-01 07:30:52 +04:00
set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS MONOLITHIC ${MONOLITHIC_BUILD}
MODULE winpr
2013-03-11 08:35:15 +04:00
MODULES winpr-input winpr-crt winpr-utils)
2012-11-01 07:30:52 +04:00
set_target_properties(${MODULE_NAME} PROPERTIES LINK_INTERFACE_LIBRARIES "")
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}>"
"${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_OUTPUT_NAME}.framework/${MODULE_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}>"
"${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_OUTPUT_NAME}.framework/${MODULE_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_NAME}_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
--compile ${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_OUTPUT_NAME}.framework/Versions/${MACOSX_BUNDLE_SHORT_VERSION_STRING}/Resources/${XIB_WE}.nib ${xib}
COMMENT "Compiling ${xib}")
endforeach()
2013-06-15 00:19:03 +04:00
endif()
2013-06-15 00:19:03 +04:00
# Copy the public header files into the framework
foreach(HEADER ${${MODULE_NAME}_HEADERS})
2013-06-23 08:18:55 +04:00
# message("adding post-build dependency: ${LIB}")
add_custom_command(TARGET ${MODULE_NAME} POST_BUILD
COMMAND ditto ${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
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)