CMakeLists.txt 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. #cmake_minimum_required(VERSION 2.8.6) #version 2.8.6 at least required because of command set(CMAKE_AUTOMOC TRUE) for qt moc-ing (see below)
  2. cmake_minimum_required(VERSION 2.8.6)
  3. project (NICELibrary)
  4. include(CheckSymbolExists)
  5. include(CheckIncludeFiles)
  6. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
  7. include(cmake/NiceModules.cmake REQUIRED)
  8. # The version number.
  9. set(NICELibrary_VERSION_MAJOR 1)
  10. set(NICELibrary_VERSION_MINOR 2)
  11. set(NICE_VERSION ${NICELibrary_VERSION_MAJOR}.${NICELibrary_VERSION_MINOR})
  12. NICE_OPTION(NICE_BUILD_DEBUG "NICE Debug Build for debugging" OFF )
  13. if(NICE_BUILD_DEBUG)
  14. message(STATUS "NICE debug build enabled")
  15. set (CMAKE_BUILD_TYPE Debug)
  16. else()
  17. set (CMAKE_BUILD_TYPE Release)
  18. endif()
  19. NICE_OPTION(CMAKE_VERBOSE "Verbose mode" OFF )
  20. if(CMAKE_VERBOSE)
  21. set(CMAKE_VERBOSE_MAKEFILE 1)
  22. endif()
  23. set(CMAKE_INSTALL_PREFIX ${PROJECT_BINARY_DIR})
  24. set(NICE_SOURCEFILES_FIND_GLOBALLYRECURSIVE ON CACHE STRING "Scan a sublibraries directory for source files instead of using an explicit src file list")
  25. NICE_OPTION(WITH_BOOST "Build with Boost support" OFF)
  26. if(WITH_BOOST)
  27. set(Boost_USE_STATIC_LIBS ON)
  28. FIND_PACKAGE(Boost COMPONENTS date_time filesystem)
  29. IF (Boost_FOUND)
  30. message(STATUS "boost-incl-dir: ${Boost_INCLUDE_DIRS}")
  31. INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
  32. ADD_DEFINITIONS( "-DNICE_BOOST_FOUND" )
  33. ADD_DEFINITIONS( "-DNICE_USELIB_BOOST" )
  34. ENDIF()
  35. endif()
  36. FIND_PACKAGE(CppUnit)
  37. IF (CPPUNIT_FOUND)
  38. message(STATUS "CppUnit-dir: ${CPPUNIT_INCLUDE_DIR}")
  39. INCLUDE_DIRECTORIES(${CPPUNIT_INCLUDE_DIR})
  40. ADD_DEFINITIONS( "-DNICE_USELIB_CPPUNIT" )
  41. ADD_DEFINITIONS( "-DCPPUNIT_USE_TYPEINFO_NAME") #converting test class name into test name
  42. else()
  43. #set(CPPUNIT_INCLUDE_DIR "/usr/include/") #can be found in /usr/include/cppunit
  44. # ADD_DEFINITIONS( "-DNICE_USELIB_CPPUNIT" )
  45. message(STATUS "CppUnit not found")
  46. ENDIF()
  47. NICE_OPTION(WITH_DBV_LIBRARIES "Build with DBV extern librares" OFF)
  48. if(WITH_DBV_LIBRARIES)
  49. set(NICE_DBV_LIBRARIES_DIR "/home/dbv/3rdparty64-gcc43/")
  50. if(EXISTS "${NICE_DBV_LIBRARIES_DIR}")
  51. message(STATUS "using DBV extern librares in ${NICE_DBV_LIBRARIES_DIR}")
  52. NICE_OPTION(WITH_IPP "Build with Intel IPP support" ON)
  53. if(WITH_IPP)
  54. set(ENV{IPPROOT} "${NICE_DBV_LIBRARIES_DIR}ipp53/")
  55. include("cmake/NiceFindIPP.cmake")
  56. if(IPP_FOUND)
  57. #message(STATUS "ipp link dir: ${IPP_LIBRARY_DIRS}")
  58. #message(STATUS "ipp link libs: ${IPP_LIBRARIES}")
  59. ADD_DEFINITIONS( "-DNICE_USELIB_IPP=5" )
  60. INCLUDE_DIRECTORIES(${IPP_INCLUDE_DIRS})
  61. else()
  62. message(STATUS "IPP library not found")
  63. endif()
  64. endif()
  65. else()
  66. message( SEND_ERROR "trying to use DBV extern library dir, but couldn't be found ${NICE_DBV_LIBRARIES_DIR}. Switch off DBV Usage to continue.") #unsetting dbv libraries path
  67. unset(WITH_DBV_LIBRARIES) #unsetting, since dbv dir not found
  68. endif()
  69. endif()
  70. NICE_OPTION(WITH_OPENMP "Build with OpenMP support" ON)
  71. if(WITH_OPENMP)
  72. find_package(OpenMP)
  73. if (OPENMP_FOUND)
  74. set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
  75. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
  76. ADD_DEFINITIONS( "-DNICE_USELIB_OPENMP")
  77. endif()
  78. endif()
  79. NICE_OPTION(WITH_PNG "Build with libPNG support" OFF)
  80. if(WITH_PNG)
  81. find_package(PNG)
  82. if (PNG_FOUND)
  83. INCLUDE_DIRECTORIES(${PNG_INCLUDE_DIRS})
  84. ADD_DEFINITIONS( "-DNICE_USELIB_PNG")
  85. endif()
  86. endif()
  87. NICE_OPTION(WITH_MATIO "Build with Matio and HDF5 support" OFF)
  88. if(WITH_MATIO)
  89. find_package(HDF5)
  90. if(HDF5_FOUND)
  91. message(STATUS "HDF5-dir: ${HDF5_INCLUDE_DIR}")
  92. endif()
  93. find_package(MATIO)
  94. if(MATIO_FOUND)
  95. message(STATUS "Matio-dir: ${MATIO_INCLUDE_DIRS}")
  96. ADD_DEFINITIONS( "-DNICE_USELIB_MATIO")
  97. INCLUDE_DIRECTORIES(${MATIO_INCLUDE_DIRS})
  98. endif()
  99. endif()
  100. NICE_OPTION(WITH_IMAGEMAGICK "Build with ImageMagick++" OFF)
  101. if(WITH_IMAGEMAGICK)
  102. find_package(ImageMagick COMPONENTS Magick++ MagickCore)
  103. if(ImageMagick_FOUND)
  104. message(STATUS "imagemagick found: ${ImageMagick_LIBRARIES}")
  105. ADD_DEFINITIONS( "-DNICE_USELIB_LIBMAGICK")
  106. INCLUDE_DIRECTORIES(${ImageMagick_INCLUDE_DIRS})
  107. else()
  108. message(STATUS "imagemagick not found")
  109. endif()
  110. endif()
  111. NICE_OPTION(WITH_QT "Build with Qt" ON)
  112. if(WITH_QT)
  113. FIND_PACKAGE(Qt4 REQUIRED)# COMPONENTS Qt3Support QtOpenGl)
  114. SET(QT_USE_QTOPENGL TRUE)
  115. SET(QT_USE_QTXML TRUE)
  116. SET(QT_USE_QT3SUPPORT TRUE)
  117. if(QT_FOUND)
  118. message(STATUS "QTfound ${QT_QT3SUPPORT_INCLUDE_DIR}")
  119. set(CMAKE_AUTOMOC TRUE) #see doc: http://blogs.kde.org/2011/11/01/cool-new-stuff-cmake-286-automoc
  120. INCLUDE(${QT_USE_FILE})
  121. ADD_DEFINITIONS(${QT_DEFINITIONS})
  122. ADD_DEFINITIONS( "-DNICE_USELIB_QT")
  123. endif()
  124. endif()
  125. NICE_OPTION(WITH_OPENGL "Build with OpenGL" ON)
  126. if(WITH_OPENGL)
  127. find_package(OpenGL)
  128. if(OPENGL_FOUND)
  129. message(STATUS "OPENGL found")
  130. include_directories( ${OPENGL_INCLUDE_DIRS} )
  131. ADD_DEFINITIONS( "-DNICE_USELIB_OPENGL")
  132. endif()
  133. #try using GLUT
  134. if(WIN32)
  135. message(STATUS "find GLUT for win32")
  136. set(GLUT_INCLUDE_DIR "C:/Libraries/freeglut-MSVC-2.8.0-1.mp/freeglut/include/")# , where to find GL/glut.h, etc.
  137. set(GLUT_ROOT_PATH "C:/Libraries/freeglut-MSVC-2.8.0-1.mp/freeglut/") # GLUT_LIBRARIES
  138. set(tmp_OPENGL_LIBRARY_DIR "${OPENGL_LIBRARY_DIR}") #temporarily store opengl_lib path
  139. set(OPENGL_LIBRARY_DIR "${GLUT_ROOT_PATH}lib")
  140. find_package(GLUT)
  141. if(GLUT_FOUND)
  142. message(STATUS "GLUT found")
  143. include_directories( ${GLUT_INCLUDE_DIR} )
  144. ADD_DEFINITIONS( -DNICE_USELIB_GLUT)
  145. #ADD_DEFINITIONS(-DBUILD_VTI -DFREEGLUT_STATIC) with static seems not to work
  146. endif()
  147. set(OPENGL_LIBRARY_DIR "${tmp_OPENGL_LIBRARY_DIR}") #reset opengl lib path
  148. else()
  149. find_package(GLUT)
  150. if(GLUT_FOUND)
  151. message(STATUS "GLUT found")
  152. include_directories( ${GLUT_INCLUDE_DIR} )
  153. ADD_DEFINITIONS(-DNICE_USELIB_GLUT)
  154. endif()
  155. endif()
  156. endif()
  157. if(NOT WIN32)
  158. #check for available regex stuff
  159. CHECK_INCLUDE_FILES(regex.h HAVE_REGEX_H)
  160. if(HAVE_REGEX_H)
  161. ADD_DEFINITIONS(-DNICE_USELIB_REGEX) #regular expressions are available per default under linux
  162. message(STATUS "Regex found")
  163. endif()
  164. endif()
  165. if(MSVC)
  166. #enable solution folders
  167. SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
  168. SET_PROPERTY(GLOBAL PROPERTY AUTOMOC_FOLDER automoc) #in future (>cmake1.8.11 this might separate the automoc projects into a separate solution folder)
  169. #in Visual Studio avoid overwriting of std::max with macro definition max() in WinDef.h (http://support.microsoft.com/kb/143208/de)
  170. ADD_DEFINITIONS("-DNOMINMAX")
  171. endif()
  172. NICE_OPTION(BUILD_UNITTESTS "Build all unit tests" ON IF CPPUNIT_FOUND)
  173. #if(CPPUNIT_FOUND)
  174. # set(BUILD_UNITTESTS ON)
  175. #else()
  176. # set(BUILD_UNITTESTS OFF)
  177. #endif()
  178. if( BUILD_UNITTESTS)
  179. enable_testing()
  180. include(CTest)
  181. endif()
  182. NICE_OPTION(BUILD_PROGRAMS "Build all programs" ON)
  183. set(OPENCV_LIB_INSTALL_PATH lib)
  184. INCLUDE_DIRECTORIES(".")
  185. INCLUDE_DIRECTORIES(core)
  186. set(the_module "nice")
  187. set(NICE_CURR_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
  188. SUBDIRLIST(__listSubDirs "${NICE_CURR_DIR}")
  189. set(__listSubLibs "")
  190. foreach(_curSubdir ${__listSubDirs})
  191. nice_get_real_path(__modpath "${NICE_CURR_DIR}/${_curSubdir}/")
  192. if(EXISTS "${__modpath}/CMakeLists.txt")
  193. #ADD_SUBDIRECTORY(${__modpath})
  194. LIST(APPEND __listSubLibs ${_curSubdir})
  195. NICE_OPTION(BUILD_LIB_${_curSubdir} "Build library ${_curSubdir}" ON)
  196. endif()
  197. endforeach()
  198. foreach(_curSublib ${__listSubLibs})
  199. if(BUILD_LIB_${_curSublib})
  200. nice_get_real_path(__modpath "${NICE_CURR_DIR}/${_curSublib}/")
  201. ADD_SUBDIRECTORY(${__modpath})
  202. endif()
  203. endforeach()
  204. # doxygen support
  205. #FIND_PROGRAM(DOXYGEN_EXECUTABLE "doxygen")
  206. ##############################################################################################
  207. configure_file(cmake/templates/NICELibraryConfigVersion.cmake.in "${PROJECT_BINARY_DIR}/NICELibraryConfigVersion.cmake" @ONLY)
  208. ##############################################################################################
  209. include (InstallRequiredSystemLibraries) # This module will include any runtime libraries that are needed by the project for the current platform
  210. SET(CPACK_GENERATOR "RPM")
  211. SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Johannes R.") #required
  212. SET(CPACK_PACKAGE_NAME "NICE New Image Library")
  213. SET(CPACK_PACKAGE_VENDOR "Computer Vision Group Jena, University of Jena")
  214. INCLUDE(CPack)