Use CMake command to move and rename for portability. Closes #73.
- Revert back CMake version. Use CMake -Wno-dev option to suppress the policy warning for CMake 2.8.12 early adopter. - Since the new policy is not in place, set some more target property to prevent Urho3D static dependency libs from being transitively link to other targets linking to Urho3D.
This commit is contained in:
Родитель
e19bed4946
Коммит
15c61cb739
|
@ -24,11 +24,10 @@
|
|||
project (Urho3D)
|
||||
|
||||
# Set minimum version
|
||||
cmake_minimum_required (VERSION 2.8.12)
|
||||
cmake_minimum_required (VERSION 2.8.6)
|
||||
|
||||
if (COMMAND cmake_policy)
|
||||
cmake_policy (SET CMP0003 NEW)
|
||||
cmake_policy (SET CMP0022 NEW)
|
||||
endif ()
|
||||
|
||||
# Set CMake modules search path
|
||||
|
|
|
@ -120,11 +120,11 @@ if (APPLE)
|
|||
# Add a custom target to build Mach-O universal binary consisting of iphoneos (universal ARM archs) and iphonesimulator (i386 arch)
|
||||
add_custom_target (${TARGET_NAME}_universal
|
||||
COMMAND xcodebuild -target ${TARGET_NAME} -configuration $(CONFIGURATION) -sdk iphonesimulator
|
||||
COMMAND mv \"$<TARGET_FILE:${TARGET_NAME}>\"{,.iphonesimulator}
|
||||
COMMAND mv $<TARGET_FILE:${TARGET_NAME}>{,.iphonesimulator}
|
||||
COMMAND xcodebuild -target ${TARGET_NAME} -configuration $(CONFIGURATION) -sdk iphoneos
|
||||
COMMAND mv \"$<TARGET_FILE:${TARGET_NAME}>\"{,.iphoneos}
|
||||
COMMAND lipo -create -output \"$<TARGET_FILE:${TARGET_NAME}>\"{,.iphonesimulator,.iphoneos}
|
||||
COMMAND rm \"$<TARGET_FILE:${TARGET_NAME}>\"{.iphonesimulator,.iphoneos}
|
||||
COMMAND mv $<TARGET_FILE:${TARGET_NAME}>{,.iphoneos}
|
||||
COMMAND lipo -create -output $<TARGET_FILE:${TARGET_NAME}>{,.iphonesimulator,.iphoneos}
|
||||
COMMAND rm $<TARGET_FILE:${TARGET_NAME}>{.iphonesimulator,.iphoneos}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMENT "Creating Mach-O universal binary library")
|
||||
else ()
|
||||
|
@ -147,21 +147,27 @@ if (NOT APPLE AND NOT MSVC)
|
|||
set_property (TARGET ${TARGET_NAME} APPEND PROPERTY LINK_LIBRARIES -Wl,--no-whole-archive)
|
||||
if (NOT URHO3D_LIB_TYPE STREQUAL SHARED) # GCC ar does not take archives directly as input like Apple libtool, however, it can be scripted to do so
|
||||
add_custom_command (TARGET ${TARGET_NAME} POST_BUILD
|
||||
COMMAND mv \"$<TARGET_FILE:${TARGET_NAME}>\"{,.engine}
|
||||
COMMAND echo CREATE \"$<TARGET_FILE:${TARGET_NAME}>\" >script.ar
|
||||
COMMAND echo ADDLIB \"$<TARGET_FILE:${TARGET_NAME}>\".engine >>script.ar
|
||||
COMMAND ${CMAKE_COMMAND} -E rename $<TARGET_FILE:${TARGET_NAME}> $<TARGET_FILE:${TARGET_NAME}>.engine
|
||||
COMMAND echo CREATE $<TARGET_FILE:${TARGET_NAME}> >script.ar
|
||||
COMMAND echo ADDLIB $<TARGET_FILE:${TARGET_NAME}>.engine >>script.ar
|
||||
COMMENT "Preparing merge script")
|
||||
foreach (TARGET ${STATIC_LIBRARY_TARGETS})
|
||||
add_custom_command (TARGET ${TARGET_NAME} POST_BUILD COMMAND echo ADDLIB \"$<TARGET_FILE:${TARGET}>\" >>script.ar)
|
||||
add_custom_command (TARGET ${TARGET_NAME} POST_BUILD COMMAND echo ADDLIB $<TARGET_FILE:${TARGET}> >>script.ar)
|
||||
endforeach ()
|
||||
add_custom_command (TARGET ${TARGET_NAME} POST_BUILD
|
||||
COMMAND echo SAVE >>script.ar
|
||||
COMMAND echo END >>script.ar
|
||||
COMMAND ${CMAKE_AR} -M <script.ar
|
||||
COMMAND rm \"$<TARGET_FILE:${TARGET_NAME}>\".engine script.ar
|
||||
COMMAND ${CMAKE_COMMAND} -E remove $<TARGET_FILE:${TARGET_NAME}>.engine script.ar
|
||||
COMMENT "Merging all archives into a single static library")
|
||||
endif ()
|
||||
endif ()
|
||||
# \todo This is a deprecated property in CMake version 2.8.12 - Remove below macros when CMake minimum version is 2.8.12
|
||||
set_target_properties (${TARGET_NAME} PROPERTIES LINK_INTERFACE_LIBRARIES "")
|
||||
if (NOT URHO3D_LIB_TYPE STREQUAL SHARED)
|
||||
set_target_properties (${TARGET_NAME} PROPERTIES LINK_LIBRARIES "")
|
||||
endif ()
|
||||
# \endtodo
|
||||
|
||||
# Generate platform specific export header file automatically
|
||||
if (NOT URHO3D_LIB_TYPE STREQUAL URHO3D_EXPORTS_LIB_TYPE OR ${CMAKE_CURRENT_SOURCE_DIR}/Urho3D.h.in IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/Urho3D.h)
|
||||
|
@ -206,11 +212,11 @@ endif ()
|
|||
# Define post build steps
|
||||
# Strip the output shared library for embedded devices
|
||||
if (URHO3D_LIB_TYPE STREQUAL SHARED AND (CMAKE_CROSSCOMPILING OR IOS))
|
||||
add_custom_command (TARGET ${TARGET_NAME} POST_BUILD COMMAND ${CMAKE_STRIP} \"$<TARGET_FILE:${TARGET_NAME}>\"
|
||||
add_custom_command (TARGET ${TARGET_NAME} POST_BUILD COMMAND ${CMAKE_STRIP} $<TARGET_FILE:${TARGET_NAME}>
|
||||
COMMENT "Stripping shared library")
|
||||
endif ()
|
||||
if (RASPI AND SCP_TO_TARGET)
|
||||
# Ensure SCP is the last command
|
||||
add_custom_command (TARGET ${TARGET_NAME} POST_BUILD COMMAND scp \"$<TARGET_FILE:${TARGET_NAME}>\" ${SCP_TO_TARGET} || exit 0
|
||||
add_custom_command (TARGET ${TARGET_NAME} POST_BUILD COMMAND scp $<TARGET_FILE:${TARGET_NAME}> ${SCP_TO_TARGET} || exit 0
|
||||
COMMENT "Scp-ing library to Raspberry Pi device")
|
||||
endif ()
|
||||
|
|
|
@ -49,5 +49,7 @@ if "%use_mklink%" == "1" (
|
|||
if exist android-Build\CMakeFiles. rd /S /Q android-Build\CMakeFiles
|
||||
)
|
||||
echo on
|
||||
cmake -E chdir %build% cmake -G "Unix Makefiles" -DANDROID=1 -DCMAKE_TOOLCHAIN_FILE=%source%\CMake\Toolchains\android.toolchain.cmake -DLIBRARY_OUTPUT_PATH_ROOT=. %* %source%
|
||||
:: \todo suppress policy warning (for 2.8.12 early adopters), remove this option when CMake minimum version is 2.8.12
|
||||
set "OPT=-Wno-dev"
|
||||
cmake -E chdir %build% cmake %OPT% -G "Unix Makefiles" -DANDROID=1 -DCMAKE_TOOLCHAIN_FILE=%source%\CMake\Toolchains\android.toolchain.cmake -DLIBRARY_OUTPUT_PATH_ROOT=. %* %source%
|
||||
@popd
|
||||
|
|
|
@ -41,7 +41,7 @@ GENERATOR="Unix Makefiles"
|
|||
[[ $( uname -m ) =~ ^armv6 ]] && PLATFORM="-DRASPI=1"
|
||||
|
||||
# Create project with the respective CMake generators
|
||||
OPT=
|
||||
OPT=-Wno-dev # \todo suppress policy warning (for 2.8.12 early adopters), remove this option when CMake minimum version is 2.8.12
|
||||
[ $ANDROID_NDK ] && msg "Android build" && cmake -E chdir android-Build cmake $OPT -G $GENERATOR -DANDROID=1 -DCMAKE_TOOLCHAIN_FILE=$SOURCE/CMake/Toolchains/android.toolchain.cmake -DLIBRARY_OUTPUT_PATH_ROOT=. $@ $SOURCE && post_cmake android-Build
|
||||
[ $RASPI_TOOL ] && msg "Raspberry Pi build" && cmake -E chdir raspi-Build cmake $OPT -G $GENERATOR -DRASPI=1 -DCMAKE_TOOLCHAIN_FILE=$SOURCE/CMake/Toolchains/raspberrypi.toolchain.cmake $@ $SOURCE && post_cmake raspi-Build
|
||||
msg "Native build" && cmake -E chdir Build cmake $OPT -G $GENERATOR $PLATFORM $@ $SOURCE && post_cmake Build
|
||||
|
|
|
@ -32,7 +32,8 @@ fi
|
|||
cmake -E make_directory $BUILD
|
||||
|
||||
# Create project with the Xcode generator
|
||||
cmake -E chdir $BUILD cmake -G "Xcode" $@ $SOURCE
|
||||
OPT=-Wno-dev # \todo suppress policy warning (for 2.8.12 early adopters), remove this option when CMake minimum version is 2.8.12
|
||||
cmake -E chdir $BUILD cmake $OPT -G "Xcode" $@ $SOURCE
|
||||
|
||||
# Temporary fix: can be removed when CMake minimum required has reached 2.8.12
|
||||
if [ "$1" == "-DIOS=1" -a -e $BUILD/CMakeScripts/XCODE_DEPEND_HELPER.make ]; then
|
||||
|
|
|
@ -24,5 +24,7 @@
|
|||
pushd %~dp0
|
||||
cmake -E make_directory Build
|
||||
echo on
|
||||
cmake -E chdir Build cmake -G "MinGW Makefiles" %* ..\Source
|
||||
:: \todo suppress policy warning (for 2.8.12 early adopters), remove this option when CMake minimum version is 2.8.12
|
||||
set "OPT=-Wno-dev"
|
||||
cmake -E chdir Build cmake %OPT% -G "MinGW Makefiles" %* ..\Source
|
||||
@popd
|
||||
|
|
|
@ -36,5 +36,7 @@ if not "%1" == "" (
|
|||
goto loop
|
||||
)
|
||||
echo on
|
||||
cmake -E chdir Build cmake -G "Visual Studio %version%%arch%" %* ..\Source
|
||||
:: \todo suppress policy warning (for 2.8.12 early adopters), remove this option when CMake minimum version is 2.8.12
|
||||
set "OPT=-Wno-dev"
|
||||
cmake -E chdir Build cmake %OPT% -G "Visual Studio %version%%arch%" %* ..\Source
|
||||
@popd
|
||||
|
|
Загрузка…
Ссылка в новой задаче