You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
2.8 KiB
CMake
90 lines
2.8 KiB
CMake
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 11)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
|
|
|
configure_file(LunariumConfig.h.in LunariumConfig.h)
|
|
|
|
# Source Files
|
|
set(LUNARIUM_SRC
|
|
"src/test_main.cpp"
|
|
"src/utils/Logger.cpp"
|
|
"src/utils/HighResTimer.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()
|
|
|
|
# add GLFW
|
|
add_subdirectory(external/glfw)
|
|
|
|
# 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)
|
|
|
|
target_include_directories(${PROJECT_NAME}
|
|
PUBLIC "${PROJECT_BINARY_DIR}"
|
|
PUBLIC external/glfw/include
|
|
PUBLIC external/glm
|
|
PUBLIC external/lua/lua5.4.3/include
|
|
PUBLIC src/dearimgui
|
|
PUBLIC external/pugixml/src
|
|
)
|
|
|
|
target_link_directories(${PROJECT_NAME}
|
|
PRIVATE external/glfw/src
|
|
PRIVATE external/glm
|
|
PRIVATE src/dearimgui
|
|
)
|
|
|
|
if(WIN32)
|
|
target_link_libraries(${PROJECT_NAME} opengl32.lib glfw glm dearimgui lua_static pugixml)
|
|
elseif(UNIX)
|
|
target_link_libraries(${PROJECT_NAME} GL glfw glm dearimgui lua_static pugixml)
|
|
endif()
|