12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. cmake_minimum_required(VERSION 2.6)
  2. set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build (Debug or Release)")
  3. if ( NOT CMAKE_INSTALL_PREFIX )
  4. set(CMAKE_INSTALL_PREFIX "/usr")
  5. endif()
  6. if ( NOT SLOP_LEGACY_MODE )
  7. set(SLOP_LEGACY_MODE FALSE CACHE BOOL "Legacy mode requires the XShape extension, is laggy, isn't guaranteed to be invisible on shutdown, isn't guaranteed to support opacity, doesn't support custom shaders, and requires C++11 for the sleep_for functions. Though it still might be desired since it doesn't require OpenGL to use. Your choice <:o)")
  8. endif()
  9. project(slop)
  10. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/")
  11. include_directories("${PROJECT_BINARY_DIR}")
  12. add_definitions(-DSLOP_VERSION="v5.3.21")
  13. # The names have to be unique unfortunately.
  14. set(EXECUTABLE_NAME "slop")
  15. set(LIBRARY_NAME "slopy")
  16. set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/modules" )
  17. if ( SLOP_LEGACY_MODE )
  18. add_definitions(-DSLOP_LEGACY_MODE=true)
  19. add_library(${LIBRARY_NAME} SHARED src/mouse.cpp
  20. src/keyboard.cpp
  21. src/x.cpp
  22. src/slopstates.cpp
  23. src/windowhelper.cpp
  24. src/resource.cpp
  25. src/xslop.cpp
  26. src/xshaperectangle.cpp)
  27. set_property(TARGET ${LIBRARY_NAME} PROPERTY CXX_STANDARD 11)
  28. set_property(TARGET ${LIBRARY_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
  29. add_executable(${EXECUTABLE_NAME} src/options.cpp
  30. src/main.cpp)
  31. # Detect and add cmake modules
  32. find_package(GLM REQUIRED)
  33. find_package(X11 REQUIRED)
  34. find_package(XExt REQUIRED)
  35. include_directories(${X11_INCLUDE_DIR}
  36. ${GLM_INCLUDE_DIR}
  37. ${XEXT_INCLUDE_DIR})
  38. target_link_libraries(${EXECUTABLE_NAME} ${X11_LIBRARIES}
  39. ${GLM_LIBRARIES}
  40. ${XEXT_LIBRARIES}
  41. ${LIBRARY_NAME})
  42. # Install targets
  43. install( TARGETS ${EXECUTABLE_NAME} DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" )
  44. install( TARGETS ${LIBRARY_NAME} DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" )
  45. install( FILES ${CMAKE_SOURCE_DIR}/src/xslop.hpp DESTINATION "${CMAKE_INSTALL_PREFIX}/include" )
  46. else()
  47. add_library(${LIBRARY_NAME} SHARED src/mouse.cpp
  48. src/keyboard.cpp
  49. src/x.cpp
  50. src/slopstates.cpp
  51. src/framebuffer.cpp
  52. src/windowhelper.cpp
  53. src/resource.cpp
  54. src/gl_core_3_3.c
  55. src/shader.cpp
  56. src/window.cpp
  57. src/glslop.cpp
  58. src/rectangle.cpp)
  59. add_executable(${EXECUTABLE_NAME} src/options.cpp
  60. src/main.cpp)
  61. # Detect and add cmake modules
  62. find_package(GLM REQUIRED)
  63. find_package(X11 REQUIRED)
  64. find_package(GLX REQUIRED)
  65. find_package(OpenGL REQUIRED)
  66. include_directories(${X11_INCLUDE_DIR}
  67. ${GLM_INCLUDE_DIR}
  68. ${GLX_INCLUDE_DIR}
  69. ${OPENGL_INCLUDE_DIR})
  70. target_link_libraries(${EXECUTABLE_NAME} ${X11_LIBRARIES}
  71. ${GLM_LIBRARIES}
  72. ${OPENGL_LIBRARIES}
  73. ${GLX_LIBRARY}
  74. ${LIBRARY_NAME})
  75. # Install targets
  76. install( TARGETS ${EXECUTABLE_NAME} DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" )
  77. install( TARGETS ${LIBRARY_NAME} DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" )
  78. install( FILES ${CMAKE_SOURCE_DIR}/src/glslop.hpp DESTINATION "${CMAKE_INSTALL_PREFIX}/include" )
  79. endif()