72 lines
2.2 KiB
CMake
72 lines
2.2 KiB
CMake
cmake_minimum_required(VERSION 3.15)
|
|
project(VoidExampleMod LANGUAGES CXX)
|
|
|
|
# ============================================================
|
|
# Project settings
|
|
# ============================================================
|
|
set(CMAKE_CXX_STANDARD 23)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
include(FetchContent)
|
|
|
|
add_compile_options(-ffunction-sections -fdata-sections)
|
|
add_link_options(-Wl,--gc-sections)
|
|
# ============================================================
|
|
# Source / includes
|
|
# ============================================================
|
|
file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS "src/*.cpp")
|
|
|
|
# ============================================================
|
|
# Platform flags
|
|
# ============================================================
|
|
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
|
add_definitions(-DWIN32_LEAN_AND_MEAN -DNOMINMAX)
|
|
else()
|
|
add_compile_options(-fPIC)
|
|
endif()
|
|
|
|
FetchContent_Declare(
|
|
VoidLoaderApi
|
|
GIT_REPOSITORY https://git.faumaray.ru/VoidLoader/VoidLoaderApi.git
|
|
GIT_TAG main # release-1.10.0
|
|
)
|
|
|
|
|
|
FetchContent_MakeAvailable(VoidLoaderApi)
|
|
|
|
# ============================================================
|
|
# Build shared library
|
|
# ============================================================
|
|
add_library(${PROJECT_NAME} SHARED ${SOURCES})
|
|
target_include_directories(${PROJECT_NAME}
|
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
|
|
)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC VoidLoaderApiInterface)
|
|
|
|
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
|
target_link_options(${PROJECT_NAME} PRIVATE
|
|
-Wl,-z,defs
|
|
-Wl,--no-undefined
|
|
-Wl,--as-needed
|
|
-static-libstdc++
|
|
-static-libgcc
|
|
-Wl,-O1
|
|
-Wl,--gc-sections
|
|
-Wl,--export-dynamic
|
|
-Wl,--undefined=__start_vlmods
|
|
-Wl,--undefined=__stop_vlmods
|
|
)
|
|
endif()
|
|
|
|
|
|
# Output name: YourAgent.dll / libYourAgent.so
|
|
set_target_properties(${PROJECT_NAME} PROPERTIES
|
|
PREFIX ""
|
|
SUFFIX ".vlmod"
|
|
OUTPUT_NAME "VoidExampleMod"
|
|
)
|
|
if(UNIX AND NOT APPLE)
|
|
target_link_options(${PROJECT_NAME} PRIVATE -Wl,--enable-new-dtags -Wl,-rpath,\$ORIGIN)
|
|
set_target_properties(${PROJECT_NAME} PROPERTIES BUILD_RPATH "\$ORIGIN" INSTALL_RPATH "\$ORIGIN")
|
|
endif() |