CMakeLists.txt 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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.")
  8. endif()
  9. project(slop)
  10. add_definitions(-DSLOP_VERSION="v5.3.21")
  11. if ( SLOP_LEGACY_MODE )
  12. add_definitions(-DSLOP_LEGACY_MODE=true)
  13. endif()
  14. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/")
  15. include_directories("${PROJECT_BINARY_DIR}")
  16. # Define sources and executable
  17. set(EXECUTABLE_NAME "slop")
  18. set( source src/x.cpp
  19. src/windowhelper.cpp
  20. src/mouse.cpp
  21. src/keyboard.cpp
  22. src/resource.cpp
  23. src/options.cpp
  24. src/slopstates.cpp
  25. src/main.cpp )
  26. if ( SLOP_LEGACY_MODE )
  27. set ( source ${source}
  28. src/xslop.cpp
  29. src/xshaperectangle.cpp )
  30. else()
  31. set ( source ${source}
  32. src/window.cpp
  33. src/glslop.cpp
  34. src/rectangle.cpp
  35. src/framebuffer.cpp
  36. src/gl_core_3_3.c
  37. src/shader.cpp )
  38. endif()
  39. add_executable(${EXECUTABLE_NAME} ${source})
  40. # Detect and add cmake modules
  41. set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/modules" )
  42. find_package(GLM REQUIRED)
  43. find_package(X11 REQUIRED)
  44. include_directories(${X11_INCLUDE_DIR}
  45. ${GLM_INCLUDE_DIR})
  46. target_link_libraries(${EXECUTABLE_NAME} ${X11_LIBRARIES}
  47. ${GLM_LIBRARIES})
  48. # Either we require OpenGL, or we require the XShape extension.
  49. if ( SLOP_LEGACY_MODE )
  50. find_package(XExt REQUIRED)
  51. include_directories(${XEXT_INCLUDE_DIR})
  52. target_link_libraries(${EXECUTABLE_NAME} ${XEXT_LIBRARIES})
  53. set_property(TARGET ${EXECUTABLE_NAME} PROPERTY CXX_STANDARD 11)
  54. set_property(TARGET ${EXECUTABLE_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
  55. else()
  56. find_package(GLX REQUIRED)
  57. find_package(OpenGL REQUIRED)
  58. include_directories(${GLX_INCLUDE_DIR}
  59. ${OPENGL_INCLUDE_DIR})
  60. target_link_libraries(${EXECUTABLE_NAME} ${OPENGL_LIBRARIES}
  61. ${GLX_LIBRARY})
  62. endif()
  63. # Install targets
  64. install( TARGETS ${EXECUTABLE_NAME} DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" )