CMakeLists.txt 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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 "2")
  18. set(SLIM_VERSION "${SLIM_VERSION_MAJOR}.${SLIM_VERSION_MINOR}.${SLIM_VERSION_PATCH}")
  19. set(CMAKE_INSTALL_PREFIX "/usr/share" CACHE PATH "Installation Directory")
  20. set(PKGDATADIR "${CMAKE_INSTALL_PREFIX}/share/slim")
  21. set(SYSCONFDIR "/etc")
  22. set(MANDIR "${CMAKE_INSTALL_PREFIX}/share/man")
  23. set(SLIM_DEFINITIONS)
  24. if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR
  25. ${CMAKE_SYSTEM_NAME} MATCHES "NetBSD" OR
  26. ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD"
  27. )
  28. set(SLIM_DEFINITIONS ${SLIM_DEFINITIONS} "-DNEEDS_BASENAME")
  29. else()
  30. set(SLIM_DEFINITIONS ${SLIM_DEFINITIONS} "-DHAVE_SHADOW")
  31. endif()
  32. set(SLIM_DEFINITIONS ${SLIM_DEFINITIONS} "-DPACKAGE=\"slim\"")
  33. set(SLIM_DEFINITIONS ${SLIM_DEFINITIONS} "-DVERSION=\"${SLIM_VERSION}\"")
  34. set(SLIM_DEFINITIONS ${SLIM_DEFINITIONS} "-DPKGDATADIR=\"${PKGDATADIR}\"")
  35. set(SLIM_DEFINITIONS ${SLIM_DEFINITIONS} "-DSYSCONFDIR=\"${SYSCONFDIR}\"")
  36. # Flags
  37. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security" )
  38. set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} -Wall -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security" )
  39. # source
  40. set(slim_srcs
  41. main.cpp
  42. app.cpp
  43. cfg.cpp
  44. image.cpp
  45. numlock.cpp
  46. panel.cpp
  47. switchuser.cpp
  48. util.cpp
  49. PAM.cpp
  50. png.c
  51. jpeg.c
  52. )
  53. add_executable(${PROJECT_NAME} ${slim_srcs})
  54. #Set the custom CMake module directory where our include/lib finders are
  55. set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
  56. find_package(X11 REQUIRED)
  57. find_package(Freetype REQUIRED)
  58. find_package(GLUT REQUIRED)
  59. find_package(JPEG REQUIRED)
  60. find_package(PNG REQUIRED)
  61. find_package(ZLIB REQUIRED)
  62. set(FONTCONFIG_DIR ${CMAKE_MODULE_PATH})
  63. # Fontconfig
  64. find_package(FONTCONFIG REQUIRED)
  65. if(FONTCONFIG_FOUND)
  66. message("\tFontConfig Found")
  67. target_link_libraries(${PROJECT_NAME} ${FONTCONFIG_LIBRARY})
  68. include_directories(${FONTCONFIG_INCLUDE_DIR})
  69. endif(FONTCONFIG_FOUND)
  70. # PAM
  71. if(USE_PAM)
  72. set(SLIM_DEFINITIONS ${SLIM_DEFINITIONS} "-DUSE_PAM")
  73. find_package(PAM)
  74. if(PAM_FOUND)
  75. message("\tPAM Enabled")
  76. message("\tPAM Found")
  77. target_link_libraries(${PROJECT_NAME} ${PAM_LIBRARY})
  78. include_directories(${PAM_INCLUDE_DIR})
  79. endif(PAM_FOUND)
  80. else(USE_PAM)
  81. message("\tPAM disabled")
  82. endif(USE_PAM)
  83. # system librarys
  84. find_library(M_LIB m)
  85. find_library(RT_LIB rt)
  86. find_library(CRYPTO_LIB crypt)
  87. add_definitions(${SLIM_DEFINITIONS})
  88. #Set up include dirs with all found packages
  89. include_directories(
  90. ${X11_INCLUDE_DIR}
  91. ${X11_Xft_INCLUDE_PATH}
  92. ${X11_Xrender_INCLUDE_PATH}
  93. ${FREETYPE_INCLUDE_DIR_freetype2}
  94. ${GLUT_Xmu_INCLUDE_PATH}
  95. ${ZLIB_INCLUDE_DIR}
  96. ${JPEG_INCLUDE_DIR}
  97. ${PNG_INCLUDE_DIR}
  98. )
  99. #Set up library with all found packages
  100. target_link_libraries(${PROJECT_NAME}
  101. ${M_LIB}
  102. ${RT_LIB}
  103. ${CRYPTO_LIB}
  104. ${X11_X11_LIB}
  105. ${X11_Xft_LIB}
  106. ${X11_Xrender_LIB}
  107. ${FREETYPE_LIBRARY}
  108. ${GLUT_Xmu_LIBRARY}
  109. ${JPEG_LIBRARIES}
  110. ${PNG_LIBRARIES}
  111. )
  112. # install
  113. # slim
  114. install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin )
  115. # man file
  116. install(FILES slim.1 DESTINATION ${MANDIR}/man1/)
  117. # configure
  118. install(FILES slim.conf DESTINATION ${SYSCONFDIR})
  119. # themes directory
  120. subdirs(themes)