From eaf27e05c6854d152cde8d219e731faa795c25bf Mon Sep 17 00:00:00 2001 From: oneechanhax Date: Mon, 10 Aug 2020 16:32:37 -0400 Subject: [PATCH] Changed install to source based --- CMakeLists.txt | 15 ++------ cmake/AddNekohook.cmake | 14 +++++++ cmake/CMakeLists.txt | 13 +++++++ cmake/NekohookConfig.cmake.in | 5 +++ cmake/modules/AddNekohook.cmake | 5 --- cmake/modules/Nekohook.cmake | 10 ----- src/CMakeLists.txt | 7 +++- src/dummy/CMakeLists.txt | 5 +++ src/dummy/drawing.cpp | 4 +- src/dummy/prediction.cpp | 16 ++++---- src/nekohook/CMakeLists.txt | 57 +++++++++------------------- src/nekohook/features/CMakeLists.txt | 6 +-- src/nekohook/game/CMakeLists.txt | 1 + src/nekohook/game/entity.hpp | 4 +- src/nekohook/gfx/CMakeLists.txt | 1 + src/nekohook/ui/CMakeLists.txt | 1 + src/nekohook/ui/var.hpp | 2 +- src/nekohook/util/CMakeLists.txt | 3 +- src/psudocrt/CMakeLists.txt | 3 ++ 19 files changed, 88 insertions(+), 84 deletions(-) create mode 100644 cmake/AddNekohook.cmake create mode 100644 cmake/CMakeLists.txt create mode 100644 cmake/NekohookConfig.cmake.in delete mode 100644 cmake/modules/AddNekohook.cmake delete mode 100644 cmake/modules/Nekohook.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 68ec985..824f3fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,15 +1,8 @@ -## -# Welcome to the cmake lists file, this controls how nekohook will build for your system -## - cmake_minimum_required(VERSION 3.14) project(nekohook CXX) -# Settings -set(NEKOHOOK_BUILD_SHARED OFF CACHE BOOL "Build the shared library") -set(NEKOHOOK_BUILD_STATIC ON CACHE BOOL "Build the static library") -set(NEKOHOOK_GFX opengl CACHE STRING "Graphics api to use: none;opengl") -set(NEKOHOOK_X86 OFF CACHE BOOL "Build x86 libraries for x86_64") -# Lib itself -add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/src/") +add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/cmake") +add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/src") + +include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/AddNekohook.cmake") diff --git a/cmake/AddNekohook.cmake b/cmake/AddNekohook.cmake new file mode 100644 index 0000000..5f85d65 --- /dev/null +++ b/cmake/AddNekohook.cmake @@ -0,0 +1,14 @@ + +function(AddNekohook name) + set(target "nekohook-${name}") + + add_library("${target}" SHARED ${NEKOHOOK_SOURCES} ${ARGN}) + set_property(TARGET "${target}" PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) + set_property(TARGET "${target}" PROPERTY CXX_STANDARD 20) + + target_include_directories("${target}" PRIVATE "${NEKOHOOK_SRC_DIR}") + target_include_directories("${target}" PRIVATE "${NEKOHOOK_SRC_DIR}/nekohook") + if (UNIX AND NOT APPLE) + target_link_libraries("${target}" PRIVATE rt pthread) + endif () +endfunction(AddNekohook) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt new file mode 100644 index 0000000..66037f1 --- /dev/null +++ b/cmake/CMakeLists.txt @@ -0,0 +1,13 @@ + + + + +include(CMakePackageConfigHelpers) +configure_package_config_file(NekohookConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/NekohookConfig.cmake + INSTALL_DESTINATION lib/cmake/Nekohook + PATH_VARS CMAKE_INSTALL_PREFIX) +install(FILES AddNekohook.cmake ${CMAKE_CURRENT_BINARY_DIR}/NekohookConfig.cmake DESTINATION lib/cmake/Nekohook) + + + + diff --git a/cmake/NekohookConfig.cmake.in b/cmake/NekohookConfig.cmake.in new file mode 100644 index 0000000..d3113e1 --- /dev/null +++ b/cmake/NekohookConfig.cmake.in @@ -0,0 +1,5 @@ +set(NEKOHOOK_SRC_DIR "@CMAKE_INSTALL_PREFIX@/src") +include("@CMAKE_INSTALL_PREFIX@/src/nekohook/CMakeLists.txt") +include("@CMAKE_INSTALL_PREFIX@/src/psudocrt/CMakeLists.txt") +#set(NEKOHOOK_SOURCES "${NEKOHOOK_SOURCES}" PARENT_SCOPE) +include("@CMAKE_INSTALL_PREFIX@/lib/cmake/Nekohook/AddNekohook.cmake") diff --git a/cmake/modules/AddNekohook.cmake b/cmake/modules/AddNekohook.cmake deleted file mode 100644 index 2b02a4b..0000000 --- a/cmake/modules/AddNekohook.cmake +++ /dev/null @@ -1,5 +0,0 @@ - -function(nekohook_link_libraries) - - -endfunction(nekohook_link_libraries) diff --git a/cmake/modules/Nekohook.cmake b/cmake/modules/Nekohook.cmake deleted file mode 100644 index 3e245a2..0000000 --- a/cmake/modules/Nekohook.cmake +++ /dev/null @@ -1,10 +0,0 @@ - -check_ipo_supported() - -function(internal_nekohook_link_libraries) - - if(NEKOHOOK_BUILD_SHARED=true shared_library) - set_property(TARGET nekohook-static PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) - set_property(TARGET nekohook-shared PROPERTY CXX_STANDARD 17) - -endfunction(internal_nekohook_link_libraries) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b7f0076..dbc4130 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,9 @@ add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/psudocrt/") + add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/nekohook/") -#add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/dummy/") +set(NEKOHOOK_SRC_ROOT "${CMAKE_CURRENT_LIST_DIR}" PARENT_SCOPE) +#set(NEKOHOOK_SOURCES "${sources}" PARENT_SCOPE) + +add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/dummy/") + diff --git a/src/dummy/CMakeLists.txt b/src/dummy/CMakeLists.txt index e69de29..f4ca486 100644 --- a/src/dummy/CMakeLists.txt +++ b/src/dummy/CMakeLists.txt @@ -0,0 +1,5 @@ + +file(GLOB_RECURSE dummy_src "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp") +add_library(nekohook-dummy STATIC ${dummy_src}) +install(TARGETS nekohook-dummy DESTINATION lib/) + diff --git a/src/dummy/drawing.cpp b/src/dummy/drawing.cpp index 8124892..fec0a52 100644 --- a/src/dummy/drawing.cpp +++ b/src/dummy/drawing.cpp @@ -18,7 +18,7 @@ */ // TODO, add texture func with texture load with drawline -#include +/*#include #include // strlen #include "util/math.hpp" // Contains pi defines @@ -106,4 +106,4 @@ uservar::Enum default_font(gui_menu, {Fonts[0], Fonts[1], Fonts[2]}, "gui_font", uservar::Int default_font_size(gui_menu, "gui_font_size", 6, "Gui font size", "The main font size"); -} // namespace draw +} */ // namespace draw diff --git a/src/dummy/prediction.cpp b/src/dummy/prediction.cpp index 5e01c55..578afe8 100644 --- a/src/dummy/prediction.cpp +++ b/src/dummy/prediction.cpp @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -#include +/*#include #include #include @@ -53,7 +53,7 @@ static const PredictionCache_s& GetCache(int entity) { // Cache Cleanup duty static void AfterWorldTick() { - /*CatEntity* local_ent = GetLocalPlayer(); + CatEntity* local_ent = GetLocalPlayer(); int local_ent_idx = 0; if (local_ent && !GetDormant(local_ent) && GetAlive(local_ent)) { int ent_count = GetEntityCount(); @@ -63,16 +63,16 @@ static void AfterWorldTick() { break; } } - }*/ + } - /*for(size_t i = 0; i < origin_cache.size();) { + for(size_t i = 0; i < origin_cache.size();) { local_ent_idx auto ii = origin_cache.begin() + i; if (ii->second.tick != time_keeper) origin_cache.erase(ii); else i++; - }*/ + } time_keeper = !time_keeper; } @@ -173,7 +173,7 @@ void DrawTick() { } } //#endif - /*int ent_count = GetEntityCount(); + int ent_count = GetEntityCount(); for (int i = 0; i < ent_count; i++) { CatEntity* entity = GetEntity(i); if (!entity || GetDormant(entity) || !GetAlive(entity) || GetType(entity) @@ -189,7 +189,7 @@ void DrawTick() { cur_pos; return true; }), wts1)) draw::Rect(wts1.first - 4, wts1.second - 4, 8, 8, colors::white); - }*/ + } } void Init() { @@ -197,4 +197,4 @@ void Init() { events::draw.Listen(DrawTick); } -} // namespace pred +}*/ // namespace pred diff --git a/src/nekohook/CMakeLists.txt b/src/nekohook/CMakeLists.txt index 82ecbc4..e70a4f0 100644 --- a/src/nekohook/CMakeLists.txt +++ b/src/nekohook/CMakeLists.txt @@ -1,42 +1,19 @@ +set(NEKOHOOK_SOURCES "") +macro(AddFolder name) + file(GLOB tmp_sources "${CMAKE_CURRENT_LIST_DIR}/${name}/*.cpp") + file(GLOB headers "${CMAKE_CURRENT_LIST_DIR}/${name}/*.hpp") + set(NEKOHOOK_SOURCES ${NEKOHOOK_SOURCES} ${tmp_sources}) + #install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/${name}/CMakeLists.txt" DESTINATION "src/nekohook/${name}/") + install(FILES ${tmp_sources} DESTINATION "src/nekohook/${name}") + install(FILES ${headers} DESTINATION "src/nekohook/${name}") +endmacro(AddFolder) -# TODO: add function to test a library for wanted functions and apply conditionals as nessesary +AddFolder(.) +AddFolder(features) +AddFolder(game) +AddFolder(gfx) +AddFolder(ui) +AddFolder(util) +set(NEKOHOOK_SOURCES ${NEKOHOOK_SOURCES} PARENT_SCOPE) -set(sources "") -add_subdirectory(features) -add_subdirectory(game) -add_subdirectory(gfx) -add_subdirectory(ui) -add_subdirectory(util) - -set(suffix "") -if (NEKOHOOK_X86) - set(suffix "32") -endif(NEKOHOOK_X86) - -add_custom_target(nekohook) -macro(ApplyCommon in_target) - add_dependencies(nekohook ${in_target}) - set_property(TARGET ${in_target} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) - set_property(TARGET ${in_target} PROPERTY CXX_STANDARD 17) - set_property(TARGET ${in_target} PROPERTY OUTPUT_NAME nekohook) - - target_include_directories(${in_target} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/") - target_include_directories(${in_target} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../") - if (UNIX AND NOT APPLE) - target_link_libraries(${in_target} PUBLIC rt pthread) - endif () - - install(TARGETS ${in_target} DESTINATION lib${suffix}) -endmacro() - -if(NEKOHOOK_BUILD_SHARED) - add_library(nekohook_shared SHARED ${sources}) - ApplyCommon(nekohook_shared) -endif(NEKOHOOK_BUILD_SHARED) -if(NEKOHOOK_BUILD_STATIC) - add_library(nekohook_static STATIC ${sources}) - ApplyCommon(nekohook_static) -endif(NEKOHOOK_BUILD_STATIC) - - -install(FILES ${headers} DESTINATION include/nekohook) +install(FILES "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "src/nekohook") diff --git a/src/nekohook/features/CMakeLists.txt b/src/nekohook/features/CMakeLists.txt index e70987d..052471b 100644 --- a/src/nekohook/features/CMakeLists.txt +++ b/src/nekohook/features/CMakeLists.txt @@ -1,6 +1,6 @@ -file(GLOB tmp_sources "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp") -file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp") -set(sources ${sources} ${tmp_sources} PARENT_SCOPE) +file(GLOB sources "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp") +add_library(nekohook-dummy STATIC ${sources}) +install(TARGETS nekohook-dummy DESTINATION lib) install(FILES ${headers} DESTINATION include/nekohook/features) diff --git a/src/nekohook/game/CMakeLists.txt b/src/nekohook/game/CMakeLists.txt index a9e17f6..adddb95 100644 --- a/src/nekohook/game/CMakeLists.txt +++ b/src/nekohook/game/CMakeLists.txt @@ -1,4 +1,5 @@ file(GLOB tmp_sources "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp") file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp") set(sources ${sources} ${tmp_sources} PARENT_SCOPE) +install(FILES ${tmp_sources} DESTINATION src/nekohook/game) install(FILES ${headers} DESTINATION include/nekohook/game) diff --git a/src/nekohook/game/entity.hpp b/src/nekohook/game/entity.hpp index 7dd33d2..a3bcb8d 100644 --- a/src/nekohook/game/entity.hpp +++ b/src/nekohook/game/entity.hpp @@ -19,8 +19,8 @@ #pragma once -#include "util/geometry.hpp" -#include "gfx/color.hpp" +#include "../util/geometry.hpp" +#include "../gfx/color.hpp" namespace nekohook { diff --git a/src/nekohook/gfx/CMakeLists.txt b/src/nekohook/gfx/CMakeLists.txt index 1d07755..8b793c6 100644 --- a/src/nekohook/gfx/CMakeLists.txt +++ b/src/nekohook/gfx/CMakeLists.txt @@ -1,4 +1,5 @@ file(GLOB tmp_sources "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp") file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp") set(sources ${sources} ${tmp_sources} PARENT_SCOPE) +install(FILES ${tmp_sources} DESTINATION src/nekohook/gfx) install(FILES ${headers} DESTINATION include/nekohook/gfx) diff --git a/src/nekohook/ui/CMakeLists.txt b/src/nekohook/ui/CMakeLists.txt index 93b8774..3a039ab 100644 --- a/src/nekohook/ui/CMakeLists.txt +++ b/src/nekohook/ui/CMakeLists.txt @@ -1,4 +1,5 @@ file(GLOB tmp_sources "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp") file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp") set(sources ${sources} ${tmp_sources} PARENT_SCOPE) +install(FILES ${tmp_sources} DESTINATION src/nekohook/ui) install(FILES ${headers} DESTINATION include/nekohook/ui) diff --git a/src/nekohook/ui/var.hpp b/src/nekohook/ui/var.hpp index 52fa6a2..f0c2afe 100644 --- a/src/nekohook/ui/var.hpp +++ b/src/nekohook/ui/var.hpp @@ -1,7 +1,7 @@ #include -#include "ui/command.hpp" +#include "command.hpp" #pragma once diff --git a/src/nekohook/util/CMakeLists.txt b/src/nekohook/util/CMakeLists.txt index 93b8774..0eb53bf 100644 --- a/src/nekohook/util/CMakeLists.txt +++ b/src/nekohook/util/CMakeLists.txt @@ -1,4 +1,5 @@ file(GLOB tmp_sources "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp") file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp") set(sources ${sources} ${tmp_sources} PARENT_SCOPE) -install(FILES ${headers} DESTINATION include/nekohook/ui) +install(FILES ${tmp_sources} DESTINATION src/nekohook/util) +install(FILES ${headers} DESTINATION include/nekohook/util) diff --git a/src/psudocrt/CMakeLists.txt b/src/psudocrt/CMakeLists.txt index 95715db..9b36cf8 100644 --- a/src/psudocrt/CMakeLists.txt +++ b/src/psudocrt/CMakeLists.txt @@ -2,3 +2,6 @@ # Do we even need this thing? i mean it helps, but what about organizing sources in cmake set(psudocrt_start "${CMAKE_CURRENT_SOURCE_DIR}/start.cpp" PARENT_SCOPE) set(psudocrt_end "${CMAKE_CURRENT_SOURCE_DIR}/end.cpp" PARENT_SCOPE) +install(FILES ${psudocrt_start} ${psudocrt_end} DESTINATION src/psudocrt/) +install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt" DESTINATION src/psudocrt) +