Skip to content

Commit

Permalink
Feature/Migrate to CPM (#22)
Browse files Browse the repository at this point in the history
Co-authored-by: cursey <[email protected]>
  • Loading branch information
cursey and cursey authored Sep 8, 2024
1 parent 31ad50b commit 5ed0f00
Show file tree
Hide file tree
Showing 19 changed files with 5,343 additions and 594 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
on: [push, pull_request]
on: [ push, pull_request ]
jobs:
build:
if: ${{github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository)}}
runs-on: windows-2022
strategy:
matrix:
arch: [x64, Win32]
arch: [ x64, Win32 ]
include:
- arch: x64
triplet: x64-windows
Expand All @@ -18,7 +18,7 @@ jobs:

- name: Build
run: |
cmake -B build-${{matrix.arch}} -A ${{matrix.arch}} -DCMAKE_BUILD_TYPE=Release -DCMAKE_UNITY_BUILD=ON -DVCPKG_TARGET_TRIPLET=${{matrix.triplet}}
cmake -B build-${{matrix.arch}} -A ${{matrix.arch}} -DCMAKE_BUILD_TYPE=Release -DVCPKG_TARGET_TRIPLET=${{matrix.triplet}}
cmake --build build-${{matrix.arch}} --config Release --parallel
- name: Upload artifacts
Expand Down
258 changes: 27 additions & 231 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,235 +1,31 @@
# 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)
set(CMAKE_CXX_STANDARD 23)
include(cmake/CPM.cmake)

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/"
)
add_subdirectory(third_party)

#
# 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
lua
sol2::sol2
luagenny
)
82 changes: 0 additions & 82 deletions cmake.toml

This file was deleted.

24 changes: 24 additions & 0 deletions cmake/CPM.cmake
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})
Loading

0 comments on commit 5ed0f00

Please sign in to comment.