58 lines
1.3 KiB
CMake
58 lines
1.3 KiB
CMake
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
|
|
project(new-engine
|
|
VERSION 0
|
|
DESCRIPTION "Simple Engine Experiment in C"
|
|
HOMEPAGE_URL "https://git.warwick-new.co.uk/"
|
|
LANGUAGES C
|
|
)
|
|
|
|
set(CMAKE_C_STANDARD 17)
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
# Dependancies
|
|
find_package(Vulkan REQUIRED)
|
|
find_package(glfw3 REQUIRED)
|
|
set(GLFW_LIBRARIES glfw)
|
|
find_package(glm REQUIRED)
|
|
#find_package(m REQUIRED)
|
|
|
|
# Include dirs
|
|
include_directories(
|
|
${Vulkan_INCLUDE_DIRS}
|
|
${GLFW_INCLUDE_DIRS}
|
|
${GLM_INCLUDE_DIRS}
|
|
)
|
|
|
|
# Executables
|
|
file(GLOB_RECURSE SOURCE_FILES
|
|
${CMAKE_SOURCE_DIR}/src/*.c)
|
|
file(GLOB_RECURSE HEADER_FILES
|
|
${CMAKE_SOURCE_DIR}/src/*.h)
|
|
add_executable(${PROJECT_NAME} ${HEADER_FILES} ${SOURCE_FILES})
|
|
|
|
# Error on memory address issues in debug mode
|
|
if(CMAKE_BUILD_TYPE MATCHES "Debug")
|
|
set(
|
|
CMAKE_C_FLAGS
|
|
"${CMAKE_C_FLAGS} -Werror -fsanitize=undefined -fsanitize=address"
|
|
)
|
|
target_link_options(${PROJECT_NAME}
|
|
BEFORE PUBLIC -fsanitize=undefined PUBLIC -fsanitize=address
|
|
)
|
|
endif()
|
|
|
|
# Link Libraries
|
|
target_link_libraries(${PROJECT_NAME}
|
|
${GLFW_LIBRARIES}
|
|
${Vulkan_LIBRARIES}
|
|
${GLM_LIBRARY_DIRS}
|
|
${CMAKE_DL_LIBS}
|
|
#${M_LIBRARIES}
|
|
m
|
|
)
|
|
|
|
# Compile Shaders
|
|
add_custom_command(TARGET ${PROJECT_NAME}
|
|
PRE_BUILD
|
|
COMMAND ./compile_shaders.sh
|
|
)
|