12 files changed
+286
-15
No files matched your search
@@ -0,0 +1,56 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
project(VoidLoaderApi LANGUAGES CXX)
|
||||
|
||||
# ============================================================
|
||||
# Project settings
|
||||
# ============================================================
|
||||
set(CMAKE_CXX_STANDARD 26)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
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()
|
||||
|
||||
# ============================================================
|
||||
# Build shared library
|
||||
# ============================================================
|
||||
add_library(${PROJECT_NAME} STATIC ${SOURCES})
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
)
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
||||
target_link_options(${PROJECT_NAME} PRIVATE
|
||||
-Wl,-z,defs # no undefined symbols at link
|
||||
-Wl,--no-undefined
|
||||
-Wl,--as-needed
|
||||
-static-libstdc++ # pull libstdc++ into .so
|
||||
-static-libgcc # pull libgcc into .so
|
||||
-Wl,-O1
|
||||
-Wl,--gc-sections
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
# Output name: YourAgent.dll / libYourAgent.so
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||
PREFIX ""
|
||||
OUTPUT_NAME "VoidLoaderApi"
|
||||
)
|
||||
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()
|
||||
Reference in new issue
Block a user