1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- cmake_minimum_required(VERSION 3.25)
- project(gaming_core C)
- add_subdirectory(glfw SYSTEM)
- set(CMAKE_C_STANDARD 23)
- set(SRC
- "src/Image.c"
- "src/Network.c"
- "src/VulkanWrapper.c"
- "src/WindowManager.c"
- )
- set(SRC_TESTS
- "test/Main.c"
- "test/modules/ImageTests.c"
- "test/modules/NetworkTests.c"
- "test/modules/WindowManagerTests.c"
- )
- if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
- set(COMPILE_OPTIONS "")
- set(LINK_OPTIONS "")
- set(LOG_LEVEL 2)
- set(DEFINITIONS CHECK_MEMORY)
- else()
- set(DEFINITIONS ERROR_SIMULATOR CHECK_MEMORY)
- if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
- set(COMPILE_OPTIONS --coverage)
- set(LINK_OPTIONS gcov)
- elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
- set(COMPILE_OPTIONS -fprofile-instr-generate -fcoverage-mapping)
- set(LINK_OPTIONS ${COMPILE_OPTIONS})
- endif()
- set(LOG_LEVEL 4)
- list(APPEND SRC "src/ErrorSimulator.c")
- endif()
- if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
- include("cmake/gcc_warnings.cmake")
- elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
- include("cmake/clang_warnings.cmake")
- endif()
- add_library(gaming_core STATIC ${SRC})
- target_compile_options(gaming_core PUBLIC
- ${COMPILE_OPTIONS}
- ${WARNINGS}
- -fdiagnostics-color=always
- )
- target_compile_definitions(gaming_core
- PUBLIC LOG_LEVEL=${LOG_LEVEL}
- PUBLIC ${DEFINITIONS}
- )
- target_link_libraries(gaming_core
- PRIVATE m core glfw vulkan ${LINK_OPTIONS}
- )
- target_include_directories(gaming_core SYSTEM
- PUBLIC ${CMAKE_INSTALL_PREFIX}/include
- PUBLIC enet/include
- PUBLIC stb
- PUBLIC glfw/include
- )
- target_link_directories(gaming_core
- PUBLIC ${CMAKE_INSTALL_PREFIX}/lib
- )
- target_sources(gaming_core PUBLIC
- FILE_SET HEADERS
- BASE_DIRS include
- FILES
- ./include/core/Image.h
- ./include/core/Network.h
- ./include/core/VulkanWrapper.h
- ./include/core/WindowManager.h
- )
- install(TARGETS gaming_core FILE_SET HEADERS)
- add_executable(test ${SRC_TESTS})
- target_link_libraries(test PRIVATE gaming_core)
|