Changed install to source based

This commit is contained in:
Rebekah 2020-08-10 16:32:37 -04:00
parent 9d59f4be23
commit eaf27e05c6
19 changed files with 88 additions and 84 deletions

View File

@ -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")

14
cmake/AddNekohook.cmake Normal file
View File

@ -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)

13
cmake/CMakeLists.txt Normal file
View File

@ -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)

View File

@ -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")

View File

@ -1,5 +0,0 @@
function(nekohook_link_libraries)
endfunction(nekohook_link_libraries)

View File

@ -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)

View File

@ -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/")

View File

@ -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/)

View File

@ -18,7 +18,7 @@
*/
// TODO, add texture func with texture load with drawline
#include <cmath>
/*#include <cmath>
#include <cstring> // 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

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <boost/circular_buffer.hpp>
/*#include <boost/circular_buffer.hpp>
#include <chrono>
#include <unordered_map>
@ -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

View File

@ -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")

View File

@ -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)

View File

@ -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)

View File

@ -19,8 +19,8 @@
#pragma once
#include "util/geometry.hpp"
#include "gfx/color.hpp"
#include "../util/geometry.hpp"
#include "../gfx/color.hpp"
namespace nekohook {

View File

@ -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)

View File

@ -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)

View File

@ -1,7 +1,7 @@
#include <variant>
#include "ui/command.hpp"
#include "command.hpp"
#pragma once

View File

@ -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)

View File

@ -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)