Added bash SHEBANG for the CMake custom scripts because the default sh shell in Mac OS X platform is broken. Fixed the static and shared library build for Mac OS X platform using Makefile generator.

This commit is contained in:
Wei Tjong Yao 2013-08-03 08:13:50 +00:00
Родитель 7aba3391a5
Коммит 8bfb657d15
5 изменённых файлов: 31 добавлений и 21 удалений

Просмотреть файл

@ -51,16 +51,13 @@ adjust_library_name ()
if (MSVC)
# todo
elseif (APPLE)
# todo
else ()
# GCC specific
# Linker adjustment for shared library
foreach (TARGET ${STATIC_LIBRARY_TARGETS})
set (ARCHIVES ${ARCHIVES} $<TARGET_FILE:${TARGET}>)
endforeach ()
set_property (TARGET ${TARGET_NAME} APPEND PROPERTY LINK_LIBRARIES -Wl,--whole-archive ${ARCHIVES} -Wl,--no-whole-archive)
# Archiver adjustment for static library
# Setting up the frameworks for Mac OS X platform
if (APPLE AND LIB_TYPE STREQUAL SHARED)
setup_macosx_framework (FRAMEWORKS)
endif ()
# Linker/Archiver adjustment to include all objects on the fly (works for GCC and Clang)
set_target_properties (${TARGET_NAME} PROPERTIES RULE_LAUNCH_LINK
"${CMAKE_SOURCE_DIR}/cmake/Scripts/ExternalObjectArchiver.sh <TARGET_TYPE> <CMAKE_AR> <TARGET> ${CMAKE_BINARY_DIR}/CMakeScriptOutput OBJECTS <OBJECTS> TARGETS ${STATIC_LIBRARY_TARGETS}\n")
"${CMAKE_SOURCE_DIR}/cmake/Scripts/ExternalObjectLinker.sh OUTDIR ${CMAKE_BINARY_DIR}/CMakeScriptOutput OBJECTS <OBJECTS> TARGETS ${STATIC_LIBRARY_TARGETS} FRAMEWORKS ${FRAMEWORKS} COMMAND")
endif ()

Просмотреть файл

@ -219,6 +219,11 @@ macro (setup_executable)
endif ()
endmacro ()
# Macro for setting up linker flags to link aginst the framework for Mac OS X desktop build
macro (setup_macosx_framework FRAMEWORKS)
set (FRAMEWORKS "-framework AudioUnit -framework Carbon -framework Cocoa -framework CoreAudio -framework ForceFeedback -framework IOKit -framework OpenGL -framework CoreServices")
endmacro ()
# Macro for setting up an executable target with resources to copy
macro (setup_main_executable)
# Define resource files
@ -235,7 +240,8 @@ macro (setup_main_executable)
set (CMAKE_EXE_LINKER_FLAGS "-framework AudioToolbox -framework CoreAudio -framework CoreGraphics -framework Foundation -framework OpenGLES -framework QuartzCore -framework UIKit")
set (EXE_TYPE MACOSX_BUNDLE)
elseif (APPLE)
set (CMAKE_EXE_LINKER_FLAGS "-framework AudioUnit -framework Carbon -framework Cocoa -framework CoreAudio -framework ForceFeedback -framework IOKit -framework OpenGL -framework CoreServices")
setup_macosx_framework (FRAMEWORKS)
set (CMAKE_EXE_LINKER_FLAGS ${FRAMEWORKS})
endif ()
if (ANDROID)
add_library (${TARGET_NAME} SHARED ${SOURCE_FILES})
@ -329,4 +335,4 @@ macro (define_dependency_libs TARGET)
list (REMOVE_DUPLICATES LINK_LIBS_ONLY)
list (SORT LINK_LIBS_ONLY)
endif ()
endmacro ()
endmacro ()

Просмотреть файл

@ -1,3 +1,4 @@
#!/usr/bin/env bash
#
# Copyright (c) 2008-2013 the Urho3D project.
#
@ -22,12 +23,15 @@
# This script is being called by CMake during GCC build
# PLEASE DO NOT EDIT unless you know what you are doing
[ $1 == "STATIC_LIBRARY" ] && shift || exit 0
archiver=$1; shift
libname=$1; shift
[ "$1" == "OUTDIR" ] && shift || exit 1
outdir=$1; shift
[ $1 == "OBJECTS" ] && shift || exit 1 # Consider that as an error
[ $1 == "TARGETS" ] && shift || exit 0
IFS=\;
$archiver r $libname $( for target in $@; do cat $outdir/$target.obj; done )
unset IFS
[ "$1" == "OBJECTS" ] && shift || exit 1
while [ "$1" != "TARGETS" ]; do hasobjects=1; shift; done
[ "$1" == "TARGETS" ] && shift || exit 1
IFS=\;; for target in $1; do externalobjects="$externalobjects $(cat $outdir/$target.obj)"; done; unset IFS; shift
[ "$1" == "FRAMEWORKS" ] && shift || exit 1
while [ "$1" != "COMMAND" ]; do frameworks="$frameworks $1"; shift; done
[ "$1" == "COMMAND" ] && shift || exit 1
command=$@
[ $hasobjects ] && command="$command $externalobjects $frameworks"
$command

Просмотреть файл

@ -1,3 +1,4 @@
#!/usr/bin/env bash
#
# Copyright (c) 2008-2013 the Urho3D project.
#
@ -27,5 +28,5 @@ outdir=$1; shift
objdir=$1; shift
(( $# )) && rm -f $outdir/$target.obj
for object in $@; do
echo -n "$objdir/$object;" >>$outdir/$target.obj
echo -n "$objdir/$object " >>$outdir/$target.obj
done

Просмотреть файл

@ -14,3 +14,5 @@ then
ln -s ../../Bin/Data $conf/.
fi
done
# vi: set ts=4 sw=4 expandtab: