uc3xx_testapp/CMakeLists.txt
2024-09-22 11:07:58 +02:00

81 lines
2.2 KiB
CMake

cmake_minimum_required(VERSION 3.16)
project(MyOpenGLProject)
# Set C++ standard
set(CMAKE_CXX_STANDARD 17)
# Only build on Windows
if(WIN32)
# Use FetchContent to download GLFW and ImGui
include(FetchContent)
# download GLM
FetchContent_Declare(
glm
GIT_REPOSITORY https://github.com/g-truc/glm.git
GIT_TAG bf71a834948186f4097caa076cd2663c69a10e1e #refs/tags/1.0.1
)
FetchContent_MakeAvailable(glm)
# Download GLFW
FetchContent_Declare(
glfw
GIT_REPOSITORY https://github.com/glfw/glfw.git
GIT_TAG 3.4 # Latest stable version
)
FetchContent_MakeAvailable(glfw)
# Download ImGui
FetchContent_Declare(
imgui
GIT_REPOSITORY https://github.com/ocornut/imgui.git
GIT_TAG v1.91.2-docking # Latest stable version
)
FetchContent_MakeAvailable(imgui)
# Set up ImGui backends for GLFW and OpenGL3
set(IMGUI_BACKENDS "${imgui_SOURCE_DIR}/backends")
set(IMGUI_SOURCES
${imgui_SOURCE_DIR}/imgui.cpp
${imgui_SOURCE_DIR}/imgui_demo.cpp
${imgui_SOURCE_DIR}/imgui_draw.cpp
${imgui_SOURCE_DIR}/imgui_tables.cpp
${imgui_SOURCE_DIR}/imgui_widgets.cpp
${IMGUI_BACKENDS}/imgui_impl_glfw.cpp
${IMGUI_BACKENDS}/imgui_impl_opengl3.cpp
)
set(glad_SOURCE_DIR src/vendor/glad)
add_library(glad ${glad_SOURCE_DIR}/src/glad.c)
target_include_directories(glad PUBLIC ${glad_SOURCE_DIR}/include)
set (APP_SOURCES
src/main.cpp
)
# Define your executable and include ImGui and backend sources
add_executable(${PROJECT_NAME} WIN32 ${APP_SOURCES} ${IMGUI_SOURCES})
# Include directories for ImGui, GLEW, and GLFW
target_include_directories(${PROJECT_NAME} PRIVATE
${imgui_SOURCE_DIR}
${IMGUI_BACKENDS}
${glfw_SOURCE_DIR}/include
${glad_SOURCE_DIR}/include
)
# Link against Windows-specific libraries, GLEW, GLFW, and OpenGL
target_link_libraries(${PROJECT_NAME} PRIVATE
glfw
glad
glm::glm
)
# Define GLEW_STATIC for static linking of GLEW
# target_compile_definitions(MyOpenGLApp PRIVATE GLEW_STATIC)
else()
message(FATAL_ERROR "This project is only supported on Windows.")
endif()