-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CMakeLists: Initial migration to CPM
LuaGenny related code has been commented out for now
- Loading branch information
Showing
12 changed files
with
5,317 additions
and
268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,235 +1,114 @@ | ||
# This file is automatically generated from cmake.toml - DO NOT EDIT | ||
# See https://github.com/build-cpp/cmkr for more information | ||
|
||
cmake_minimum_required(VERSION 3.15) | ||
|
||
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) | ||
message(FATAL_ERROR "In-tree builds are not supported. Run CMake from a separate directory: cmake -B build") | ||
endif() | ||
|
||
# Regenerate CMakeLists.txt automatically in the root project | ||
set(CMKR_ROOT_PROJECT OFF) | ||
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) | ||
set(CMKR_ROOT_PROJECT ON) | ||
|
||
# Bootstrap cmkr | ||
include(cmkr.cmake OPTIONAL RESULT_VARIABLE CMKR_INCLUDE_RESULT) | ||
if(CMKR_INCLUDE_RESULT) | ||
cmkr() | ||
endif() | ||
|
||
# Enable folder support | ||
set_property(GLOBAL PROPERTY USE_FOLDERS ON) | ||
endif() | ||
|
||
# Create a configure-time dependency on cmake.toml to improve IDE support | ||
if(CMKR_ROOT_PROJECT) | ||
configure_file(cmake.toml cmake.toml COPYONLY) | ||
endif() | ||
|
||
|
||
add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/MP>) | ||
|
||
cmake_minimum_required(VERSION 3.28) | ||
project(regenny) | ||
|
||
if(CMKR_ROOT_PROJECT AND NOT CMKR_DISABLE_VCPKG) | ||
include(FetchContent) | ||
message(STATUS "Fetching vcpkg (2023.12.12)...") | ||
FetchContent_Declare(vcpkg URL "https://github.com/microsoft/vcpkg/archive/refs/tags/2023.12.12.tar.gz") | ||
FetchContent_GetProperties(vcpkg) | ||
if(NOT vcpkg_POPULATED) | ||
FetchContent_Populate(vcpkg) | ||
include("${vcpkg_SOURCE_DIR}/scripts/buildsystems/vcpkg.cmake") | ||
endif() | ||
endif() | ||
|
||
include(FetchContent) | ||
|
||
message(STATUS "Fetching sdkgenny (cbf986af49c45afb2016c96202b66d66fa1cbd8e)...") | ||
FetchContent_Declare(sdkgenny | ||
GIT_REPOSITORY | ||
"https://github.com/cursey/sdkgenny.git" | ||
GIT_TAG | ||
cbf986af49c45afb2016c96202b66d66fa1cbd8e | ||
) | ||
FetchContent_MakeAvailable(sdkgenny) | ||
|
||
message(STATUS "Fetching luagenny (556c914a846ccf3f358b559e99d4610f71d71c29)...") | ||
FetchContent_Declare(luagenny | ||
GIT_REPOSITORY | ||
"https://github.com/praydog/luagenny.git" | ||
GIT_TAG | ||
556c914a846ccf3f358b559e99d4610f71d71c29 | ||
) | ||
FetchContent_MakeAvailable(luagenny) | ||
|
||
# Packages | ||
find_package(imgui REQUIRED) | ||
|
||
find_package(fmt REQUIRED) | ||
|
||
find_package(pegtl REQUIRED) | ||
|
||
find_package(unofficial-nativefiledialog REQUIRED) | ||
|
||
find_package(spdlog REQUIRED) | ||
|
||
find_package(utf8cpp REQUIRED) | ||
|
||
find_package(SDL2 REQUIRED) | ||
|
||
find_package(nlohmann_json REQUIRED) | ||
|
||
find_package(glad REQUIRED) | ||
|
||
find_package(sol2 REQUIRED) | ||
|
||
find_package(lua REQUIRED) | ||
|
||
# Target regenny | ||
set(CMKR_TARGET regenny) | ||
set(regenny_SOURCES "") | ||
|
||
list(APPEND regenny_SOURCES | ||
"src/AboutUi.cpp" | ||
"src/Config.cpp" | ||
"src/LoggerUi.cpp" | ||
"src/Main.cpp" | ||
"src/MemoryUi.cpp" | ||
"src/Process.cpp" | ||
"src/Project.cpp" | ||
"src/ReGenny.cpp" | ||
"src/Utility.cpp" | ||
"src/arch/Arch.cpp" | ||
"src/arch/Windows.cpp" | ||
"src/node/Array.cpp" | ||
"src/node/Base.cpp" | ||
"src/node/Bitfield.cpp" | ||
"src/node/Pointer.cpp" | ||
"src/node/Struct.cpp" | ||
"src/node/Undefined.cpp" | ||
"src/node/UndefinedBitfield.cpp" | ||
"src/node/Variable.cpp" | ||
"src/AboutUi.hpp" | ||
"src/Config.hpp" | ||
"src/Helpers.hpp" | ||
"src/LoggerUi.hpp" | ||
"src/MemoryUi.hpp" | ||
"src/Process.hpp" | ||
"src/Project.hpp" | ||
"src/ReGenny.hpp" | ||
"src/Utility.hpp" | ||
"src/arch/Arch.hpp" | ||
"src/arch/Windows.hpp" | ||
"src/node/Array.hpp" | ||
"src/node/Base.hpp" | ||
"src/node/Bitfield.hpp" | ||
"src/node/Pointer.hpp" | ||
"src/node/Property.hpp" | ||
"src/node/Struct.hpp" | ||
"src/node/Undefined.hpp" | ||
"src/node/UndefinedBitfield.hpp" | ||
"src/node/Variable.hpp" | ||
"thirdparty/SDL_Trigger/sdl_trigger.cpp" | ||
"thirdparty/scope_gaurd/scope_guard.hpp" | ||
"thirdparty/SDL_Trigger/sdl_trigger.h" | ||
) | ||
|
||
if(WIN32) # windows | ||
list(APPEND regenny_SOURCES | ||
"src/arch/Windows.rc" | ||
) | ||
endif() | ||
|
||
list(APPEND regenny_SOURCES | ||
cmake.toml | ||
) | ||
|
||
set(CMKR_SOURCES ${regenny_SOURCES}) | ||
add_executable(regenny) | ||
|
||
if(regenny_SOURCES) | ||
target_sources(regenny PRIVATE ${regenny_SOURCES}) | ||
endif() | ||
|
||
get_directory_property(CMKR_VS_STARTUP_PROJECT DIRECTORY ${PROJECT_SOURCE_DIR} DEFINITION VS_STARTUP_PROJECT) | ||
if(NOT CMKR_VS_STARTUP_PROJECT) | ||
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT regenny) | ||
endif() | ||
|
||
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${regenny_SOURCES}) | ||
|
||
target_compile_definitions(regenny PRIVATE | ||
UTF_CPP_CPLUSPLUS=201103L | ||
) | ||
|
||
target_compile_features(regenny PRIVATE | ||
cxx_std_17 | ||
) | ||
|
||
target_compile_options(regenny PRIVATE | ||
"/EHa" | ||
) | ||
|
||
target_include_directories(regenny PRIVATE | ||
"src/" | ||
"thirdparty/scope_gaurd/" | ||
"thirdparty/SDL_Trigger/" | ||
) | ||
|
||
# Set project wide C++ standard | ||
set(CMAKE_CXX_STANDARD 23) | ||
|
||
# | ||
# Dependencies | ||
# | ||
include(cmake/CPM.cmake) | ||
CPMAddPackage( | ||
NAME imgui | ||
GITHUB_REPOSITORY ocornut/imgui | ||
VERSION 1.90.9-docking | ||
DOWNLOAD_ONLY YES) | ||
|
||
if (imgui_ADDED) | ||
file(GLOB imgui_sources ${imgui_SOURCE_DIR}/*.cpp) | ||
add_library(imgui STATIC | ||
${imgui_sources} | ||
${imgui_SOURCE_DIR}/backends/imgui_impl_sdl2.cpp | ||
${imgui_SOURCE_DIR}/backends/imgui_impl_opengl3.cpp | ||
${imgui_SOURCE_DIR}/misc/cpp/imgui_stdlib.cpp) | ||
target_include_directories(imgui PUBLIC | ||
$<BUILD_INTERFACE:${imgui_SOURCE_DIR}> | ||
$<BUILD_INTERFACE:${imgui_SOURCE_DIR}/backends> | ||
$<BUILD_INTERFACE:${imgui_SOURCE_DIR}/misc/cpp>) | ||
target_link_libraries(imgui PUBLIC SDL2::SDL2) | ||
endif () | ||
|
||
CPMAddPackage("gh:fmtlib/fmt#11.0.2") | ||
CPMAddPackage("gh:taocpp/pegtl#3.2.7") | ||
|
||
CPMAddPackage( | ||
NAME nativefiledialog | ||
GITHUB_REPOSITORY mlabbe/nativefiledialog | ||
VERSION 1.16 | ||
GIT_TAG release_116 | ||
DOWNLOAD_ONLY YES) | ||
|
||
if (nativefiledialog_ADDED) | ||
add_library(nativefiledialog STATIC | ||
${nativefiledialog_SOURCE_DIR}/src/nfd_common.c | ||
${nativefiledialog_SOURCE_DIR}/src/nfd_win.cpp) | ||
target_include_directories(nativefiledialog PUBLIC $<BUILD_INTERFACE:${nativefiledialog_SOURCE_DIR}>/src/include) | ||
endif () | ||
|
||
CPMAddPackage( | ||
NAME spdlog | ||
GITHUB_REPOSITORY gabime/spdlog | ||
VERSION 1.14.1 | ||
OPTIONS | ||
"SPDLOG_FMT_EXTERNAL ON") | ||
CPMAddPackage( | ||
NAME utfcpp | ||
GITHUB_REPOSITORY nemtrif/utfcpp | ||
VERSION 4.0.5 | ||
DOWNLOAD_ONLY YES) | ||
|
||
if (utfcpp_ADDED) | ||
add_library(utfcpp INTERFACE) | ||
target_include_directories(utfcpp INTERFACE $<BUILD_INTERFACE:${utfcpp_SOURCE_DIR}/source>) | ||
target_compile_definitions(utfcpp INTERFACE UTF_CPP_CPLUSPLUS=202002L) | ||
endif () | ||
|
||
CPMAddPackage("gh:nlohmann/[email protected]") | ||
#CPMAddPackage("gh:libsdl-org/SDL#release-2.30.5") | ||
CPMAddPackage( | ||
NAME SDL2 | ||
GITHUB_REPOSITORY libsdl-org/SDL | ||
VERSION 2.30.5 | ||
GIT_TAG release-2.30.5 | ||
OPTIONS | ||
"SDL_SHARED OFF" | ||
"SDL_STATIC ON") | ||
CPMAddPackage("gh:cursey/sdkgenny#cbf986af49c45afb2016c96202b66d66fa1cbd8e") | ||
|
||
# | ||
# Third party | ||
# | ||
|
||
# Glad | ||
add_library(glad STATIC "thirdparty/glad/src/glad.c") | ||
target_include_directories(glad PUBLIC "thirdparty/glad/include") | ||
|
||
# scope_guard | ||
add_library(scope_guard INTERFACE) | ||
target_include_directories(scope_guard INTERFACE "thirdparty/scope_guard") | ||
|
||
# SDL_Trigger | ||
add_library(SDL_Trigger STATIC "thirdparty/SDL_Trigger/SDL_Trigger.cpp") | ||
target_include_directories(SDL_Trigger INTERFACE "thirdparty/SDL_Trigger") | ||
target_link_libraries(SDL_Trigger PUBLIC SDL2::SDL2) | ||
|
||
# | ||
# regenny | ||
# | ||
file(GLOB_RECURSE regenny_sources "src/**") | ||
add_executable(regenny ${regenny_sources}) | ||
target_include_directories(regenny PRIVATE "src") | ||
target_link_libraries(regenny PRIVATE | ||
imgui::imgui | ||
fmt::fmt | ||
taocpp::pegtl | ||
unofficial::nativefiledialog::nfd | ||
spdlog::spdlog | ||
SDL2::SDL2 | ||
SDL2::SDL2main | ||
nlohmann_json::nlohmann_json | ||
glad::glad | ||
sdkgenny::sdkgenny | ||
lua | ||
sol2 | ||
luagenny::luagenny | ||
) | ||
|
||
add_custom_command( | ||
TARGET regenny POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:luagenny_shared> $<TARGET_FILE_DIR:regenny>) | ||
|
||
unset(CMKR_TARGET) | ||
unset(CMKR_SOURCES) | ||
|
||
# Target test0 | ||
set(CMKR_TARGET test0) | ||
set(test0_SOURCES "") | ||
|
||
list(APPEND test0_SOURCES | ||
"examples/test0.cpp" | ||
) | ||
|
||
list(APPEND test0_SOURCES | ||
cmake.toml | ||
) | ||
|
||
set(CMKR_SOURCES ${test0_SOURCES}) | ||
add_executable(test0) | ||
|
||
if(test0_SOURCES) | ||
target_sources(test0 PRIVATE ${test0_SOURCES}) | ||
endif() | ||
|
||
get_directory_property(CMKR_VS_STARTUP_PROJECT DIRECTORY ${PROJECT_SOURCE_DIR} DEFINITION VS_STARTUP_PROJECT) | ||
if(NOT CMKR_VS_STARTUP_PROJECT) | ||
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT test0) | ||
endif() | ||
|
||
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${test0_SOURCES}) | ||
|
||
target_compile_features(test0 PRIVATE | ||
cxx_std_17 | ||
) | ||
|
||
unset(CMKR_TARGET) | ||
unset(CMKR_SOURCES) | ||
|
||
imgui | ||
fmt::fmt | ||
taocpp::pegtl | ||
nativefiledialog | ||
spdlog::spdlog | ||
utfcpp | ||
nlohmann_json::nlohmann_json | ||
SDL2::SDL2 | ||
SDL2::SDL2main | ||
sdkgenny::sdkgenny | ||
glad | ||
scope_guard | ||
SDL_Trigger) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# SPDX-License-Identifier: MIT | ||
# | ||
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors | ||
|
||
set(CPM_DOWNLOAD_VERSION 0.40.0) | ||
set(CPM_HASH_SUM "7b354f3a5976c4626c876850c93944e52c83ec59a159ae5de5be7983f0e17a2a") | ||
|
||
if(CPM_SOURCE_CACHE) | ||
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") | ||
elseif(DEFINED ENV{CPM_SOURCE_CACHE}) | ||
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") | ||
else() | ||
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake") | ||
endif() | ||
|
||
# Expand relative path. This is important if the provided path contains a tilde (~) | ||
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE) | ||
|
||
file(DOWNLOAD | ||
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake | ||
${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM} | ||
) | ||
|
||
include(${CPM_DOWNLOAD_LOCATION}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.