CMakeLists.txt 1.8 KB

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