CMakeLists.txt 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. cmake_minimum_required(VERSION 3.25)
  2. project(gaming_core C)
  3. add_subdirectory(glfw SYSTEM)
  4. set(CMAKE_C_STANDARD 23)
  5. set(SRC
  6. "src/Image.c"
  7. "src/Network.c"
  8. "src/VulkanWrapper.c"
  9. "src/WindowManager.c"
  10. )
  11. set(SRC_TESTS
  12. "test/Main.c"
  13. "test/modules/ImageTests.c"
  14. "test/modules/NetworkTests.c"
  15. "test/modules/WindowManagerTests.c"
  16. )
  17. if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
  18. set(COMPILE_OPTIONS "")
  19. set(LINK_OPTIONS "")
  20. set(LOG_LEVEL 2)
  21. set(DEFINITIONS CHECK_MEMORY)
  22. else()
  23. set(DEFINITIONS ERROR_SIMULATOR CHECK_MEMORY)
  24. if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
  25. set(COMPILE_OPTIONS --coverage)
  26. set(LINK_OPTIONS gcov)
  27. elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
  28. set(COMPILE_OPTIONS -fprofile-instr-generate -fcoverage-mapping)
  29. set(LINK_OPTIONS ${COMPILE_OPTIONS})
  30. endif()
  31. set(LOG_LEVEL 4)
  32. list(APPEND SRC "src/ErrorSimulator.c")
  33. endif()
  34. if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
  35. include("cmake/gcc_warnings.cmake")
  36. elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
  37. include("cmake/clang_warnings.cmake")
  38. endif()
  39. add_library(gaming_core STATIC ${SRC})
  40. target_compile_options(gaming_core PUBLIC
  41. ${COMPILE_OPTIONS}
  42. ${WARNINGS}
  43. -fdiagnostics-color=always
  44. )
  45. target_compile_definitions(gaming_core
  46. PUBLIC LOG_LEVEL=${LOG_LEVEL}
  47. PUBLIC ${DEFINITIONS}
  48. )
  49. target_link_libraries(gaming_core
  50. PRIVATE m core glfw vulkan ${LINK_OPTIONS}
  51. )
  52. target_include_directories(gaming_core SYSTEM
  53. PUBLIC ${CMAKE_INSTALL_PREFIX}/include
  54. PUBLIC enet/include
  55. PUBLIC stb
  56. PUBLIC glfw/include
  57. )
  58. target_link_directories(gaming_core
  59. PUBLIC ${CMAKE_INSTALL_PREFIX}/lib
  60. )
  61. target_sources(gaming_core PUBLIC
  62. FILE_SET HEADERS
  63. BASE_DIRS include
  64. FILES
  65. ./include/core/Image.h
  66. ./include/core/Network.h
  67. ./include/core/VulkanWrapper.h
  68. ./include/core/WindowManager.h
  69. )
  70. install(TARGETS gaming_core FILE_SET HEADERS)
  71. add_executable(test ${SRC_TESTS})
  72. target_link_libraries(test PRIVATE gaming_core)