CMakeLists.txt 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. project(supertuxkart-editor)
  2. cmake_minimum_required(VERSION 2.8)
  3. if(NOT (CMAKE_MAJOR_VERSION VERSION_LESS 3))
  4. cmake_policy(SET CMP0043 OLD)
  5. endif()
  6. set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
  7. if (NOT CMAKE_BUILD_TYPE)
  8. message(STATUS "No build type selected, default to Release")
  9. set(CMAKE_BUILD_TYPE "Release")
  10. endif()
  11. option(STATIC_PHYSFS "Force build with static physfs library" OFF)
  12. option(STATIC_ZLIB "Force build with static zlib library" OFF)
  13. if(UNIX OR MINGW)
  14. option(DEBUG_SYMBOLS "Compile with debug symbols" OFF)
  15. endif()
  16. # These variables enable MSVC to find libraries located in "dependencies"
  17. if(WIN32)
  18. set(ENV{PATH} "$ENV{PATH};${PROJECT_SOURCE_DIR}/dependencies/include")
  19. set(ENV{LIB} ${PROJECT_SOURCE_DIR}/dependencies/lib)
  20. set(ENV{OPENALDIR} ${PROJECT_SOURCE_DIR}/dependencies)
  21. endif()
  22. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
  23. set(STKTE_SOURCE_DIR "${PROJECT_SOURCE_DIR}/src")
  24. include_directories(${STKTE_SOURCE_DIR})
  25. if(WIN32)
  26. add_definitions(-D_IRR_STATIC_LIB_)
  27. configure_file("${PROJECT_SOURCE_DIR}/src/icon_rc.template" "${PROJECT_BINARY_DIR}/tmp/icon.rc")
  28. endif()
  29. file(GLOB_RECURSE STKTE_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${STKTE_SOURCE_DIR}/*.cpp")
  30. file(GLOB_RECURSE STKTE_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${PROJECT_BINARY_DIR}/tmp/*.rc")
  31. if(UNIX OR MINGW)
  32. if(DEBUG_SYMBOLS)
  33. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
  34. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
  35. endif()
  36. endif()
  37. # OpenGL
  38. find_package(OpenGL REQUIRED)
  39. include_directories(${OPENGL_INCLUDE_DIR})
  40. if(NOT OPENGL_FOUND)
  41. message(FATAL_ERROR "OpenGL not found")
  42. endif()
  43. if(WIN32 OR APPLE OR STATIC_ZLIB)
  44. add_subdirectory("${PROJECT_SOURCE_DIR}/lib/zlib")
  45. include_directories("${PROJECT_SOURCE_DIR}/lib/zlib")
  46. set(ZLIB_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/lib/zlib" "${PROJECT_BINARY_DIR}/lib/zlib/")
  47. set(ZLIB_LIBRARY zlibstatic)
  48. else()
  49. find_package(ZLIB REQUIRED)
  50. endif()
  51. if(WIN32 OR APPLE OR STATIC_PHYSFS)
  52. add_definitions(-DPHYSFS_BUILD_STATIC)
  53. add_subdirectory("${PROJECT_SOURCE_DIR}/lib/physfs")
  54. include_directories("${PROJECT_SOURCE_DIR}/lib/physfs")
  55. set(PHYSFS_LIBRARY physfs-static)
  56. else()
  57. find_package(PhysFS REQUIRED)
  58. endif()
  59. add_subdirectory("${PROJECT_SOURCE_DIR}/lib/irrlicht")
  60. include_directories("${PROJECT_SOURCE_DIR}/lib/irrlicht/include")
  61. if(UNIX AND NOT APPLE)
  62. find_package(X11 REQUIRED)
  63. include_directories(${X11_INCLUDE_DIR})
  64. endif()
  65. if(UNIX OR MINGW)
  66. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
  67. endif()
  68. if(MSVC)
  69. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
  70. add_definitions(-DNOMINMAX)
  71. add_definitions(-D_CRT_SECURE_NO_WARNINGS)
  72. set_property(DIRECTORY PROPERTY COMPILE_DEFINITIONS_DEBUG DEBUG)
  73. else()
  74. if(CMAKE_BUILD_TYPE MATCHES Debug)
  75. add_definitions(-DDEBUG)
  76. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
  77. else()
  78. add_definitions(-DNDEBUG)
  79. endif()
  80. endif()
  81. add_executable(${PROJECT_NAME} ${STKTE_SOURCES} ${STKTE_RESOURCES})
  82. file(COPY ${PROJECT_SOURCE_DIR}/src/font/ DESTINATION ${PROJECT_BINARY_DIR}/bin/font)
  83. # Link options
  84. target_link_libraries(${PROJECT_NAME}
  85. irrlicht
  86. ${PHYSFS_LIBRARY}
  87. ${OPENGL_gl_LIBRARY}
  88. )
  89. if(UNIX AND NOT APPLE)
  90. target_link_libraries(${PROJECT_NAME} ${X11_X11_LIB} ${X11_Xxf86vm_LIB})
  91. elseif(WIN32)
  92. target_link_libraries(${PROJECT_NAME} winmm)
  93. endif()