CMakeLists.txt 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. cmake_minimum_required(VERSION 3.1)
  2. include(ExternalProject)
  3. project(DoRayMe)
  4. set(CMAKE_CXX_STANDARD 11)
  5. option(COVERALLS "Generate coveralls data" OFF)
  6. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/external/coveralls-cmake/cmake)
  7. option(PACKAGE_TESTS "Build the tests" ON)
  8. option(ENABLE_COVERAGE "Build for code coverage" OFF)
  9. option(SHOW_STATS "Show rendering stat" ON)
  10. if (SHOW_STATS)
  11. add_compile_options(-DRENDER_STATS)
  12. endif()
  13. option(USE_LUA "Enable the use of Lua" ON)
  14. if (USE_LUA)
  15. add_compile_options(-DENABLE_LUA_SUPPORT)
  16. endif()
  17. if (ENABLE_COVERAGE AND COVERALLS)
  18. message(FATAL_ERROR "You can't enable both ENABLE_COVERAGE and COVERALLS at the same time")
  19. endif()
  20. if (COVERALLS)
  21. include(Coveralls)
  22. coveralls_turn_on_coverage()
  23. endif()
  24. if (ENABLE_COVERAGE)
  25. if("${CMAKE_C_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang" OR
  26. "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang")
  27. message("Building with LLVM Code Coverage Tools")
  28. set(CMAKE_CXX_FLAGS "-fprofile-instr-generate -fcoverage-mapping")
  29. elseif(CMAKE_COMPILER_IS_GNUCXX)
  30. message("Building with lcov Code Coverage Tools")
  31. set(CMAKE_CXX_FLAGS "--coverage")
  32. else()
  33. message(FATAL_ERROR "Compiler ${CMAKE_C_COMPILER_ID} is not supported for code coverage")
  34. endif()
  35. endif()
  36. # LodePNG don't make a .a or .so, so let's build a library here
  37. add_library(LodePNG STATIC)
  38. set(LODEPNG_INCLUDE_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/external/lodepng)
  39. target_sources(LodePNG PRIVATE external/lodepng/lodepng.cpp external/lodepng/lodepng.h)
  40. ExternalProject_Add(LuaCore
  41. URL "https://www.lua.org/ftp/lua-5.3.5.tar.gz"
  42. URL_HASH SHA1=112eb10ff04d1b4c9898e121d6bdf54a81482447
  43. SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/lua
  44. CONFIGURE_COMMAND ""
  45. BUILD_IN_SOURCE True
  46. BUILD_COMMAND make generic
  47. INSTALL_COMMAND ""
  48. )
  49. set(LUA_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/lua/src")
  50. set(LUA_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/external/lua/src/liblua.a")
  51. # Main app
  52. add_subdirectory(source)
  53. if(PACKAGE_TESTS OR COVERALLS)
  54. enable_testing()
  55. include(GoogleTest)
  56. add_subdirectory("${PROJECT_SOURCE_DIR}/external/googletest" "external/googletest")
  57. add_subdirectory(tests)
  58. endif()
  59. if (COVERALLS)
  60. # Create the coveralls target.
  61. coveralls_setup(
  62. "${COVERAGE_SRCS}" # The source files.
  63. ON # If we should upload.
  64. ) # (Optional) Alternate project cmake module path.
  65. endif()