CMakeLists.txt 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #Change this if you need to target a specific CMake version
  2. cmake_minimum_required(VERSION 3.1)
  3. if(NOT CMAKE_BUILD_TYPE)
  4. set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build (Debug or Release)" FORCE)
  5. endif()
  6. if( NOT CMAKE_INSTALL_PREFIX )
  7. set( CMAKE_INSTALL_PREFIX "/usr" )
  8. endif()
  9. if( NOT SHADER_PREFIX )
  10. set( SHADER_PREFIX "${CMAKE_INSTALL_PREFIX}" CACHE PATH "The path where slop thinks it resides in, so that it can find the shaders. This is not necessarily the CMAKE_INSTALL_PREFIX. For example if the shaders will exist in /usr/share/slop, SHADER_PREFIX should be \"/usr\"." )
  11. endif()
  12. project(slop)
  13. set(CMAKE_CXX_STANDARD 14)
  14. set(CMAKE_CXX_STANDARD_REQUIRED on)
  15. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -Wno-missing-braces")
  16. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/")
  17. include_directories("${PROJECT_BINARY_DIR}")
  18. # Define sources and executable
  19. set(EXECUTABLE_NAME "slop")
  20. set( source src/x.cpp
  21. src/window.cpp
  22. src/mouse.cpp
  23. src/keyboard.cpp
  24. src/framebuffer.cpp
  25. src/resource.cpp
  26. src/options.cpp
  27. src/gl_core_3_3.c
  28. src/shader.cpp
  29. src/slopstates.cpp
  30. src/slop.cpp
  31. src/rectangle.cpp
  32. src/main.cpp )
  33. add_executable(${EXECUTABLE_NAME} ${source})
  34. # Detect and add SFML
  35. set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/modules" )
  36. #Find any version 2.X of SFML
  37. #See the FindSFML.cmake file for additional details and instructions
  38. find_package(OpenGL REQUIRED)
  39. find_package(GLM REQUIRED)
  40. find_package(GLX REQUIRED)
  41. find_package(X11 REQUIRED)
  42. find_package(XExt REQUIRED)
  43. find_package(XRender REQUIRED)
  44. find_package(RT)
  45. include_directories(${X11_INCLUDE_DIR}
  46. ${GLM_INCLUDE_DIR}
  47. ${GLX_INCLUDE_DIR}
  48. ${XRENDER_INCLUDE_DIRS}
  49. ${OPENGL_INCLUDE_DIR})
  50. if ( RT_INCLUDE_DIR )
  51. include_directories(${RT_INCLUDE_DIR})
  52. endif()
  53. target_link_libraries(${EXECUTABLE_NAME} ${X11_LIBRARIES}
  54. ${GLX_LIBRARIES}
  55. ${XRENDER_LIBRARIES}
  56. ${OPENGL_LIBRARIES})
  57. if ( RT_LIBRARY )
  58. target_link_libraries(${EXECUTABLE_NAME} ${RT_LIBRARY})
  59. endif()
  60. # Install targets
  61. install( TARGETS ${EXECUTABLE_NAME} DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" )
  62. install( DIRECTORY "${CMAKE_SOURCE_DIR}/share" DESTINATION "${CMAKE_INSTALL_PREFIX}" )
  63. add_definitions(-DSHADER_PREFIX="${SHADER_PREFIX}")