CMakeLists.txt 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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. if(QT_FOUND)
  117. message(STATUS "QTfound ${QT_QT3SUPPORT_INCLUDE_DIR}")
  118. set(CMAKE_AUTOMOC TRUE) #see doc: http://blogs.kde.org/2011/11/01/cool-new-stuff-cmake-286-automoc
  119. INCLUDE(${QT_USE_FILE})
  120. ADD_DEFINITIONS(${QT_DEFINITIONS})
  121. ADD_DEFINITIONS( "-DNICE_USELIB_QT")
  122. endif()
  123. endif()
  124. NICE_OPTION(WITH_OPENGL "Build with OpenGL" ON)
  125. if(WITH_OPENGL)
  126. find_package(OpenGL)
  127. if(OPENGL_FOUND)
  128. message(STATUS "OPENGL found")
  129. include_directories( ${OPENGL_INCLUDE_DIRS} )
  130. ADD_DEFINITIONS( "-DNICE_USELIB_OPENGL")
  131. endif()
  132. #try using GLUT
  133. if(WIN32)
  134. message(STATUS "find GLUT for win32")
  135. set(GLUT_INCLUDE_DIR "C:/Libraries/freeglut-MSVC-2.8.0-1.mp/freeglut/include/")# , where to find GL/glut.h, etc.
  136. set(GLUT_ROOT_PATH "C:/Libraries/freeglut-MSVC-2.8.0-1.mp/freeglut/") # GLUT_LIBRARIES
  137. set(tmp_OPENGL_LIBRARY_DIR "${OPENGL_LIBRARY_DIR}") #temporarily store opengl_lib path
  138. set(OPENGL_LIBRARY_DIR "${GLUT_ROOT_PATH}lib")
  139. find_package(GLUT)
  140. if(GLUT_FOUND)
  141. message(STATUS "GLUT found")
  142. include_directories( ${GLUT_INCLUDE_DIR} )
  143. ADD_DEFINITIONS( -DNICE_USELIB_GLUT)
  144. #ADD_DEFINITIONS(-DBUILD_VTI -DFREEGLUT_STATIC) with static seems not to work
  145. endif()
  146. set(OPENGL_LIBRARY_DIR "${tmp_OPENGL_LIBRARY_DIR}") #reset opengl lib path
  147. else()
  148. find_package(GLUT)
  149. if(GLUT_FOUND)
  150. message(STATUS "GLUT found")
  151. include_directories( ${GLUT_INCLUDE_DIR} )
  152. ADD_DEFINITIONS(-DNICE_USELIB_GLUT)
  153. endif()
  154. endif()
  155. endif()
  156. if(NOT WIN32)
  157. #check for available regex stuff
  158. CHECK_INCLUDE_FILES(regex.h HAVE_REGEX_H)
  159. if(HAVE_REGEX_H)
  160. ADD_DEFINITIONS(-DNICE_USELIB_REGEX) #regular expressions are available per default under linux
  161. message(STATUS "Regex found")
  162. endif()
  163. endif()
  164. if(MSVC)
  165. #enable solution folders
  166. SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
  167. SET_PROPERTY(GLOBAL PROPERTY AUTOMOC_FOLDER automoc) #in future (>cmake1.8.11 this might separate the automoc projects into a separate solution folder)
  168. #in Visual Studio avoid overwriting of std::max with macro definition max() in WinDef.h (http://support.microsoft.com/kb/143208/de)
  169. ADD_DEFINITIONS("-DNOMINMAX")
  170. endif()
  171. NICE_OPTION(BUILD_UNITTESTS "Build all unit tests" ON IF CPPUNIT_FOUND)
  172. #if(CPPUNIT_FOUND)
  173. # set(BUILD_UNITTESTS ON)
  174. #else()
  175. # set(BUILD_UNITTESTS OFF)
  176. #endif()
  177. if( BUILD_UNITTESTS)
  178. enable_testing()
  179. include(CTest)
  180. endif()
  181. NICE_OPTION(BUILD_PROGRAMS "Build all programs" ON)
  182. set(OPENCV_LIB_INSTALL_PATH lib)
  183. INCLUDE_DIRECTORIES(".")
  184. INCLUDE_DIRECTORIES(core)
  185. set(the_module "nice")
  186. set(NICE_CURR_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
  187. SUBDIRLIST(__listSubDirs "${NICE_CURR_DIR}")
  188. set(__listSubLibs "")
  189. foreach(_curSubdir ${__listSubDirs})
  190. nice_get_real_path(__modpath "${NICE_CURR_DIR}/${_curSubdir}/")
  191. if(EXISTS "${__modpath}/CMakeLists.txt")
  192. #ADD_SUBDIRECTORY(${__modpath})
  193. LIST(APPEND __listSubLibs ${_curSubdir})
  194. NICE_OPTION(BUILD_LIB_${_curSubdir} "Build library ${_curSubdir}" ON)
  195. endif()
  196. endforeach()
  197. foreach(_curSublib ${__listSubLibs})
  198. if(BUILD_LIB_${_curSublib})
  199. nice_get_real_path(__modpath "${NICE_CURR_DIR}/${_curSublib}/")
  200. ADD_SUBDIRECTORY(${__modpath})
  201. endif()
  202. endforeach()
  203. # doxygen support
  204. #FIND_PROGRAM(DOXYGEN_EXECUTABLE "doxygen")
  205. ##############################################################################################
  206. configure_file(cmake/templates/NICELibraryConfigVersion.cmake.in "${PROJECT_BINARY_DIR}/NICELibraryConfigVersion.cmake" @ONLY)
  207. ##############################################################################################
  208. include (InstallRequiredSystemLibraries) # This module will include any runtime libraries that are needed by the project for the current platform
  209. SET(CPACK_GENERATOR "RPM")
  210. SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Johannes R.") #required
  211. SET(CPACK_PACKAGE_NAME "NICE New Image Library")
  212. SET(CPACK_PACKAGE_VENDOR "Computer Vision Group Jena, University of Jena")
  213. INCLUDE(CPack)