目标 c - 编译 Collada DOM (c++) 以在 iOS 中使用
objective c - Compile Collada DOM (c++) for use in iOS
我想在我当前的iOS项目中使用Collada DOM,这是一个C ++库。那么,这样做的标准程序是:
- 使用 cmake 配置 c++ 库。
- 通过 make 或 xcode 为 iOS 编译静态库。
- 将静态库导入 xcode 并享受乐趣。
不幸的是,到目前为止,我所做的一切都不好玩。我从一开始就遇到了问题。所以这就是我所做的以及我如何试图"解决"我的问题。
我通过自制软件安装了boost,pkgconfig和readline。然后我使用 cmake gui (3.3.0) 创建了一个 xcode 项目,我计划在下一步中构建该项目。Cmake停止了,并出现错误,告诉我它找不到提升。所以我在 CMakeList 中设置了提升路径.txt如下所示:
set(Boost_INCLUDE_DIR "/usr/local/Cellar/boost/1.58.0/include")
set(Boost_LIBRARY_DIR "/usr/local/Cellar/boost/1.58.0/lib")
这很有帮助,我能够成功配置项目。然后我在 xcode 中打开它,只是意识到包含的架构只是 OSX。我用谷歌搜索,直到偶然发现了ios.cmake工具链文件,据说它允许交叉编译到iOS。所以我将cmake指向这个工具链文件,并尝试再次配置该项目。但无济于事。这一次,cmake抱怨它找不到编译器。我不得不将工具链文件中的第 30 行和第 31 行更改为:
# Force the compilers to gcc for iOS
include (CMakeForceCompiler)
CMAKE_FORCE_C_COMPILER (/usr/bin/clang GNU)
CMAKE_FORCE_CXX_COMPILER (/usr/bin/clang++ GNU)
并且,为了让 cmake 找到 SDK,请将第 89 行更改为:
# Setup iOS developer location
if (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT)
set (CMAKE_IOS_DEVELOPER_ROOT "/Applications/Xcode.app/Contents/Developer/Platforms/${IOS_PLATFORM_LOCATION}/Developer")
现在,cmake 配置再次运行,没有红色错误。但是现在日志告诉我,有很多东西cmake找不到:
Toolchain using default iOS SDK: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk
Checking whether C compiler has -isysroot
Checking whether C compiler has -isysroot - yes
Checking whether C compiler supports OSX deployment target flag
Checking whether C compiler supports OSX deployment target flag - no
Checking whether CXX compiler has -isysroot
Checking whether CXX compiler has -isysroot - yes
Checking whether CXX compiler supports OSX deployment target flag
Checking whether CXX compiler supports OSX deployment target flag - no
Compiling Collada DOM Version 2.4.0
Using cmake version 3.3
installing to /usr/local
compiling with double float precision
Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
Boost version: 1.58.0
Found the following Boost libraries:
filesystem
system
found boost version: 105800
Found ZLIB: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/usr/lib/libz.dylib (found version "1.2.5")
Found LibXml2: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/usr/lib/libxml2.dylib (found version "2.9.0")
libxml2 found
compiling minizip from sources and linking statically
System pcre not found, using local from sources
Found BZip2: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/usr/lib/libbz2.dylib (found version "1.0.6")
Looking for BZ2_bzCompressInit in /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/usr/lib/libbz2.dylib
Looking for BZ2_bzCompressInit in /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/usr/lib/libbz2.dylib - not found
Could not find OPTIONAL package Readline
Looking for dirent.h
Looking for dirent.h - not found
Looking for stdint.h
Looking for stdint.h - not found
Looking for inttypes.h
Looking for inttypes.h - not found
Looking for sys/stat.h
Looking for sys/stat.h - not found
Looking for sys/types.h
Looking for sys/types.h - not found
Looking for unistd.h
Looking for unistd.h - not found
Looking for windows.h
Looking for windows.h - not found
Looking for C++ include type_traits.h
Looking for C++ include type_traits.h - not found
Looking for C++ include bits/type_traits.h
Looking for C++ include bits/type_traits.h - not found
Looking for bcopy
Looking for bcopy - not found
Looking for memmove
Looking for memmove - not found
Looking for strerror
Looking for strerror - not found
Looking for strtoll
Looking for strtoll - not found
Looking for strtoq
Looking for strtoq - not found
Looking for _strtoi64
Looking for _strtoi64 - not found
Looking for stddef.h
Looking for stddef.h - not found
Check size of long long
Check size of long long - failed
Check size of unsigned long long
Check size of unsigned long long - failed
Configuring done
打开 xcode 项目并尝试构建时,这次我在 minizip 库中出现了 7 个错误:
Semantic Issue
Use of undeclared identifier 'Dfseeko64'; did you mean 'feesko'?
Semantic Issue
'FILE *(*)(const char *restrict, const char *restrict)' and 'int (*)(FILE*, off_t, int)' are not pointers to compatible types
Semantic Issue
Use of undeclared identifier 'Dftel64'
等。。。
似乎迷你zip库不包含正确的架构。但老实说,我不知道如何从这里开始。任何帮助将不胜感激!
仅供记录,以下是完整的配置脚本。CMakeLists.txt:
cmake_minimum_required (VERSION 2.6.0)
project (collada-dom)
set( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE )
# fix boost location
set(Boost_INCLUDE_DIR "/usr/local/Cellar/boost/1.58.0/include")
set(Boost_LIBRARY_DIR "/usr/local/Cellar/boost/1.58.0/lib")
# Define here the needed parameters
set (COLLADA_DOM_VERSION_MAJOR 2)
set (COLLADA_DOM_VERSION_MINOR 4)
set (COLLADA_DOM_VERSION_PATCH 0)
set (COLLADA_DOM_VERSION ${COLLADA_DOM_VERSION_MAJOR}.${COLLADA_DOM_VERSION_MINOR}.${COLLADA_DOM_VERSION_PATCH})
set (COLLADA_DOM_SOVERSION ${COLLADA_DOM_VERSION_MAJOR}.${COLLADA_DOM_VERSION_MINOR})
message(STATUS "Compiling Collada DOM Version ${COLLADA_DOM_VERSION}")
message(STATUS "Using cmake version ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" )
# http://www.cmake.org/cmake/help/cmake-2.6.html#policy:CMP0002
cmake_policy(SET CMP0002 NEW)
# http://www.cmake.org/cmake/help/cmake-2.6.html#policy:CMP0003
cmake_policy(SET CMP0003 NEW)
# Use, i.e. don't skip the full RPATH for the build tree
set(CMAKE_SKIP_BUILD_RPATH FALSE)
# When building, don't use the install RPATH already
# (but later on when installing)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
# The RPATH to be used when installing
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
# Add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
message(STATUS "installing to ${CMAKE_INSTALL_PREFIX}")
##############################################################################
# Custom CMake options
##############################################################################
option(OPT_COLLADA15 "Enable collada 1.5 compilation" ON)
option(OPT_COLLADA14 "Enable collada 1.4 compilation" ON)
option(OPT_COMPILE_VIEWER "Enable collada viewer compilation" OFF)
option(OPT_COMPILE_FX "Enable collada fx compilation" OFF)
option(OPT_COMPILE_RT "Enable collada rt compilation" OFF)
option(OPT_BUILD_PACKAGES "Set to ON to generate CPack configuration files and packaging targets" OFF)
option(OPT_BUILD_PACKAGE_DEFAULT "Set to ON to generate a default openrave package that creates symlinks" ON)
option(OPT_DOUBLE_PRECISION "Use double precision for everything (daeFloat included)" ON)
set(COLLADA_DOM_EXTERNAL_FLAGS)
if( OPT_COLLADA14 )
set(COLLADA_DOM_EXTERNAL_FLAGS "${COLLADA_DOM_EXTERNAL_FLAGS} -DCOLLADA_DOM_SUPPORT141")
endif()
if( OPT_COLLADA15 )
set(COLLADA_DOM_EXTERNAL_FLAGS "${COLLADA_DOM_EXTERNAL_FLAGS} -DCOLLADA_DOM_SUPPORT150")
endif()
set(CPACK_DEBIAN_PACKAGE_NAME collada-dom${COLLADA_DOM_SOVERSION})
if(OPT_DOUBLE_PRECISION)
set(COLLADA_PRECISION "dp")
set(CPACK_DEBIAN_PACKAGE_NAME "${CPACK_DEBIAN_PACKAGE_NAME}-dp")
set(COLLADA_DOM_EXTERNAL_FLAGS "${COLLADA_DOM_EXTERNAL_FLAGS} -DCOLLADA_DOM_DAEFLOAT_IS64") # daeFloat is 64 bit
message(STATUS "compiling with double float precision")
else()
set(COLLADA_PRECISION "sp")
set(CPACK_DEBIAN_PACKAGE_NAME "${CPACK_DEBIAN_PACKAGE_NAME}-sp")
message(STATUS "compiling with single float precision")
endif()
if( OPT_COMPILE_VIEWER )
message(WARNING "compiling collada viewer currently not supported")
endif()
if( OPT_COMPILE_FX )
message(WARNING "compiling collada fx currently not supported")
endif()
if( OPT_COMPILE_RT )
message(WARNING "compiling collada rt currently not supported")
endif()
set(PACKAGE_VERSION "0" CACHE STRING "the package-specific version used for uploading the sources")
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules")
set(COMPONENT_PREFIX "${CPACK_DEBIAN_PACKAGE_NAME}")
string(TOUPPER ${COMPONENT_PREFIX} COMPONENT_PREFIX_UPPER)
set(CPACK_COMPONENTS_ALL ${COMPONENT_PREFIX}-base ${COMPONENT_PREFIX}-dev)
if( MSVC )
if( MSVC70 OR MSVC71 )
set(MSVC_PREFIX "vc70")
elseif( MSVC80 )
set(MSVC_PREFIX "vc80")
elseif( MSVC90 )
set(MSVC_PREFIX "vc90")
else()
set(MSVC_PREFIX "vc100")
endif()
set(COLLADA_DOM_LIBRARY_SUFFIX "${COLLADA_DOM_SOVERSION}-${COLLADA_PRECISION}-${MSVC_PREFIX}-mt")
else()
set(COLLADA_DOM_LIBRARY_SUFFIX "${COLLADA_DOM_SOVERSION}-${COLLADA_PRECISION}")
endif()
include(CheckIncludeFile)
include(CheckIncludeFileCXX)
include(CheckLibraryExists)
include(CheckFunctionExists)
include(CheckCXXSourceCompiles)
#include(CheckCXXSourceRuns)
#include(CheckCXXCompilerFlag)
include(CheckTypeSize)
find_package(PkgConfig)
if( CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX )
add_definitions("-fno-strict-aliasing -Wall")
endif()
if( CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX )
set(CMAKE_CXX_FLAGS_RELEASE "-O2")# -DNDEBUG -DBOOST_DISABLE_ASSERTS -D_SECURE_SCL=0") # this practically removes all checks making it a very dangerous options to play with
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
set(CMAKE_CXX_FLAGS_DEBUG "-g -D_DEBUG")
endif()
if( UNIX OR CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX )
set(STDC_LIBRARY stdc++)
else()
set(STDC_LIBRARY)
endif()
if( APPLE OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# apple doesn't have 64bit versions of file opening functions, so add them
add_definitions("-Dfopen64=fopen -Dfseeko64=fseeko -Dfseek64=fseek -Dftell64=ftell -Dftello64=ftello")
endif()
set(COLLADA_DOM_INCLUDE_INSTALL_DIR "include/collada-dom${COLLADA_DOM_SOVERSION}")
set(COLLADA_DOM_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/dom/include)
set(COLLADA_DOM_LINK_DIRS "")
if( MSVC )
# force multi-threaded DLL boost
set(Boost_USE_MULTITHREAD ON)
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_STATIC_RUNTIME OFF)
set(Boost_CFLAGS "-DBOOST_ALL_DYN_LINK -DBOOST_ALL_NO_LIB")
endif()
set(Boost_ADDITIONAL_VERSIONS "1.46" "1.45" "1.44" "1.43" "1.42" "1.41" "1.40" "1.39" "1.38" "1.37.0" "1.37" "1.35.0" "1.34.1" "1.34.0" "1.34" "1.33.1" "1.33.0" "1.33")
if( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" )
set(Boost_INCLUDE_DIR $ENV{BOOST_INCLUDEDIR})
endif()
if( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" )
set(Boost_LIBRARY_DIRS $ENV{BOOST_LIBRARYDIR})
endif()
find_package(Boost COMPONENTS filesystem system REQUIRED)
message(STATUS "found boost version: ${Boost_VERSION}")
if( Boost_FOUND )
include_directories(${Boost_INCLUDE_DIRS})
set(COLLADA_DOM_LINK_DIRS ${COLLADA_DOM_LINK_DIRS} ${Boost_LIBRARY_DIRS})
elseif(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0")
include_directories(${Boost_INCLUDE_DIRS})
set(COLLADA_DOM_LINK_DIRS ${COLLADA_DOM_LINK_DIRS} ${Boost_LIBRARY_DIRS})
else()
message(FATAL_ERROR "Could not find boost libraries!")
endif()
set(COLLADA_DOM_BOOST_INCLUDE_DIRS)
foreach(idir ${Boost_INCLUDE_DIRS})
set(COLLADA_DOM_BOOST_INCLUDE_DIRS "${COLLADA_DOM_BOOST_INCLUDE_DIRS} -I${idir}")
endforeach()
set(COLLADA_DOM_BOOST_LIB_DIRS)
foreach(ldir ${Boost_LIBRARY_DIRS})
set(COLLADA_DOM_BOOST_LIB_DIRS "${COLLADA_DOM_BOOST_LIB_DIRS} -L${ldir}")
endforeach()
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
set(EXTRA_COMPILE_FLAGS "${COLLADA_DOM_EXTERNAL_FLAGS} -DCOLLADA_DOM_NAMESPACE -fPIC")
else()
set(EXTRA_COMPILE_FLAGS "${COLLADA_DOM_EXTERNAL_FLAGS} -DCOLLADA_DOM_NAMESPACE")
endif()
find_package(ZLIB)
if( NOT ZLIB_FOUND )
message(STATUS "compiling zlib from souces and linking statically")
# compile from sources
add_subdirectory(dom/external-libs/zlib-1.2.5)
set(ZLIB_FOUND 1)
set(ZLIB_LIBRARIES zlib)
set(ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/dom/external-libs/zlib-1.2.5)
endif()
find_package(LibXml2)
if( LIBXML2_FOUND )
include_directories(${LIBXML2_INCLUDE_DIR})
add_definitions(${LIBXML2_DEFINITIONS} -DDOM_INCLUDE_LIBXML)
message(STATUS "libxml2 found")
else()
if( MSVC )
set(LIBXML2_LIBRARY_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/dom/external-libs/libxml2-new/lib")
set(LIBXML2_LIBRARIES "${LIBXML2_LIBRARY_DIRS}/libxml2-${MSVC_PREFIX}-mt.lib")
set(LIBXML2_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/dom/external-libs/libxml2-new/include)
set(LIBXML2_DEFINITIONS)
set(LIBXML2_FOUND 1)
include_directories(${LIBXML2_INCLUDE_DIR})
add_definitions(-DDOM_INCLUDE_LIBXML)
# have to install the DLLs
install(DIRECTORY "${LIBXML2_LIBRARY_DIRS}/" DESTINATION lib${LIB_SUFFIX} FILES_MATCHING PATTERN "*-${MSVC_PREFIX}-*.dll")
else()
message(FATAL_ERROR "Could not find libxml2")
endif()
endif()
pkg_check_modules(minizip minizip)
if(minizip_FOUND)
set(MINIZIP_INCLUDE_DIR ${minizip_INCLUDE_DIRS})
else()
message(STATUS "compiling minizip from sources and linking statically")
add_subdirectory(dom/external-libs/minizip-1.1)
set(MINIZIP_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/dom/external-libs/minizip-1.1 ${ZLIB_INCLUDE_DIR})
endif()
pkg_check_modules(libpcrecpp libpcrecpp)
if( libpcrecpp_FOUND )
set(CMAKE_REQUIRED_INCLUDES ${libpcrecpp_INCLUDE_DIRS})
check_include_file_cxx(pcrecpp.h HAVE_PCRECPP_H)
set(CMAKE_REQUIRED_INCLUDES)
if( NOT HAVE_PCRECPP_H )
set(libpcrecpp_FOUND 0)
endif()
endif()
if( NOT libpcrecpp_FOUND )
message(STATUS "System pcre not found, using local from sources")
# include the local pcre
add_subdirectory(dom/external-libs/pcre-8.02)
set(libpcrecpp_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/dom/external-libs/pcre-8.02)
set(libpcrecpp_LIBRARY_DIRS)
set(libpcrecpp_LIBRARIES pcrecpp_local)
set(libpcrecpp_CFLAGS_OTHERS "-DPCRE_STATIC")
set(libpcrecpp_LDFLAGS_OTHERS)
endif()
# declare minizip/zlib before libxml2! (for some reason the precompiled libxml2 libraries have zlib.h/zconf.h)
include_directories(BEFORE ${MINIZIP_INCLUDE_DIR})
include_directories(BEFORE ${libpcrecpp_INCLUDE_DIRS})
set(COLLADA_DOM_LINK_DIRS ${COLLADA_DOM_LINK_DIRS} ${libpcrecpp_LIBRARY_DIRS})
link_directories(${COLLADA_DOM_LINK_DIRS})
add_subdirectory(dom)
if(UNIX)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/collada-dom.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/collada-dom.pc" @ONLY IMMEDIATE)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/collada-dom.pc DESTINATION lib${LIB_SUFFIX}/pkgconfig COMPONENT ${COMPONENT_PREFIX}-dev)
endif()
if( OPT_COLLADA15 )
if(UNIX)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/collada-dom-150.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/collada-dom-150.pc" @ONLY IMMEDIATE)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/collada-dom-150.pc DESTINATION lib${LIB_SUFFIX}/pkgconfig COMPONENT ${COMPONENT_PREFIX}-dev)
endif()
endif()
if( OPT_COLLADA14 )
if(UNIX)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/collada-dom-141.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/collada-dom-141.pc" @ONLY IMMEDIATE)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/collada-dom-141.pc DESTINATION lib${LIB_SUFFIX}/pkgconfig COMPONENT ${COMPONENT_PREFIX}-dev)
endif()
endif()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/collada_dom-config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/collada_dom-config.cmake" @ONLY IMMEDIATE)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/collada_dom-config-version.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/collada_dom-config-version.cmake" @ONLY IMMEDIATE)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/collada_dom-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/collada_dom-config-version.cmake" DESTINATION "lib${LIB_SUFFIX}/cmake/collada_dom-${COLLADA_DOM_SOVERSION}" COMPONENT ${COMPONENT_PREFIX}-dev)
# add make uninstall capability
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)
add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
if(CMAKE_CPACK_COMMAND AND UNIX AND OPT_BUILD_PACKAGES)
# Packing information
set(CPACK_PACKAGE_NAME collada-dom${COLLADA_DOM_SOVERSION})
set(CPACK_PACKAGE_CONTACT "" CACHE STRING "Package maintainer and PGP signer.")
set(CPACK_PACKAGE_VENDOR "http://sourceforge.net/projects/collada-dom")
set(CPACK_PACKAGE_DISPLAY_NAME "collada-dom ${COLLADA_DOM_VERSION}")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY " - COLLADA")
if( OPT_DOUBLE_PRECISION )
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${CPACK_PACKAGE_DESCRIPTION_SUMMARY} using double precision")
else()
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${CPACK_PACKAGE_DESCRIPTION_SUMMARY} using single precision")
endif()
set(CPACK_PACKAGE_VERSION ${COLLADA_DOM_VERSION}.${PACKAGE_VERSION})
set(CPACK_PACKAGE_VERSION_MAJOR ${COLLADA_DOM_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${COLLADA_DOM_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${COLLADA_DOM_VERSION_PATCH})
set(CPACK_PACKAGE_INSTALL_DIRECTORY "collada-dom${COLLADA_DOM_SOVERSION}")
set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/description)
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/dom/license.txt)
set(CPACK_COMPONENT_${COMPONENT_PREFIX_UPPER}-BASE_DISPLAY_NAME "core libraries")
set(CPACK_COMPONENT_${COMPONENT_PREFIX_UPPER}-DEV_DISPLAY_NAME "C++ headers and build tools")
set(CPACK_COMPONENT_${COMPONENT_PREFIX_UPPER}-DEV_DEPENDS ${COMPONENT_PREFIX}-base)
set(CPACK_DEBIAN_BUILD_DEPENDS debhelper cmake libxml2-dev libboost-dev zlib1g-dev libboost-filesystem-dev libboost-system-dev libpcre3-dev pkg-config)
# debian
set(CPACK_DEBIAN_PACKAGE_PRIORITY optional)
set(CPACK_DEBIAN_PACKAGE_SECTION libs)
set(CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_COMPONENTS_ALL})
set(CPACK_DEBIAN_PACKAGE_SUGGESTS)
set(CPACK_DEBIAN_CMAKE_OPTIONS "-DOPT_DOUBLE_PRECISION=${OPT_DOUBLE_PRECISION} -DOPT_BUILD_PACKAGE_DEFAULT=${OPT_BUILD_PACKAGE_DEFAULT}")
set(CPACK_DEBIAN_PACKAGE_REMOVE_SOURCE_FILES viewer fx rt Makefile.linux Makefile dom/codeGen dom/Makefile dom/external-libs/boost dom/external-libs/libxml2 dom/external-libs/minizip dom/external-libs/pcre dom/external-libs/pcre-8.02 dom/external-libs/zlib-1.2.5 dom/test dom/release dom/projects dom/make)
set(CPACK_DEBIAN_PACKAGE_SOURCE_COPY svn export --force)
set(CPACK_DEBIAN_CHANGELOG)
execute_process(COMMAND lsb_release -is
OUTPUT_VARIABLE _lsb_distribution OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE _lsb_release_failed)
set(CPACK_DEBIAN_DISTRIBUTION_NAME ${_lsb_distribution} CACHE STRING "Name of the distrubiton")
string(TOLOWER ${CPACK_DEBIAN_DISTRIBUTION_NAME} CPACK_DEBIAN_DISTRIBUTION_NAME)
if( ${CPACK_DEBIAN_DISTRIBUTION_NAME} STREQUAL "ubuntu" )
set(CPACK_DEBIAN_DISTRIBUTION_RELEASES lucid maverick natty oneiric precise CACHE STRING "Release code-names of the distrubiton release")
endif()
set(CPACK_COMPONENT_COLLADA-DOM_DEPENDS ${CPACK_COMPONENTS_ALL})
if( OPT_BUILD_PACKAGE_DEFAULT )
set(CPACK_COMPONENT_COLLADA-DOM-DEV_RECOMMENDS ${CPACK_DEBIAN_PACKAGE_NAME}-dev)
set(CPACK_COMPONENT_COLLADA-DOM-DEV_DISPLAY_NAME ${CPACK_COMPONENT_${COMPONENT_PREFIX_UPPER}-DEV_DISPLAY_NAME})
set(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} collada-dom-dev)
endif()
set(DPUT_HOST "" CACHE STRING "PPA repository to upload the debian sources")
include(CPack)
include(DebSourcePPA)
endif()
iOS.cmake:
# This file is based off of the Platform/Darwin.cmake and Platform/UnixPaths.cmake
# files which are included with CMake 2.8.4
# It has been altered for iOS development
# Options:
#
# IOS_PLATFORM = OS (default) or SIMULATOR
# This decides if SDKS will be selected from the iPhoneOS.platform or iPhoneSimulator.platform folders
# OS - the default, used to build for iPhone and iPad physical devices, which have an arm arch.
# SIMULATOR - used to build for the Simulator platforms, which have an x86 arch.
#
# CMAKE_IOS_DEVELOPER_ROOT = automatic(default) or /path/to/platform/Developer folder
# By default this location is automatcially chosen based on the IOS_PLATFORM value above.
# If set manually, it will override the default location and force the user of a particular Developer Platform
#
# CMAKE_IOS_SDK_ROOT = automatic(default) or /path/to/platform/Developer/SDKs/SDK folder
# By default this location is automatcially chosen based on the CMAKE_IOS_DEVELOPER_ROOT value.
# In this case it will always be the most up-to-date SDK found in the CMAKE_IOS_DEVELOPER_ROOT path.
# If set manually, this will force the use of a specific SDK version
# Standard settings
set (CMAKE_SYSTEM_NAME Darwin)
set (CMAKE_SYSTEM_VERSION 1 )
set (UNIX True)
set (APPLE True)
set (IOS True)
# Force the compilers to gcc for iOS
include (CMakeForceCompiler)
CMAKE_FORCE_C_COMPILER (/usr/bin/clang GNU)
CMAKE_FORCE_CXX_COMPILER (/usr/bin/clang++ GNU)
# Skip the platform compiler checks for cross compiling
set (CMAKE_CXX_COMPILER_WORKS TRUE)
set (CMAKE_C_COMPILER_WORKS TRUE)
# All iOS/Darwin specific settings - some may be redundant
set (CMAKE_SHARED_LIBRARY_PREFIX "lib")
set (CMAKE_SHARED_LIBRARY_SUFFIX ".dylib")
set (CMAKE_SHARED_MODULE_PREFIX "lib")
set (CMAKE_SHARED_MODULE_SUFFIX ".so")
set (CMAKE_MODULE_EXISTS 1)
set (CMAKE_DL_LIBS "")
set (CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ")
set (CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ")
set (CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}")
set (CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}")
# Hidden visibilty is required for cxx on iOS
set (CMAKE_C_FLAGS "")
set (CMAKE_CXX_FLAGS "-headerpad_max_install_names -fvisibility=hidden -fvisibility-inlines-hidden")
set (CMAKE_C_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}")
set (CMAKE_CXX_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}")
set (CMAKE_PLATFORM_HAS_INSTALLNAME 1)
set (CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib -headerpad_max_install_names")
set (CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle -headerpad_max_install_names")
set (CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,")
set (CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,")
set (CMAKE_FIND_LIBRARY_SUFFIXES ".dylib" ".so" ".a")
# hack: if a new cmake (which uses CMAKE_INSTALL_NAME_TOOL) runs on an old build tree
# (where install_name_tool was hardcoded) and where CMAKE_INSTALL_NAME_TOOL isn't in the cache
# and still cmake didn't fail in CMakeFindBinUtils.cmake (because it isn't rerun)
# hardcode CMAKE_INSTALL_NAME_TOOL here to install_name_tool, so it behaves as it did before, Alex
if (NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
find_program(CMAKE_INSTALL_NAME_TOOL install_name_tool)
endif (NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
# Setup iOS platform
if (NOT DEFINED IOS_PLATFORM)
set (IOS_PLATFORM "OS")
endif (NOT DEFINED IOS_PLATFORM)
set (IOS_PLATFORM ${IOS_PLATFORM} CACHE STRING "Type of iOS Platform")
# Check the platform selection and setup for developer root
if (${IOS_PLATFORM} STREQUAL "OS")
set (IOS_PLATFORM_LOCATION "iPhoneOS.platform")
elseif (${IOS_PLATFORM} STREQUAL "SIMULATOR")
set (IOS_PLATFORM_LOCATION "iPhoneSimulator.platform")
else (${IOS_PLATFORM} STREQUAL "OS")
message (FATAL_ERROR "Unsupported IOS_PLATFORM value selected. Please choose OS or SIMULATOR")
endif (${IOS_PLATFORM} STREQUAL "OS")
# Setup iOS developer location
if (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT)
set (CMAKE_IOS_DEVELOPER_ROOT "/Applications/Xcode.app/Contents/Developer/Platforms/${IOS_PLATFORM_LOCATION}/Developer")
endif (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT)
set (CMAKE_IOS_DEVELOPER_ROOT ${CMAKE_IOS_DEVELOPER_ROOT} CACHE PATH "Location of iOS Platform")
# Find and use the most recent iOS sdk
if (NOT DEFINED CMAKE_IOS_SDK_ROOT)
file (GLOB _CMAKE_IOS_SDKS "${CMAKE_IOS_DEVELOPER_ROOT}/SDKs/*")
if (_CMAKE_IOS_SDKS)
list (SORT _CMAKE_IOS_SDKS)
list (REVERSE _CMAKE_IOS_SDKS)
list (GET _CMAKE_IOS_SDKS 0 CMAKE_IOS_SDK_ROOT)
else (_CMAKE_IOS_SDKS)
message (FATAL_ERROR "No iOS SDK's found in default seach path ${CMAKE_IOS_DEVELOPER_ROOT}. Manually set CMAKE_IOS_SDK_ROOT or install the iOS SDK.")
endif (_CMAKE_IOS_SDKS)
message (STATUS "Toolchain using default iOS SDK: ${CMAKE_IOS_SDK_ROOT}")
endif (NOT DEFINED CMAKE_IOS_SDK_ROOT)
set (CMAKE_IOS_SDK_ROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Location of the selected iOS SDK")
# Set the sysroot default to the most recent SDK
set (CMAKE_OSX_SYSROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Sysroot used for iOS support")
# set the architecture for iOS - using ARCHS_STANDARD_32_BIT sets armv6,armv7 and appears to be XCode's standard.
# The other value that works is ARCHS_UNIVERSAL_IPHONE_OS but that sets armv7 only
set (CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD_32_BIT)" CACHE string "Build architecture for iOS")
# Set the find root to the iOS developer roots and to user defined paths
set (CMAKE_FIND_ROOT_PATH ${CMAKE_IOS_DEVELOPER_ROOT} ${CMAKE_IOS_SDK_ROOT} ${CMAKE_PREFIX_PATH} CACHE string "iOS find search path root")
# default to searching for frameworks first
set (CMAKE_FIND_FRAMEWORK FIRST)
# set up the default search directories for frameworks
set (CMAKE_SYSTEM_FRAMEWORK_PATH
${CMAKE_IOS_SDK_ROOT}/System/Library/Frameworks
${CMAKE_IOS_SDK_ROOT}/System/Library/PrivateFrameworks
${CMAKE_IOS_SDK_ROOT}/Developer/Library/Frameworks
)
# only search the iOS sdks, not the remainder of the host filesystem
set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
iOS 工具链目前不支持 CheckIncludeFiles.cmake 使用的 TRY_COMPILE。工具链当前设置为使用以下方法跳过TRY_COMPILE:
# Skip the platform compiler checks for cross compiling
set (CMAKE_CXX_COMPILER_WORKS TRUE)
set (CMAKE_C_COMPILER_WORKS TRUE)
要修复try_compile
,您需要注释掉这些行并将其添加到IOS.cmake工具链文件的顶部。
set(MACOSX_BUNDLE_GUI_IDENTIFIER com.example)
set(CMAKE_MACOSX_BUNDLE YES)
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer")
- 创建一个函数以在输入为负数或零时输出字符串.第一次执行用户定义的函数
- 以在Qt中的IF语句中设置时间延迟
- 我可以在 iOS 或 mac 应用程序中使用C++代码吗?
- 如何重写全局方法名称以在调用原始方法之前将我的代码推到前面
- 为什么 C++ 11 在 ios 类中添加了运算符 bool
- 不确定如何装饰我的C++库代码以在 C 中使用
- 如何从Windows控制台调用.exe(C++)以在不同的目录(或任何目录)中创建文件夹?
- 如何注册Qt C++对象以在QML中使用它
- 将 std::vector<double> 从 C++ 包装到 C 以在 Swift 中使用
- LLVM 传递以在特定地址分配内存
- 测量时间以在 c++ 中生成更好的随机数
- 坚持编译QDoc以在Windows上构建qt5
- 传递指针数组以在 Vivado HLS (SDSoC 2018) 中发挥作用
- 唤醒多个线程以在每个条件下工作一次
- 如何获得CMake Tools以在Visual Studio Code中编译具有C++11(或更高版本)功能的程序?
- 需要帮助编写 for 循环以在字符串周围创建边框
- 递增 'int i = 0' 以在初始化的字符数组的位置递增
- 无法在 IOS 中将常量字符 * 表[] 转换为 NSArray 以实现统一
- IOS 从资源中获取 XML 文件以在 c++ 中处理它
- 目标 c - 编译 Collada DOM (c++) 以在 iOS 中使用