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.

CMakeLists.txt 6.1 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR)
  2. set(PROJECT_NAME slim)
  3. project(${PROJECT_NAME})
  4. #Pretty colors
  5. set(CMAKE_COLOR_MAKEFILE ON)
  6. #Dont force verbose
  7. set(CMAKE_VERBOSE_MAKEFILE ON)
  8. #Include current dir
  9. set(CMAKE_INCLUDE_CURRENT_DIR TRUE)
  10. INCLUDE(CheckIncludeFile)
  11. INCLUDE(CheckCCompilerFlag)
  12. INCLUDE(CheckCXXCompilerFlag)
  13. INCLUDE(CheckTypeSize)
  14. # Version
  15. set(SLIM_VERSION_MAJOR "1")
  16. set(SLIM_VERSION_MINOR "3")
  17. set(SLIM_VERSION_PATCH "6")
  18. set(SLIM_VERSION "${SLIM_VERSION_MAJOR}.${SLIM_VERSION_MINOR}.${SLIM_VERSION_PATCH}")
  19. set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Installation Directory")
  20. set(PKGDATADIR "${CMAKE_INSTALL_PREFIX}/share/slim")
  21. set(SYSCONFDIR "/etc")
  22. set(LIBDIR "/lib")
  23. set(MANDIR "${CMAKE_INSTALL_PREFIX}/share/man")
  24. set(SLIM_DEFINITIONS)
  25. if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR
  26. ${CMAKE_SYSTEM_NAME} MATCHES "NetBSD" OR
  27. ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD"
  28. )
  29. set(SLIM_DEFINITIONS ${SLIM_DEFINITIONS} "-DNEEDS_BASENAME")
  30. else()
  31. set(SLIM_DEFINITIONS ${SLIM_DEFINITIONS} "-DHAVE_SHADOW")
  32. endif()
  33. set(SLIM_DEFINITIONS ${SLIM_DEFINITIONS} "-DPACKAGE=\"slim\"")
  34. set(SLIM_DEFINITIONS ${SLIM_DEFINITIONS} "-DVERSION=\"${SLIM_VERSION}\"")
  35. set(SLIM_DEFINITIONS ${SLIM_DEFINITIONS} "-DPKGDATADIR=\"${PKGDATADIR}\"")
  36. set(SLIM_DEFINITIONS ${SLIM_DEFINITIONS} "-DSYSCONFDIR=\"${SYSCONFDIR}\"")
  37. # Flags
  38. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -g -O2")
  39. set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} -Wall -g -O2")
  40. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -g -O2")
  41. # source
  42. set(slim_srcs
  43. main.cpp
  44. app.cpp
  45. numlock.cpp
  46. switchuser.cpp
  47. png.c
  48. jpeg.c
  49. )
  50. set(slimlock_srcs
  51. slimlock.cpp
  52. )
  53. set(common_srcs
  54. cfg.cpp
  55. image.cpp
  56. log.cpp
  57. panel.cpp
  58. util.cpp
  59. )
  60. if(USE_PAM)
  61. set(common_srcs ${common_srcs} PAM.cpp)
  62. # for now, only build slimlock if we are using PAM.
  63. set(BUILD_SLIMLOCK 1)
  64. endif(USE_PAM)
  65. # Build common library
  66. set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries")
  67. if (BUILD_SHARED_LIBS)
  68. message(STATUS "Enable shared library building")
  69. add_library(libslim ${common_srcs})
  70. else(BUILD_SHARED_LIBS)
  71. message(STATUS "Disable shared library building")
  72. add_library(libslim STATIC ${common_srcs})
  73. endif(BUILD_SHARED_LIBS)
  74. if(USE_CONSOLEKIT)
  75. set(slim_srcs ${slim_srcs} Ck.cpp)
  76. endif(USE_CONSOLEKIT)
  77. add_executable(${PROJECT_NAME} ${slim_srcs})
  78. if(BUILD_SLIMLOCK)
  79. add_executable(slimlock ${slimlock_srcs})
  80. endif(BUILD_SLIMLOCK)
  81. #Set the custom CMake module directory where our include/lib finders are
  82. set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
  83. find_package(X11 REQUIRED)
  84. find_package(Freetype REQUIRED)
  85. find_package(JPEG REQUIRED)
  86. find_package(PNG REQUIRED)
  87. find_package(ZLIB REQUIRED)
  88. # Fontconfig
  89. set(FONTCONFIG_DIR ${CMAKE_MODULE_PATH})
  90. find_package(FONTCONFIG REQUIRED)
  91. if(FONTCONFIG_FOUND)
  92. message("\tFontConfig Found")
  93. target_link_libraries(${PROJECT_NAME} ${FONTCONFIG_LIBRARY})
  94. include_directories(${FONTCONFIG_INCLUDE_DIR})
  95. endif(FONTCONFIG_FOUND)
  96. # PAM
  97. if(USE_PAM)
  98. message("\tPAM Enabled")
  99. find_package(PAM)
  100. if(PAM_FOUND)
  101. message("\tPAM Found")
  102. set(SLIM_DEFINITIONS ${SLIM_DEFINITIONS} "-DUSE_PAM")
  103. target_link_libraries(${PROJECT_NAME} ${PAM_LIBRARY})
  104. target_link_libraries(slimlock ${PAM_LIBRARY})
  105. include_directories(${PAM_INCLUDE_DIR})
  106. else(PAM_FOUND)
  107. message("\tPAM Not Found")
  108. endif(PAM_FOUND)
  109. else(USE_PAM)
  110. message("\tPAM disabled")
  111. endif(USE_PAM)
  112. # ConsoleKit
  113. if(USE_CONSOLEKIT)
  114. find_package(CkConnector)
  115. message("\tConsoleKit Enabled")
  116. if(CKCONNECTOR_FOUND)
  117. message("\tConsoleKit Found")
  118. # DBus check
  119. find_package(DBus REQUIRED)
  120. if(DBUS_FOUND)
  121. message("\tDBus Found")
  122. target_link_libraries(${PROJECT_NAME} ${DBUS_LIBRARIES})
  123. include_directories(${DBUS_ARCH_INCLUDE_DIR})
  124. include_directories(${DBUS_INCLUDE_DIR})
  125. set(SLIM_DEFINITIONS ${SLIM_DEFINITIONS} "-DUSE_CONSOLEKIT")
  126. target_link_libraries(${PROJECT_NAME} ${CKCONNECTOR_LIBRARIES})
  127. include_directories(${CKCONNECTOR_INCLUDE_DIR})
  128. else(DBUS_FOUND)
  129. message("\tDBus Not Found")
  130. endif(DBUS_FOUND)
  131. else(CKCONNECTOR_FOUND)
  132. message("\tConsoleKit Not Found")
  133. message("\tConsoleKit disabled")
  134. endif(CKCONNECTOR_FOUND)
  135. else(USE_CONSOLEKIT)
  136. message("\tConsoleKit disabled")
  137. endif(USE_CONSOLEKIT)
  138. # system librarys
  139. find_library(M_LIB m)
  140. find_library(RT_LIB rt)
  141. find_library(CRYPTO_LIB crypt)
  142. find_package(Threads)
  143. add_definitions(${SLIM_DEFINITIONS})
  144. #Set up include dirs with all found packages
  145. include_directories(
  146. ${X11_INCLUDE_DIR}
  147. ${X11_Xft_INCLUDE_PATH}
  148. ${X11_Xrender_INCLUDE_PATH}
  149. ${X11_Xrandr_INCLUDE_PATH}
  150. ${FREETYPE_INCLUDE_DIR_freetype2}
  151. ${X11_Xmu_INCLUDE_PATH}
  152. ${ZLIB_INCLUDE_DIR}
  153. ${JPEG_INCLUDE_DIR}
  154. ${PNG_INCLUDE_DIR}
  155. )
  156. target_link_libraries(libslim
  157. ${JPEG_LIBRARIES}
  158. ${PNG_LIBRARIES}
  159. )
  160. #Set up library with all found packages for slim
  161. target_link_libraries(${PROJECT_NAME}
  162. ${M_LIB}
  163. ${RT_LIB}
  164. ${CRYPTO_LIB}
  165. ${X11_X11_LIB}
  166. ${X11_Xft_LIB}
  167. ${X11_Xrender_LIB}
  168. ${X11_Xrandr_LIB}
  169. ${X11_Xmu_LIB}
  170. ${FREETYPE_LIBRARY}
  171. ${JPEG_LIBRARIES}
  172. ${PNG_LIBRARIES}
  173. libslim
  174. )
  175. if(BUILD_SLIMLOCK)
  176. #Set up library with all found packages for slimlock
  177. target_link_libraries(slimlock
  178. ${M_LIB}
  179. ${RT_LIB}
  180. ${CRYPTO_LIB}
  181. ${X11_X11_LIB}
  182. ${X11_Xft_LIB}
  183. ${X11_Xrender_LIB}
  184. ${X11_Xrandr_LIB}
  185. ${X11_Xmu_LIB}
  186. ${X11_Xext_LIB}
  187. ${FREETYPE_LIBRARY}
  188. ${JPEG_LIBRARIES}
  189. ${PNG_LIBRARIES}
  190. ${CMAKE_THREAD_LIBS_INIT}
  191. libslim
  192. )
  193. endif(BUILD_SLIMLOCK)
  194. ####### install
  195. # slim
  196. install(TARGETS slim RUNTIME DESTINATION bin)
  197. install(TARGETS slimlock RUNTIME DESTINATION bin)
  198. if (BUILD_SHARED_LIBS)
  199. set_target_properties(libslim PROPERTIES
  200. OUTPUT_NAME slim
  201. SOVERSION ${SLIM_VERSION})
  202. install(TARGETS libslim
  203. LIBRARY DESTINATION lib
  204. ARCHIVE DESTINATION lib
  205. )
  206. endif (BUILD_SHARED_LIBS)
  207. # man file
  208. install(FILES slim.1 DESTINATION ${MANDIR}/man1/)
  209. install(FILES slimlock.1 DESTINATION ${MANDIR}/man1/)
  210. # configure
  211. install(FILES slim.conf DESTINATION ${SYSCONFDIR})
  212. # systemd service file
  213. if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
  214. install(FILES slim.service DESTINATION ${LIBDIR}/systemd/system)
  215. endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
  216. # themes directory
  217. subdirs(themes)