Batman
This commit is contained in:
91
CmakeLists.txt
Normal file
91
CmakeLists.txt
Normal file
@@ -0,0 +1,91 @@
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
project(KevEngine)
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
set(CMAKE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
set(DEFAULT_BUILD_TYPE "Release")
|
||||
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
||||
set(DEFAULT_BUILD_TYPE "Debug")
|
||||
endif()
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.")
|
||||
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING "Choose the type of build." FORCE)
|
||||
# Set the possible values of build type for cmake-gui
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
|
||||
endif()
|
||||
|
||||
|
||||
if(WIN32) # Install dlls in the same directory as the executable on Windows
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
endif()
|
||||
|
||||
# Fetch LUA
|
||||
# ++++++++++
|
||||
FetchContent_Declare(
|
||||
lua
|
||||
URL https://github.com/marovira/lua/archive/refs/tags/5.4.4.tar.gz
|
||||
)
|
||||
FetchContent_MakeAvailable(lua)
|
||||
|
||||
# Fetch SOL2
|
||||
# ++++++++++
|
||||
FetchContent_Declare(
|
||||
sol2
|
||||
URL https://github.com/ThePhD/sol2/archive/refs/tags/v3.3.0.tar.gz
|
||||
)
|
||||
FetchContent_MakeAvailable(sol2)
|
||||
|
||||
set(USE_NGHTTP2 OFF)
|
||||
|
||||
FetchContent_Declare(cpr GIT_REPOSITORY https://github.com/libcpr/cpr.git
|
||||
GIT_TAG dec9422db3af470641f8b0d90e4b451c4daebf64) # Replace with your desired git commit from: https://github.com/libcpr/cpr/releases
|
||||
FetchContent_MakeAvailable(cpr)
|
||||
|
||||
|
||||
find_library(GDIPLUS_LIBRARY NAMES libgdiplus gdiplus)
|
||||
set(GDIPLUS_LIBRARY gdiplus)
|
||||
|
||||
set(LIBS XInput)
|
||||
|
||||
|
||||
set(SRC_FILES
|
||||
"src/AbstractGame.cpp"
|
||||
"src/Game.cpp"
|
||||
"src/GameDefines.h"
|
||||
"src/GameEngine.cpp"
|
||||
"src/GameWinMain.cpp"
|
||||
"src/resource.h")
|
||||
|
||||
add_executable(${PROJECT_NAME} WIN32 ${SRC_FILES})
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE cpr::cpr sol2 lua::lua ${LIBS})
|
||||
|
||||
|
||||
|
||||
# Copy /lua folder to output directory
|
||||
add_custom_target(CopyLuaScripts ALL
|
||||
COMMENT "Copying Lua scripts to output directory"
|
||||
)
|
||||
|
||||
add_custom_command(TARGET CopyLuaScripts POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/lua
|
||||
$<TARGET_FILE_DIR:${PROJECT_NAME}>/lua)
|
||||
|
||||
add_custom_target(CopyResources ALL
|
||||
COMMENT "Copying resources to output directory"
|
||||
)
|
||||
|
||||
add_custom_command(TARGET CopyResources POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/resources
|
||||
$<TARGET_FILE_DIR:${PROJECT_NAME}>/resources)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user