Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

275 строки
12 KiB

  1. cmake_minimum_required( VERSION 2.6 )
  2. PROJECT( Assimp )
  3. # Define here the needed parameters
  4. set (ASSIMP_VERSION_MAJOR 3)
  5. set (ASSIMP_VERSION_MINOR 1)
  6. set (ASSIMP_VERSION_PATCH 1) # subversion revision?
  7. set (ASSIMP_VERSION ${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}.${ASSIMP_VERSION_PATCH})
  8. set (ASSIMP_SOVERSION 3)
  9. set (PROJECT_VERSION "${ASSIMP_VERSION}")
  10. set(ASSIMP_PACKAGE_VERSION "0" CACHE STRING "the package-specific version used for uploading the sources")
  11. # Get the current working branch
  12. execute_process(
  13. COMMAND git rev-parse --abbrev-ref HEAD
  14. WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  15. OUTPUT_VARIABLE GIT_BRANCH
  16. OUTPUT_STRIP_TRAILING_WHITESPACE
  17. )
  18. # Get the latest abbreviated commit hash of the working branch
  19. execute_process(
  20. COMMAND git log -1 --format=%h
  21. WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  22. OUTPUT_VARIABLE GIT_COMMIT_HASH
  23. OUTPUT_STRIP_TRAILING_WHITESPACE
  24. )
  25. if(NOT GIT_COMMIT_HASH)
  26. set(GIT_COMMIT_HASH 0)
  27. endif(NOT GIT_COMMIT_HASH)
  28. configure_file(
  29. ${CMAKE_SOURCE_DIR}/revision.h.in
  30. ${CMAKE_BINARY_DIR}/revision.h
  31. )
  32. include_directories(${CMAKE_BINARY_DIR})
  33. option(ASSIMP_OPT_BUILD_PACKAGES "Set to ON to generate CPack configuration files and packaging targets" OFF)
  34. set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules" )
  35. set(LIBASSIMP_COMPONENT "libassimp${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}.${ASSIMP_VERSION_PATCH}" )
  36. set(LIBASSIMP-DEV_COMPONENT "libassimp${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}.${ASSIMP_VERSION_PATCH}-dev" )
  37. set(CPACK_COMPONENTS_ALL assimp-bin ${LIBASSIMP_COMPONENT} ${LIBASSIMP-DEV_COMPONENT} assimp-dev)
  38. set(ASSIMP_LIBRARY_SUFFIX "" CACHE STRING "Suffix to append to library names")
  39. if((CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) AND NOT CMAKE_COMPILER_IS_MINGW)
  40. add_definitions(-fPIC) # this is a very important switch and some libraries seem now to have it....
  41. # hide all not-exported symbols
  42. add_definitions( -fvisibility=hidden -Wall )
  43. elseif(MSVC)
  44. # enable multi-core compilation with MSVC
  45. add_definitions(/MP)
  46. endif()
  47. INCLUDE (FindPkgConfig)
  48. INCLUDE_DIRECTORIES( include )
  49. INCLUDE (PrecompiledHeader)
  50. # If this is an in-source build (CMAKE_SOURCE_DIR == CMAKE_BINARY_DIR),
  51. # write the library/executable files to the respective directories in the
  52. # source tree. During an out-of-source build, however, do not litter this
  53. # directory, since that is probably what the user wanted to avoid.
  54. IF ( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR )
  55. SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_HOME_DIRECTORY}/lib" )
  56. SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_HOME_DIRECTORY}/lib" )
  57. SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_HOME_DIRECTORY}/bin" )
  58. ENDIF ( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR )
  59. # Cache these to allow the user to override them manually.
  60. SET( ASSIMP_LIB_INSTALL_DIR "lib" CACHE PATH
  61. "Path the built library files are installed to." )
  62. SET( ASSIMP_INCLUDE_INSTALL_DIR "include" CACHE PATH
  63. "Path the header files are installed to." )
  64. SET( ASSIMP_BIN_INSTALL_DIR "bin" CACHE PATH
  65. "Path the tool executables are installed to." )
  66. SET ( ASSIMP_BUILD_STATIC_LIB OFF CACHE BOOL
  67. "Build a static (.a) version of the library" )
  68. SET(ASSIMP_DEBUG_POSTFIX "d" CACHE STRING "Debug Postfitx for lib, samples and tools")
  69. # Allow the user to build a static library
  70. option ( BUILD_SHARED_LIBS "Build a shared version of the library" ON )
  71. IF ( ASSIMP_BUILD_STATIC_LIB )
  72. option ( BUILD_SHARED_LIBS "Build a shared version of the library" OFF )
  73. ELSE ( ASSIMP_BUILD_STATIC_LIB )
  74. option ( BUILD_SHARED_LIBS "Build a shared version of the library" ON )
  75. ENDIF ( ASSIMP_BUILD_STATIC_LIB )
  76. # Generate a pkg-config .pc for the Assimp library.
  77. CONFIGURE_FILE( "${PROJECT_SOURCE_DIR}/assimp.pc.in" "${PROJECT_BINARY_DIR}/assimp.pc" @ONLY )
  78. INSTALL( FILES "${PROJECT_BINARY_DIR}/assimp.pc" DESTINATION ${ASSIMP_LIB_INSTALL_DIR}/pkgconfig/ COMPONENT ${LIBASSIMP-DEV_COMPONENT})
  79. # Only generate this target if no higher-level project already has
  80. IF (NOT TARGET uninstall)
  81. # add make uninstall capability
  82. configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)
  83. add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
  84. ENDIF()
  85. # Globally enable Boost resp. the Boost workaround – it is also needed by the
  86. # tools which include the Assimp headers.
  87. SET ( ASSIMP_ENABLE_BOOST_WORKAROUND ON CACHE BOOL
  88. "If a simple implementation of the used Boost functions is used. Slightly reduces functionality, but enables builds without Boost available."
  89. )
  90. IF ( ASSIMP_ENABLE_BOOST_WORKAROUND )
  91. INCLUDE_DIRECTORIES( code/BoostWorkaround )
  92. ADD_DEFINITIONS( -DASSIMP_BUILD_BOOST_WORKAROUND )
  93. MESSAGE( STATUS "Building a non-boost version of Assimp." )
  94. ELSE ( ASSIMP_ENABLE_BOOST_WORKAROUND )
  95. SET( Boost_DETAILED_FAILURE_MSG ON )
  96. SET( Boost_ADDITIONAL_VERSIONS "1.47" "1.47.0" "1.48.0" "1.48" "1.49" "1.49.0" "1.50" "1.50.0" "1.51" "1.51.0" "1.52.0" "1.53.0" "1.54.0" "1.55" )
  97. FIND_PACKAGE( Boost )
  98. IF ( NOT Boost_FOUND )
  99. MESSAGE( FATAL_ERROR
  100. "Boost libraries (http://www.boost.org/) not found. "
  101. "You can build a non-boost version of Assimp with slightly reduced "
  102. "functionality by specifying -DASSIMP_ENABLE_BOOST_WORKAROUND=ON."
  103. )
  104. ENDIF ( NOT Boost_FOUND )
  105. INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIRS} )
  106. ENDIF ( ASSIMP_ENABLE_BOOST_WORKAROUND )
  107. # cmake configuration files
  108. configure_file("${CMAKE_CURRENT_SOURCE_DIR}/assimp-config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config.cmake" @ONLY IMMEDIATE)
  109. configure_file("${CMAKE_CURRENT_SOURCE_DIR}/assimp-config-version.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config-version.cmake" @ONLY IMMEDIATE)
  110. install(FILES "${CMAKE_CURRENT_BINARY_DIR}/assimp-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config-version.cmake" DESTINATION "${ASSIMP_LIB_INSTALL_DIR}/cmake/assimp-${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}" COMPONENT ${LIBASSIMP-DEV_COMPONENT})
  111. SET ( ASSIMP_NO_EXPORT OFF CACHE BOOL
  112. "Disable Assimp's export functionality."
  113. )
  114. # Search for external dependencies, and build them from source if not found
  115. # Search for zlib
  116. find_package(ZLIB)
  117. if( NOT ZLIB_FOUND )
  118. message(STATUS "compiling zlib from souces")
  119. include(CheckIncludeFile)
  120. include(CheckTypeSize)
  121. include(CheckFunctionExists)
  122. # compile from sources
  123. add_subdirectory(contrib/zlib)
  124. set(ZLIB_FOUND 1)
  125. set(ZLIB_LIBRARIES zlibstatic)
  126. set(ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/contrib/zlib ${CMAKE_CURRENT_BINARY_DIR}/contrib/zlib)
  127. else(NOT ZLIB_FOUND)
  128. ADD_DEFINITIONS(-DASSIMP_BUILD_NO_OWN_ZLIB)
  129. endif(NOT ZLIB_FOUND)
  130. INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
  131. # Search for unzip
  132. if (PKG_CONFIG_FOUND)
  133. PKG_CHECK_MODULES(UNZIP minizip)
  134. endif (PKG_CONFIG_FOUND)
  135. IF ( ASSIMP_NO_EXPORT )
  136. ADD_DEFINITIONS( -DASSIMP_BUILD_NO_EXPORT)
  137. MESSAGE( STATUS "Build an import-only version of Assimp." )
  138. ENDIF( ASSIMP_NO_EXPORT )
  139. # if(CMAKE_CL_64)
  140. # set(ASSIMP_BUILD_ARCHITECTURE "amd64")
  141. # else(CMAKE_CL_64)
  142. # set(ASSIMP_BUILD_ARCHITECTURE "x86")
  143. # endif(CMAKE_CL_64)
  144. SET ( ASSIMP_BUILD_ARCHITECTURE "" CACHE STRING
  145. "describe the current architecture."
  146. )
  147. IF ( ASSIMP_BUILD_ARCHITECTURE STREQUAL "")
  148. ELSE ( ASSIMP_BUILD_ARCHITECTURE STREQUAL "")
  149. ADD_DEFINITIONS ( -D'ASSIMP_BUILD_ARCHITECTURE="${ASSIMP_BUILD_ARCHITECTURE}"' )
  150. ENDIF ( ASSIMP_BUILD_ARCHITECTURE STREQUAL "")
  151. # ${CMAKE_GENERATOR}
  152. SET ( ASSIMP_BUILD_COMPILER "" CACHE STRING
  153. "describe the current compiler."
  154. )
  155. IF ( ASSIMP_BUILD_COMPILER STREQUAL "")
  156. ELSE ( ASSIMP_BUILD_COMPILER STREQUAL "")
  157. ADD_DEFINITIONS ( -D'ASSIMP_BUILD_COMPILER="${ASSIMP_BUILD_COMPILER}"' )
  158. ENDIF ( ASSIMP_BUILD_COMPILER STREQUAL "")
  159. MARK_AS_ADVANCED ( ASSIMP_BUILD_ARCHITECTURE ASSIMP_BUILD_COMPILER )
  160. ADD_SUBDIRECTORY( code/ )
  161. SET ( ASSIMP_BUILD_ASSIMP_TOOLS ON CACHE BOOL
  162. "If the supplementary tools for Assimp are built in addition to the library."
  163. )
  164. IF ( ASSIMP_BUILD_ASSIMP_TOOLS )
  165. IF ( WIN32 )
  166. ADD_SUBDIRECTORY( tools/assimp_view/ )
  167. ENDIF ( WIN32 )
  168. ADD_SUBDIRECTORY( tools/assimp_cmd/ )
  169. ENDIF ( ASSIMP_BUILD_ASSIMP_TOOLS )
  170. SET ( ASSIMP_BUILD_SAMPLES OFF CACHE BOOL
  171. "If the official samples are built as well (needs Glut)."
  172. )
  173. IF ( ASSIMP_BUILD_SAMPLES)
  174. IF ( WIN32 )
  175. ADD_SUBDIRECTORY( samples/SimpleTexturedOpenGL/ )
  176. ENDIF ( WIN32 )
  177. ADD_SUBDIRECTORY( samples/SimpleOpenGL/ )
  178. ENDIF ( ASSIMP_BUILD_SAMPLES )
  179. IF ( WIN32 )
  180. SET ( ASSIMP_BUILD_TESTS ON CACHE BOOL
  181. "If the test suite for Assimp is built in addition to the library."
  182. )
  183. IF ( ASSIMP_BUILD_TESTS )
  184. ADD_SUBDIRECTORY( test/ )
  185. ENDIF ( ASSIMP_BUILD_TESTS )
  186. ENDIF ( WIN32 )
  187. IF(MSVC)
  188. SET ( ASSIMP_INSTALL_PDB ON CACHE BOOL
  189. "Install MSVC debug files."
  190. )
  191. ENDIF(MSVC)
  192. if(CMAKE_CPACK_COMMAND AND UNIX AND ASSIMP_OPT_BUILD_PACKAGES)
  193. # Packing information
  194. set(CPACK_PACKAGE_NAME "assimp{ASSIMP_VERSION_MAJOR}")
  195. set(CPACK_PACKAGE_CONTACT "" CACHE STRING "Package maintainer and PGP signer.")
  196. set(CPACK_PACKAGE_VENDOR "http://assimp.sourceforge.net/")
  197. set(CPACK_PACKAGE_DISPLAY_NAME "Assimp ${ASSIMP_VERSION}")
  198. set(CPACK_PACKAGE_DESCRIPTION_SUMMARY " - Open Asset Import Library ${ASSIMP_VERSION}")
  199. set(CPACK_PACKAGE_VERSION "${ASSIMP_VERSION}.${ASSIMP_PACKAGE_VERSION}" )
  200. set(CPACK_PACKAGE_VERSION_MAJOR "${ASSIMP_VERSION_MAJOR}")
  201. set(CPACK_PACKAGE_VERSION_MINOR "${ASSIMP_VERSION_MINOR}")
  202. set(CPACK_PACKAGE_VERSION_PATCH "${ASSIMP_VERSION_PATCH}")
  203. set(CPACK_PACKAGE_INSTALL_DIRECTORY "assimp${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}")
  204. #set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/description")
  205. set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
  206. string(TOUPPER ${LIBASSIMP_COMPONENT} "LIBASSIMP_COMPONENT_UPPER")
  207. string(TOUPPER ${LIBASSIMP-DEV_COMPONENT} "LIBASSIMP-DEV_COMPONENT_UPPER")
  208. set(CPACK_COMPONENT_ASSIMP-BIN_DISPLAY_NAME "tools")
  209. set(CPACK_COMPONENT_ASSIMP-BIN_DEPENDS "${LIBASSIMP_COMPONENT}" )
  210. set(CPACK_COMPONENT_${LIBASSIMP_COMPONENT_UPPER}_DISPLAY_NAME "libraries")
  211. set(CPACK_COMPONENT_${LIBASSIMP-DEV_COMPONENT_UPPER}_DISPLAY_NAME "common headers and installs")
  212. set(CPACK_COMPONENT_${LIBASSIMP-DEV_COMPONENT_UPPER}_DEPENDS $ "{LIBASSIMP_COMPONENT}" )
  213. set(CPACK_COMPONENT_ASSIMP-DEV_DISPLAY_NAME "${CPACK_COMPONENT_${LIBASSIMP-DEV_COMPONENT}_DISPLAY_NAME}" )
  214. set(CPACK_COMPONENT_ASSIMP-DEV_DEPENDS "${LIBASSIMP-DEV_COMPONENT}" )
  215. set(CPACK_DEBIAN_BUILD_DEPENDS debhelper cmake libboost-dev libboost-thread-dev libboost-math-dev zlib1g-dev pkg-config)
  216. # debian
  217. set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
  218. set(CPACK_DEBIAN_CMAKE_OPTIONS "-DBUILD_ASSIMP_SAMPLES:BOOL=${ASSIMP_BUILD_SAMPLES}")
  219. set(CPACK_DEBIAN_PACKAGE_SECTION "libs" )
  220. set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_COMPONENTS_ALL}")
  221. set(CPACK_DEBIAN_PACKAGE_SUGGESTS)
  222. set(CPACK_DEBIAN_PACKAGE_NAME "assimp")
  223. set(CPACK_DEBIAN_PACKAGE_REMOVE_SOURCE_FILES contrib/cppunit-1.12.1 contrib/cppunit_note.txt contrib/zlib workspaces test doc obj samples packaging)
  224. set(CPACK_DEBIAN_PACKAGE_SOURCE_COPY svn export --force)
  225. set(CPACK_DEBIAN_CHANGELOG)
  226. execute_process(COMMAND lsb_release -is
  227. OUTPUT_VARIABLE _lsb_distribution OUTPUT_STRIP_TRAILING_WHITESPACE
  228. RESULT_VARIABLE _lsb_release_failed)
  229. set(CPACK_DEBIAN_DISTRIBUTION_NAME ${_lsb_distribution} CACHE STRING "Name of the distrubiton")
  230. string(TOLOWER ${CPACK_DEBIAN_DISTRIBUTION_NAME} CPACK_DEBIAN_DISTRIBUTION_NAME)
  231. if( ${CPACK_DEBIAN_DISTRIBUTION_NAME} STREQUAL "ubuntu" )
  232. set(CPACK_DEBIAN_DISTRIBUTION_RELEASES lucid maverick natty oneiric precise CACHE STRING "Release code-names of the distrubiton release")
  233. endif()
  234. set(DPUT_HOST "" CACHE STRING "PPA repository to upload the debian sources")
  235. include(CPack)
  236. include(DebSourcePPA)
  237. endif()