CMakeLists.txt 8.3 KB

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