|
|
|
|
cmake_minimum_required(VERSION 3.16.3)
|
|
|
|
|
|
|
|
|
|
# Set the project name and version
|
|
|
|
|
project(Lunarium VERSION 0.1.0)
|
|
|
|
|
|
|
|
|
|
# specify the C++ standard
|
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
|
|
|
|
|
|
|
|
|
# specify the opengl version
|
|
|
|
|
set(OpenGL_MAJOR_VERSION 4)
|
|
|
|
|
set(OpenGL_MINOR_VERSION 5)
|
|
|
|
|
|
|
|
|
|
configure_file(LunariumConfig.h.in LunariumConfig.h)
|
|
|
|
|
|
|
|
|
|
# Source Files
|
|
|
|
|
set(LUNARIUM_SRC
|
|
|
|
|
"src/main.cpp"
|
|
|
|
|
"src/core/core.cpp"
|
|
|
|
|
"src/core/state.cpp"
|
|
|
|
|
"src/core/version.cpp"
|
|
|
|
|
"src/utils/types.cpp"
|
|
|
|
|
"src/utils/logger.cpp"
|
|
|
|
|
"src/utils/highResTimer.cpp"
|
|
|
|
|
"src/utils/helpers.cpp"
|
|
|
|
|
"src/utils/opRes.cpp"
|
|
|
|
|
"src/utils/args.cpp"
|
|
|
|
|
"src/utils/binaryFileBuffer.cpp"
|
|
|
|
|
"src/utils/frameCounter.cpp"
|
|
|
|
|
"src/graphics/window.cpp"
|
|
|
|
|
"src/graphics/glGraphics.cpp"
|
|
|
|
|
"src/graphics/glShader.cpp"
|
|
|
|
|
"src/graphics/image.cpp"
|
|
|
|
|
"src/graphics/glText.cpp"
|
|
|
|
|
"src/graphics/internalFont.cpp"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# add the executable
|
|
|
|
|
add_executable(${PROJECT_NAME} ${LUNARIUM_SRC})
|
|
|
|
|
|
|
|
|
|
# DOWNLOAD ALL SUBMODULES
|
|
|
|
|
find_package(Git QUIET)
|
|
|
|
|
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
|
|
|
|
|
# Update submodules as needed
|
|
|
|
|
option(GIT_SUBMODULE "Check submodules during build" ON)
|
|
|
|
|
if(GIT_SUBMODULE)
|
|
|
|
|
message(STATUS "Submodule update")
|
|
|
|
|
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
|
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
|
RESULT_VARIABLE GIT_SUBMOD_RESULT)
|
|
|
|
|
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
|
|
|
|
|
message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# CHECK THAT ALL SUBMODULES EXIST
|
|
|
|
|
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/external/glfw/CMakeLists.txt")
|
|
|
|
|
message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/external/glm/CMakeLists.txt")
|
|
|
|
|
message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/external/lua/CMakeLists.txt")
|
|
|
|
|
message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/external/pugixml/CMakeLists.txt")
|
|
|
|
|
message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/external/freetype/CMakeLists.txt")
|
|
|
|
|
message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# add GLFW
|
|
|
|
|
add_subdirectory(external/glfw)
|
|
|
|
|
|
|
|
|
|
# add glad2
|
|
|
|
|
add_subdirectory(external/glad/src)
|
|
|
|
|
|
|
|
|
|
# add GLM
|
|
|
|
|
add_subdirectory(external/glm)
|
|
|
|
|
|
|
|
|
|
# add dearimgui
|
|
|
|
|
add_subdirectory(src/dearimgui)
|
|
|
|
|
|
|
|
|
|
# add lua -- https://github.com/walterschell/Lua
|
|
|
|
|
add_subdirectory(external/lua)
|
|
|
|
|
|
|
|
|
|
# add pugixml
|
|
|
|
|
add_subdirectory(external/pugixml)
|
|
|
|
|
|
|
|
|
|
# add freetype
|
|
|
|
|
add_subdirectory(external/freetype)
|
|
|
|
|
|
|
|
|
|
target_include_directories(${PROJECT_NAME}
|
|
|
|
|
PUBLIC "${PROJECT_BINARY_DIR}"
|
|
|
|
|
PUBLIC src
|
|
|
|
|
PUBLIC external/glfw/include
|
|
|
|
|
PUBLIC external/glm
|
|
|
|
|
PUBLIC external/lua/lua5.4.3/include
|
|
|
|
|
PUBLIC src/dearimgui
|
|
|
|
|
PUBLIC external/pugixml/src
|
|
|
|
|
PUBLIC external/glad/include
|
|
|
|
|
PUBLIC external/freetype/include
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
target_link_directories(${PROJECT_NAME}
|
|
|
|
|
PRIVATE external/glfw/src
|
|
|
|
|
PRIVATE external/glm
|
|
|
|
|
PRIVATE src/dearimgui
|
|
|
|
|
PRIVATE external/glad/src
|
|
|
|
|
PRIVATE external/freetype/src
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if(WIN32)
|
|
|
|
|
target_link_libraries(${PROJECT_NAME} opengl32.lib glfw glad glm dearimgui lua_static pugixml freetype)
|
|
|
|
|
elseif(UNIX)
|
|
|
|
|
target_link_libraries(${PROJECT_NAME} X11 GL glfw glad glm dearimgui lua_static pugixml freetype)
|
|
|
|
|
endif()
|