diff --git a/.gitignore b/.gitignore index 00fb8eddc..73c0bf88c 100644 --- a/.gitignore +++ b/.gitignore @@ -39,10 +39,12 @@ Debug *.dylib cunit/test_freerdp client/X11/xfreerdp +client/Mac/xcode client/test/freerdp-test client/DirectFB/dfreerdp server/test/tfreerdp-server server/X11/xfreerdp-server +xcode # Other *~ diff --git a/client/Mac/CMakeLists.txt b/client/Mac/CMakeLists.txt index 3a6f477d3..870a65950 100644 --- a/client/Mac/CMakeLists.txt +++ b/client/Mac/CMakeLists.txt @@ -18,7 +18,7 @@ include(FindOptionalPackage) include(CheckCCompilerFlag) include(GNUInstallDirsWrapper) -# Default to release build type +# Default to debug build type if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Debug") endif() @@ -41,7 +41,7 @@ endif() # Libraries that we have a hard dependency on if(NOT DEFINED OPENSSL_INCLUDE_DIR OR NOT DEFINED OPENSSL_LIBRARIES) -find_required_package(OpenSSL) + find_required_package(OpenSSL) endif() # Mac OS X @@ -51,10 +51,11 @@ if(APPLE) set(FRAMEWORK_HEADERS_PATH /System/Library/Frameworks/Cocoa.framework/Versions/A/Headers/) include_directories (${FREERDP_INCLUDE_PATH} ${FRAMEWORK_HEADERS_PATH} /System/Library/Frameworks) - # set(CMAKE_OSX_SYSROOT MacOSX10.7.sdk) uncomment to specify SDK version + # set(CMAKE_OSX_SYSROOT MacOSX10.7.sdk) # uncomment to specify SDK version set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -mmacosx-version-min=10.4") set(GUI_TYPE MACOSX_BUNDLE) + # Import libraries find_library(FOUNDATION_LIBRARY Foundation) message("+ Using foundation library ${FOUNDATION_LIBRARY}") find_library(COCOA_LIBRARY Cocoa) @@ -74,10 +75,9 @@ if(APPLE) set(MACOSX_BUNDLE_BUNDLE_VERSION 1.0.1) set(MACOSX_BUNDLE_COPYRIGHT "Copyright 2012. All Rights Reserved.") - # These variables are specific to our plist and are NOT standard CMake variables + # Specific plist and NOT standard CMake variables set(MACOSX_BUNDLE_NSMAIN_NIB_FILE "MainMenu") set(MACOSX_BUNDLE_NSPRINCIPAL_CLASS "NSApplication") - mark_as_advanced(COCOA_LIBRARY FOUNDATION_LIBRARY @@ -86,21 +86,19 @@ if(APPLE) set(APP_TYPE MACOSX_BUNDLE) endif() -# Configure files -# set(XCODE_ATTRIBUTE_REFCOUNT "Object-C Automatic Reference Counting") - -# these are the OS X Interface Builder Files +# OS X Interface Builder files set (MacFreeRDP_XIBS MainMenu.xib Credits.rtf ) -# the headers +# Headers set (MacFreeRDP_Headers MRDPCursor.h MRDPView.h AppDelegate.h) +# Source set (MacFreeRDP_Source MRDPCursor.m MRDPView.m @@ -115,19 +113,33 @@ add_executable(MacFreeRDP # This is necessary for the xib file part below configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Info.plist ${CMAKE_CURRENT_BINARY_DIR}/Info.plist) + # This allows for automatic xib to nib ibitool set_target_properties(MacFreeRDP PROPERTIES RESOURCE "${MacFreeRDP_XIBS}") + +# Automatic ref counting set_target_properties(MacFreeRDP PROPERTIES XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES) -set_target_properties(MacFreeRDP PROPERTIES XCODE_ATTRIBUTE_GCC_VERSION com.apple.compilers.llvmgcc42) +# Support for automatic reference counting requires non-fragile abi. +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fobjc-nonfragile-abi") +# XCode project architecture to native architecture of build machine +# ----------------------------------------------------------------------------------------------------- +# Issue: Had some issues with FreeRDP project building only 64 bit and +# MacFreeRDP attempting to link to both 32 and 64 for dual target. +# In the future the FreeRDP Xcode project should be pulled in for a couple of reasons: +# 1) better step-into debugging 2) automatic dependency compilation and multi-arch compilation + linkage +# If you know the solutions for 1 and 2, please add below. +set_target_properties(MacFreeRDP PROPERTIES XCODE_ATTRIBUTE_ARCHS "$(NATIVE_ARCH_ACTUAL)") + +# Set the info plist to the custom instance set_target_properties(MacFreeRDP PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_BINARY_DIR}/Info.plist) if(NOT WIN32) find_optional_package(MacAudio) endif() - +# Add all libraries target_link_libraries(MacFreeRDP ${EXTRA_LIBS}) target_link_libraries(MacFreeRDP ${CMAKE_SOURCE_DIR}/../../xcode/libfreerdp-core/Debug/libfreerdp-core.dylib) target_link_libraries(MacFreeRDP ${CMAKE_SOURCE_DIR}/../../xcode/libfreerdp-channels/Debug/libfreerdp-channels.dylib) diff --git a/xcode.sh b/xcode.sh new file mode 100755 index 000000000..5e8589484 --- /dev/null +++ b/xcode.sh @@ -0,0 +1,71 @@ +#!/bin/bash +# Xcode generated files directory +XCODE_PROJ_DIR=xcode +# MacFreeRDP client directory +CLIENT_MAC_DIR=./client/Mac/ +pushd . + +GEN='Xcode' + +# Build settings +ARCH=-DCMAKE_OSX_ARCHITECTURES="${CMAKE_OSX_ARCHITECTURES:-i386;x86_64}" +BUILDTYPE=-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:Debug}" +MANPAGES=-DWITH_MANPAGES="${WITHMANPAGES:NO}" + +# Run cmake for FreeRDP and MacFreeRDP +mkdir ${XCODE_PROJ_DIR} >/dev/null 2>&1 +pushd ${XCODE_PROJ_DIR} +cmake ${BUILDTYPE} -G "$GEN" ${ARCH} ../ +popd +mkdir ${CLIENT_MAC_DIR}/${XCODE_PROJ_DIR} >/dev/null 2>&1 +pushd ${CLIENT_MAC_DIR}/${XCODE_PROJ_DIR} +cmake ${BUILDTYPE} -G "$GEN" ${ARCH} ../ +popd + +# Check for errors; otherwise, ask for compile. +if [ "$?" -ne 0 ]; then + echo "CMake failed. Please check error messages" + popd > /dev/null + exit +else + popd + while true + do + echo -n "Compile FreeRDP? (y or n) - (y recommended for MacFreeRDP compilation):" + read CONFIRM + case $CONFIRM in + y|Y|YES|yes|Yes) + pushd ./${XCODE_PROJ_DIR} + xcodebuild + popd + break ;; + n|N|no|NO|No) + echo OK - you entered $CONFIRM + break + ;; + *) echo Please enter only y or n + esac + done + + echo "SUCCESS!" + while true + do + echo -n "Open Xcode projects now? (y or n):" + read CONFIRM + case $CONFIRM in + y|Y|YES|yes|Yes) + open ${CLIENT_MAC_DIR}/${XCODE_PROJ_DIR}/MacFreeRDP.xcodeproj + open ./${XCODE_PROJ_DIR}/FreeRDP.xcodeproj + break ;; + n|N|no|NO|No) + echo OK - $CONFIRM + break + ;; + *) echo Please enter only y or n + esac + done + + echo -n "NOTE: Dragging FreeRDP project from finder +onto the MacFreeRDP project in Xcode will enable code stepping from MacFreeRDP into FreeRDP. +" +fi \ No newline at end of file