Files
LearnOpenGL/CMakeLists.txt

111 lines
3.7 KiB
CMake

# @file CMakeLists.txt - LearnOpenGL library's root CMakeList
# @auth Joshua O'Leary
# @edited 2 March 2024
# @copyright 2024 Redacted Software LLC
# @contact josh@redacted.cc, william@redacted.cc
# @license Explicitly granted to the Public Domain by Redacted Software.
# So, what's up with this file?
# C++ is old as hell, basically.
# We use a funky scripting language to tell the compiler how to build our program
# which (if done correctly) should work automatically and identically on any
# developer environment.
# It's well-integrated with every serious C++ Editor that exists to mortals.
# Allow CMake versions between and including 3.18 and 3.27.
cmake_minimum_required(VERSION 3.18...3.27)
project(LearnOpenGL
VERSION 1.5
LANGUAGES CXX
)
# Don't let dummies compile the program right in the source directory
# (Try it yourself if you don't yet know)
if (PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
message(FATAL_ERROR "In-source builds are not allowed!")
endif()
# Modern C++ Please
set(CMAKE_CXX_STANDARD 20)
# Windows Compatibility Flag?
# (TODO: Test, IIRC this line failed in one of the projects on the Billiam VM)
if (WIN32)
set(CMAKE_CXX_FLAGS "-municode")
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}")
# Enable Package Manager
# CPM will automagically download and build required libraries in a neat and hassle-free manner
# (That is our hope and intention)
include(cmake/CPM.cmake)
# Most dependencies
# Grab Josh Math Lib
CPMAddPackage(
NAME J3ML
URL https://git.redacted.cc/josh/j3ml/archive/Release-1.zip
)
# Grab GLAD
# GLAD as I understand essentially generates an OpenGL API to spec with the
# proper "API extensions" based on available graphics hardware features.
CPMAddPackage(
NAME GLAD
URL https://git.redacted.cc/Redacted/glad/archive/v2.1.zip
)
# Open Asset Importer - 3D Model File IO Library
# https://github.com/assimp/assimp/blob/master/LICENSE
CPMAddPackage(
NAME ASSIMP
URL https://github.com/assimp/assimp/archive/refs/tags/v5.3.1.zip
)
# Redacted Software's ReWindow Library
# One Class Header, Implemented for multiple platforms
#CPMAddPackage(
# NAME ReWindow
# URL https://git.redacted.cc/Redacted/ReWindow/archive/vA0.2.22.zip
#)
# Grab OpenGL from the "System"
find_package(OpenGL REQUIRED)
file(GLOB_RECURSE HEADERS "include/*.h" "include/*.hpp")
file(GLOB_RECURSE SOURCES "src/LearnOpenGL/*.c" "src/LearnOpenGL/*.cpp")
# TODO: Wrangle target_include_directories
include_directories(${PROJECT_SOURCE_DIR}/include)
add_library(LearnOpenGL SHARED ${SOURCES})
target_include_directories(LearnOpenGL PUBLIC ${J3ML_SOURCE_DIR}/include)
target_include_directories(LearnOpenGL PUBLIC ${glad_SOURCE_DIR}/include)
target_include_directories(LearnOpenGL PUBLIC ${ASSIMP_SOURCE_DIR}/include)
target_link_libraries(LearnOpenGL PUBLIC J3ML)
target_link_libraries(LearnOpenGL PUBLIC GL)
target_link_libraries(LearnOpenGL PUBLIC glad)
target_link_libraries(LearnOpenGL PUBLIC assimp)
set_target_properties(LearnOpenGL PROPERTIES LINKER_LANGUAGE CXX)
#add_executable(LearnOpenGLDemo main.cpp)
# Privately include and link ReWindowLib DIRECTLY to LearnOpenGLDemo executable
# so it doesn't become a second-order-dependency
# On downstream projects that use LearnOpenGL as a dependency
#target_include_directories(LearnOpenGLDemo PRIVATE ${ReWindow_SOURCE_DIR}/include)
#target_link_libraries(LearnOpenGLDemo PRIVATE ReWindowLibrary)
#target_link_libraries(LearnOpenGLDemo PUBLIC LearnOpenGL)
add_subdirectory(src/demos/SkeletalAnim)
# Copy resources into build directory!
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/resources/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/resources)