This repository has been archived on 2024-12-30. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
2024CG-project-render/CMakeLists.txt
github-classroom[bot] 686dcaf351
Initial commit
2024-11-29 09:50:03 +00:00

61 lines
1.9 KiB
CMake

cmake_minimum_required(VERSION 3.6)
# Set project name
project(shaderpipeline)
# Check for C++17 support
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++17" COMPILER_SUPPORTS_CXX17)
if(COMPILER_SUPPORTS_CXX17)
set(CMAKE_CXX_STANDARD 17)
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++17 support. Please use a different C++ compiler.")
endif()
# Add headers
include_directories("include/")
# OpenGL library
find_package(OpenGL REQUIRED)
# Add Glad
add_library(glad "glad.c")
include_directories(include)
# Check if GLFW and Eigen are not empty
file(GLOB GLFW_DIR lib/glfw/*)
list(LENGTH GLFW_DIR NR_FILES_IN_GLFW_DIR)
if(NR_FILES_IN_GLFW_DIR LESS_EQUAL 1)
message(WARNING "Did you forget git submodule update --init --recursive ?")
endif()
# Add GLFW as a submodule
add_subdirectory(lib/glfw)
include_directories(lib/glfw/include)
# Add Eigen as a submodule
add_subdirectory(lib/eigen)
include_directories(lib/eigen)
# Define the glsl files
# Note: ${RESOURCEFILES} is not used, since it is not part of the C++ compilation step.
# If you use an extension to your IDE that provides syntax highlighting etc for OpenGL,
# you might need to add ${RESOURCEFILES} in add_executable().
file(GLOB RESOURCEFILES "src/*" "glsl/*")
# Add c++ files
set(SOURCES main.cpp glHelper.h)
add_executable(${PROJECT_NAME} ${SOURCES})
#add_executable(${PROJECT_NAME} ${SOURCES} ${RESOURCEFILES}) # in case you need the glsl files for an IDE extension
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC ${OPENGL_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} glfw ${OPENGL_gl_LIBRARY} glad)
# make the current path available to the source code
target_compile_definitions(${PROJECT_NAME} PUBLIC CMAKELISTS_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
# if using Visual Studio, set the startup project
if(MSVC)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME})
endif()