CMakeLists.txt 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. if (ENABLE_COVERAGE AND COVERALLS)
  14. message(FATAL_ERROR "You can't enable both ENABLE_COVERAGE and COVERALLS at the same time")
  15. endif()
  16. if (COVERALLS)
  17. include(Coveralls)
  18. coveralls_turn_on_coverage()
  19. endif()
  20. if (ENABLE_COVERAGE)
  21. if("${CMAKE_C_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang" OR
  22. "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang")
  23. message("Building with LLVM Code Coverage Tools")
  24. set(CMAKE_CXX_FLAGS "-fprofile-instr-generate -fcoverage-mapping")
  25. elseif(CMAKE_COMPILER_IS_GNUCXX)
  26. message("Building with lcov Code Coverage Tools")
  27. set(CMAKE_CXX_FLAGS "--coverage")
  28. else()
  29. message(FATAL_ERROR "Compiler ${CMAKE_C_COMPILER_ID} is not supported for code coverage")
  30. endif()
  31. endif()
  32. # LodePNG don't make a .a or .so, so let's build a library here
  33. add_library(LodePNG STATIC)
  34. set(LODEPNG_INCLUDE_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/external/lodepng)
  35. target_sources(LodePNG PRIVATE external/lodepng/lodepng.cpp external/lodepng/lodepng.h)
  36. # Main app
  37. add_subdirectory(source)
  38. if(PACKAGE_TESTS OR COVERALLS)
  39. enable_testing()
  40. include(GoogleTest)
  41. add_subdirectory("${PROJECT_SOURCE_DIR}/external/googletest" "external/googletest")
  42. add_subdirectory(tests)
  43. endif()
  44. if (COVERALLS)
  45. # Create the coveralls target.
  46. coveralls_setup(
  47. "${COVERAGE_SRCS}" # The source files.
  48. ON # If we should upload.
  49. ) # (Optional) Alternate project cmake module path.
  50. endif()