93 lines
2.1 KiB
CMake
93 lines
2.1 KiB
CMake
cmake_minimum_required(VERSION 3.21)
|
|
project(Hiload)
|
|
|
|
# I just like to have this with my tooling. Also might be required for proper hotreloading.
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
set(CMAKE_C_STANDARD 11)
|
|
|
|
# Conditionally define _GNU_SOURCE for Linux systems
|
|
if(UNIX AND NOT APPLE)
|
|
# This checks for Linux (UNIX but not macOS)
|
|
add_compile_definitions(_GNU_SOURCE)
|
|
message(STATUS "Defining _GNU_SOURCE for Unix build")
|
|
endif()
|
|
|
|
# Handle 3rd party dependencies
|
|
# #############################
|
|
|
|
set(COPY_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/scripts/copy_dependencies.sh)
|
|
|
|
execute_process(
|
|
COMMAND bash ${COPY_SCRIPT}
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
RESULT_VARIABLE SCRIPT_RESULT
|
|
OUTPUT_VARIABLE SCRIPT_OUTPUT
|
|
ERROR_VARIABLE SCRIPT_ERROR
|
|
)
|
|
|
|
# Check if the script executed successfully
|
|
if(NOT SCRIPT_RESULT EQUAL 0)
|
|
message(WARNING "Script execution failed: ${SCRIPT_ERROR}")
|
|
else()
|
|
message(STATUS "Dependencies copied:\n${SCRIPT_OUTPUT}")
|
|
endif()
|
|
|
|
|
|
# hiload library
|
|
# ##############
|
|
|
|
add_library(hiload SHARED
|
|
src/hiload.c
|
|
src/symbols.c
|
|
|
|
# dependencies
|
|
src/str.c
|
|
src/logger/sc_log.c
|
|
)
|
|
|
|
set_property(TARGET hiload PROPERTY POSITION_INDEPENDENT_CODE ON)
|
|
target_link_libraries(hiload dl)
|
|
|
|
# Specify the public headers location
|
|
target_include_directories(hiload PUBLIC
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> # During build
|
|
$<INSTALL_INTERFACE:include> # When installed
|
|
)
|
|
|
|
install(TARGETS hiload
|
|
EXPORT hiloadTargets
|
|
ARCHIVE DESTINATION lib
|
|
LIBRARY DESTINATION lib
|
|
RUNTIME DESTINATION bin
|
|
)
|
|
|
|
# Install header files
|
|
install(DIRECTORY include/ DESTINATION include)
|
|
|
|
# Export the library for find_package()
|
|
install(EXPORT hiloadTargets
|
|
FILE hiloadConfig.cmake
|
|
DESTINATION lib/cmake/hiload
|
|
)
|
|
|
|
export(TARGETS hiload FILE hiloadConfig.cmake)
|
|
|
|
# auditor libraries
|
|
# ###############
|
|
|
|
add_library(auditor-x86_64 SHARED
|
|
src/auditor/auditor-x86_64.c
|
|
)
|
|
|
|
install(TARGETS auditor-x86_64
|
|
EXPORT auditor-x86_64Targets
|
|
ARCHIVE DESTINATION lib
|
|
LIBRARY DESTINATION lib
|
|
RUNTIME DESTINATION bin
|
|
)
|
|
|
|
# tests and test projects
|
|
# #######################
|
|
|
|
add_subdirectory(test)
|