Amarok – versatile and easy to use audio player
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

389 lines
10 KiB

  1. #################################################
  2. #
  3. # (C) 2010 Serghei Amelian
  4. # serghei (DOT) amelian (AT) gmail.com
  5. #
  6. # Improvements and feedback are welcome
  7. #
  8. # This file is released under GPL >= 2
  9. #
  10. #################################################
  11. # required stuff
  12. find_package( TQt )
  13. find_package( TDE )
  14. tde_setup_architecture_flags( )
  15. include(TestBigEndian)
  16. test_big_endian(WORDS_BIGENDIAN)
  17. tde_setup_largefiles( )
  18. ##### check for gcc visibility support
  19. if( WITH_GCC_VISIBILITY )
  20. tde_setup_gcc_visibility( )
  21. endif( WITH_GCC_VISIBILITY )
  22. find_package( Threads )
  23. find_package( X11 )
  24. check_type_size( "int" SIZEOF_INT BUILTIN_TYPES_ONLY )
  25. check_type_size( "long" SIZEOF_LONG BUILTIN_TYPES_ONLY )
  26. check_include_file( stdint.h HAVE_STDINT_H )
  27. check_include_file( systems.h HAVE_SYSTEMS_H )
  28. ##### check for inotify ###########################
  29. if( WITH_INOTIFY )
  30. check_include_file( "inotify.h" INOTIFY_FOUND )
  31. check_include_file( "sys/inotify.h" INOTIFY_SYS_FOUND )
  32. if( NOT INOTIFY_FOUND )
  33. if( NOT INOTIFY_SYS_FOUND )
  34. message(FATAL_ERROR "\ninotify support was requested, but inotify was not found on your system" )
  35. endif( NOT INOTIFY_SYS_FOUND )
  36. endif( NOT INOTIFY_FOUND )
  37. if( INOTIFY_FOUND )
  38. set( HAVE_INOTIFY 1 )
  39. endif( INOTIFY_FOUND )
  40. if( INOTIFY_SYS_FOUND )
  41. set( HAVE_INOTIFY 1 )
  42. set( HAVE_SYS_INOTIFY 1 )
  43. endif( INOTIFY_SYS_FOUND )
  44. endif( )
  45. check_function_exists( statvfs HAVE_STATVFS )
  46. # sched_setaffinity buggy glibc check
  47. check_c_source_compiles("
  48. #define _GNU_SOURCE
  49. #include <sched.h>
  50. int main() {
  51. cpu_set_t mask;
  52. CPU_ZERO(&mask);
  53. CPU_SET(0, &mask);
  54. sched_setaffinity(0, sizeof(mask), &mask);
  55. return 0;
  56. } "
  57. SCHEDAFFINITY_3PARAMS )
  58. if( SCHEDAFFINITY_3PARAMS )
  59. set( SCHEDAFFINITY_SUPPORT 1 )
  60. else( )
  61. check_c_source_compiles("
  62. #define _GNU_SOURCE
  63. #include <sched.h>
  64. int main() {
  65. cpu_set_t mask;
  66. CPU_ZERO(&mask);
  67. CPU_SET(0, &mask);
  68. sched_setaffinity(0, &mask);
  69. return 0;
  70. } "
  71. SCHEDAFFINITY_SUPPORT )
  72. endif( )
  73. # fabsf
  74. tde_save( CMAKE_REQUIRED_LIBRARIES )
  75. set( CMAKE_REQUIRED_LIBRARIES m )
  76. check_function_exists( fabsf HAVE_FABSF )
  77. tde_restore( CMAKE_REQUIRED_LIBRARIES )
  78. # taglib
  79. pkg_search_module( TAGLIB taglib )
  80. if( TAGLIB_FOUND )
  81. if( ${TAGLIB_VERSION} VERSION_LESS "1.5" )
  82. tde_message_fatal( "taglib version must be at least 1.5" )
  83. else( )
  84. set( TAGLIB_15 1 )
  85. message( STATUS "Found TAGLIB: ${TAGLIB_INCLUDE_DIRS}" )
  86. endif( )
  87. else( )
  88. tde_message_fatal( "taglib is required, but not found on your system" )
  89. endif( )
  90. # libvisual
  91. if( WITH_LIBVISUAL )
  92. pkg_search_module( SDL sdl )
  93. if( NOT SDL_FOUND )
  94. check_include_file( SDL/SDL.h HAVE_SDL_H )
  95. if( NOT HAVE_SDL_H )
  96. tde_message_fatal( "SDL is required, but not found on your system" )
  97. endif ( )
  98. set ( SDL_INCLUDE_DIRS /usr/include/SDL )
  99. set ( SDL_LIBRARIES SDL pthread )
  100. endif( )
  101. pkg_search_module( LIBVISUAL libvisual-0.4 )
  102. if( LIBVISUAL_FOUND )
  103. if( ${LIBVISUAL_VERSION} VERSION_LESS "0.4.0" )
  104. tde_message_fatal( "libvisual version must be at least 0.4.0" )
  105. endif( )
  106. else( )
  107. tde_message_fatal( "libvisual is requested, but not found on your system" )
  108. endif( )
  109. set( HAVE_LIBVISUAL 1 )
  110. endif( )
  111. # xine-engine
  112. if( WITH_XINE )
  113. pkg_search_module( XINE libxine )
  114. if( XINE_FOUND )
  115. if( ${XINE_VERSION} VERSION_LESS "1.0.2" )
  116. tde_message_fatal( "your xine version is too old; at least 1.0.2 is required" )
  117. endif( )
  118. else( )
  119. tde_message_fatal( "xine is requested, but was not found on your system" )
  120. endif( )
  121. endif( )
  122. # akode-engine
  123. if( WITH_AKODE )
  124. pkg_search_module( AKODE akode )
  125. if( AKODE_FOUND )
  126. if( ${AKODE_VERSION} VERSION_LESS "2.0.0" )
  127. tde_message_fatal( "your akode version is too old; at least 2.0.0 is required" )
  128. endif( )
  129. else( )
  130. tde_message_fatal( "akode is requested, but was not found on your system" )
  131. endif( )
  132. endif( )
  133. ##### check for libgpod - iPod
  134. if( WITH_IPOD )
  135. pkg_search_module( GLIB2 glib-2.0 )
  136. pkg_search_module( GPOD libgpod-1.0 )
  137. if( GPOD_FOUND )
  138. if( ${GPOD_VERSION} VERSION_LESS "0.4.2" )
  139. tde_message_fatal( "your libgpod version is too old; at least 0.4.2 is required" )
  140. elseif( NOT ${GPOD_VERSION} VERSION_LESS "0.6.0" )
  141. set( HAVE_GPOD_060 1 )
  142. endif( )
  143. else( )
  144. tde_message_fatal( "libgpod-1.0 is requested, but was not found on your system" )
  145. endif( )
  146. tde_save( CMAKE_REQUIRED_INCLUDES )
  147. set( CMAKE_REQUIRED_INCLUDES ${GPOD_INCLUDE_DIRS} )
  148. check_struct_has_member( "struct _Itdb_Track" mediatype "gpod/itdb.h" HAVE_ITDB_MEDIATYPE )
  149. tde_restore( CMAKE_REQUIRED_INCLUDES )
  150. set( GPOD_LIBRARY gpod )
  151. endif( )
  152. if( WITH_OPENGL )
  153. set( OpenGL_GL_PREFERENCE LEGACY )
  154. find_package( GLUT )
  155. find_package( OpenGL )
  156. ##### check for OpenGL support within tqt
  157. tde_save( CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_LIBRARIES )
  158. set( CMAKE_REQUIRED_INCLUDES ${TQT_INCLUDE_DIRS} )
  159. set( CMAKE_REQUIRED_LIBRARIES -L${TQT_LIBRARY_DIRS} ${TQT_LIBRARIES} )
  160. check_cxx_source_compiles("
  161. #include <cstdlib>
  162. #include <tqgl.h>
  163. int main( int, char** )
  164. {
  165. (void) new TQGLWidget( (TQWidget*)0, \"qgl\" ) ;
  166. return EXIT_SUCCESS ;
  167. }"
  168. HAVE_TQGLWIDGET )
  169. tde_restore( CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_LIBRARIES )
  170. endif( WITH_OPENGL )
  171. # konqsidebarplugin.h
  172. if( WITH_KONQSIDEBAR )
  173. tde_save( CMAKE_REQUIRED_DEFINITIONS CMAKE_REQUIRED_FLAGS CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_LIBRARIES )
  174. set( CMAKE_REQUIRED_DEFINITIONS ${TQT_CFLAGS_OTHER} )
  175. set( CMAKE_REQUIRED_INCLUDES ${TDE_INCLUDE_DIR};${TQT_INCLUDE_DIRS};${CMAKE_INCLUDE_PATH} )
  176. set( CMAKE_REQUIRED_FLAGS "-include tqt.h" )
  177. set( CMAKE_REQUIRED_LIBRARIES -L${TQT_LIBRARY_DIRS} -L${TQT_LIBRARY_DIRS} ${TQT_LIBRARIES} )
  178. check_cxx_source_compiles("
  179. #include <konqsidebarplugin.h>
  180. int main(int, char**) { return 0; } "
  181. HAVE_KONQSIDEBARPLUGIN_H )
  182. tde_restore( CMAKE_REQUIRED_DEFINITIONS CMAKE_REQUIRED_FLAGS CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_LIBRARIES )
  183. if( NOT HAVE_KONQSIDEBARPLUGIN_H )
  184. tde_message_fatal( "Konqueror sidebar is requested, but konqsidebarplugin.h was not found on your system" )
  185. endif( )
  186. endif( )
  187. if( WITH_MP4V2 )
  188. ##### check for mp4v2
  189. check_include_file( "mp4v2/mp4v2.h" MP4V2_H_FOUND )
  190. if( MP4V2_H_FOUND )
  191. set( HAVE_MP4V2_H 1)
  192. find_path( MP4V2_INCLUDE_DIR "mp4v2/mp4v2.h" )
  193. set( MP4V2_INCLUDE_DIRS "${MP4V2_INCLUDE_DIR}" )
  194. find_library( MP4V2_LIBRARY mp4v2 )
  195. set( MP4V2_LIBRARIES "${MP4V2_LIBRARY}" )
  196. endif()
  197. check_include_file( "mp4.h" MP4_H_FOUND )
  198. if( MP4_H_FOUND )
  199. set( HAVE_MP4_H 1)
  200. find_path( MP4_INCLUDE_DIR "mp4.h" )
  201. set( MP4V2_INCLUDE_DIRS "${MP4_INCLUDE_DIR}" )
  202. find_library( MP4_LIBRARY mp4 )
  203. set( MP4V2_LIBRARIES "${MP4_LIBRARY}" )
  204. endif()
  205. if( HAVE_MP4V2_H OR HAVE_MP4_H )
  206. set( HAVE_MP4V2 1 )
  207. else()
  208. tde_message_fatal( "MP4V2 support was requested but was not found on your system" )
  209. endif()
  210. endif( WITH_MP4V2 )
  211. if( WITH_MYSQL )
  212. #### check for MySql or Mariadb
  213. message( STATUS "Check for MariaDB or MySQL" )
  214. find_program( MYSQL_CONFIG NAMES mariadb_config mysql_config )
  215. if( NOT MYSQL_CONFIG )
  216. tde_message_fatal( "MySql support is requested but neither MySql or Mariadb have been found on your system" )
  217. else()
  218. macro( _mysql_config __type __var )
  219. execute_process(
  220. COMMAND ${MYSQL_CONFIG} --${__type}
  221. OUTPUT_VARIABLE ${__var}
  222. RESULT_VARIABLE __result
  223. OUTPUT_STRIP_TRAILING_WHITESPACE )
  224. if( _result )
  225. tde_message_fatal( "Unable to run ${MYSQL_CONFIG}!" )
  226. endif()
  227. endmacro()
  228. _mysql_config( include MYSQL_INCLUDE_DIRS )
  229. _mysql_config( libs MYSQL_LIBRARIES )
  230. if( MYSQL_INCLUDE_DIRS )
  231. string( REGEX REPLACE "(^| +)-I" ";" MYSQL_INCLUDE_DIRS "${MYSQL_INCLUDE_DIRS}" )
  232. endif()
  233. if( MYSQL_LIBRARIES )
  234. string( REGEX REPLACE "(^| +)-l" ";" MYSQL_LIBRARIES "${MYSQL_LIBRARIES}" )
  235. endif( )
  236. set( MYSQL_INCLUDE_DIRS "${MYSQL_INCLUDE_DIRS}" CACHE INTERNAL "" FORCE )
  237. set( MYSQL_LIBRARIES "${MYSQL_LIBRARIES}" CACHE INTERNAL "" FORCE )
  238. message( STATUS " includes ${MYSQL_INCLUDE_DIRS} ")
  239. message( STATUS " libraries ${MYSQL_LIBRARIES} ")
  240. set( USE_MYSQL 1 )
  241. tde_save_and_set( CMAKE_REQUIRED_INCLUDES ${MYSQL_INCLUDE_DIRS} )
  242. check_cxx_source_compiles("
  243. #include <mysql.h>
  244. typedef struct st_mysql MYSQL;
  245. int main(int, char**)
  246. {
  247. return 1;
  248. }"
  249. HAVE_STRUCT_ST_MYSQL )
  250. if( HAVE_STRUCT_ST_MYSQL )
  251. set( MYSQL_STRUCT "st_mysql" )
  252. else()
  253. check_cxx_source_compiles("
  254. #include <mysql.h>
  255. typedef struct MYSQL MYSQL;
  256. int main()
  257. {
  258. return 1;
  259. }"
  260. HAVE_STRUCT_MYSQL )
  261. if( HAVE_STRUCT_MYSQL )
  262. set( MYSQL_STRUCT "MYSQL" )
  263. else()
  264. tde_message_fatal( "MySQL is requested, but it is not possible to determine the type of MySQL structure" )
  265. endif()
  266. endif()
  267. tde_restore( CMAKE_REQUIRED_INCLUDES )
  268. endif( NOT MYSQL_CONFIG )
  269. endif( WITH_MYSQL )
  270. if( WITH_POSTGRESQL )
  271. ##### check for PostgreSQL
  272. message( STATUS "Check for PostgreSQL" )
  273. find_package( PostgreSQL )
  274. if( PostgreSQL_INCLUDE_DIR AND PostgreSQL_LIBRARY )
  275. message( STATUS " includes ${PostgreSQL_INCLUDE_DIR} ")
  276. message( STATUS " library ${PostgreSQL_LIBRARY} ")
  277. set( USE_POSTGRESQL 1 )
  278. else()
  279. pkg_search_module( LIBPQ libpq )
  280. if( NOT LIBPQ_FOUND )
  281. tde_message_fatal( "Postgresql support is requested but Postgresql was not found on your system." )
  282. endif()
  283. set( PostgreSQL_INCLUDE_DIR "${LIBPQ_INCLUDE_DIRS}" )
  284. set( PostgreSQL_LIBRARY "${LIBPQ_LIBRARIES}" )
  285. set( PostgreSQL_LIBRARY_DIRS "${LIBPQ_LIBRARY_DIRS}" )
  286. set( USE_POSTGRESQL 1 )
  287. endif()
  288. endif( WITH_POSTGRESQL )
  289. if( WITH_EMBEDDED_SQLITE )
  290. set( SQLITE_LIBRARIES sqlite-static )
  291. message( STATUS "sqlite3 linking: ${SQLITE_LIBRARIES}" )
  292. endif()
  293. if( WITH_SYSTEM_SQLITE )
  294. ##### check for sqlite3
  295. pkg_search_module( SQLITE sqlite3 )
  296. if( NOT SQLITE_FOUND )
  297. tde_message_fatal( "sqlite3 is required, but not found on your system" )
  298. else()
  299. message( STATUS "sqlite3 linking: ${SQLITE_LIBRARIES}" )
  300. endif( )
  301. endif( WITH_SYSTEM_SQLITE )
  302. if( WITH_AMAZON )
  303. set( AMAZON_SUPPORT 1 )
  304. endif()