Some checks failed
Documentation / build-and-publish (push) Waiting to run
Test / test (push) Waiting to run
Checkout test / test (push) Successful in 5s
CI with Native Libraries / test-native (push) Has been cancelled
CI with Native Libraries / build-release (push) Has been cancelled
76 lines
2.1 KiB
CMake
76 lines
2.1 KiB
CMake
cmake_minimum_required(VERSION 3.20)
|
|
project(fetchml_native VERSION 0.1.0 LANGUAGES CXX C)
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_C_STANDARD 11)
|
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
|
|
# Build options
|
|
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
|
|
option(ENABLE_ASAN "Enable AddressSanitizer" OFF)
|
|
option(ENABLE_TSAN "Enable ThreadSanitizer" OFF)
|
|
|
|
# Position independent code for shared libraries
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
|
|
# Compiler flags
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
|
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native -DNDEBUG -fomit-frame-pointer")
|
|
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -fno-omit-frame-pointer")
|
|
set(CMAKE_C_FLAGS_RELEASE "-O3 -march=native -DNDEBUG -fomit-frame-pointer")
|
|
set(CMAKE_C_FLAGS_DEBUG "-O0 -g -fno-omit-frame-pointer")
|
|
|
|
# Warnings
|
|
add_compile_options(-Wall -Wextra -Wpedantic)
|
|
|
|
if(ENABLE_ASAN)
|
|
add_compile_options(-fsanitize=address -fno-omit-frame-pointer)
|
|
add_link_options(-fsanitize=address)
|
|
endif()
|
|
|
|
if(ENABLE_TSAN)
|
|
add_compile_options(-fsanitize=thread)
|
|
add_link_options(-fsanitize=thread)
|
|
endif()
|
|
endif()
|
|
|
|
if(APPLE)
|
|
# macOS universal binary support (optional - comment out if targeting single arch)
|
|
# set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64")
|
|
endif()
|
|
|
|
# Find threading library
|
|
find_package(Threads REQUIRED)
|
|
|
|
# Include directories
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
# Libraries will be added as subdirectories
|
|
add_subdirectory(queue_index)
|
|
add_subdirectory(dataset_hash)
|
|
add_subdirectory(artifact_scanner)
|
|
add_subdirectory(streaming_io)
|
|
|
|
# Combined target for building all libraries
|
|
add_custom_target(all_native_libs DEPENDS
|
|
queue_index
|
|
dataset_hash
|
|
artifact_scanner
|
|
streaming_io
|
|
)
|
|
|
|
# Install configuration
|
|
install(TARGETS queue_index dataset_hash artifact_scanner streaming_io
|
|
LIBRARY DESTINATION lib
|
|
ARCHIVE DESTINATION lib
|
|
)
|
|
|
|
# Install headers
|
|
install(FILES
|
|
queue_index/queue_index.h
|
|
dataset_hash/dataset_hash.h
|
|
artifact_scanner/artifact_scanner.h
|
|
streaming_io/streaming_io.h
|
|
DESTINATION include/fetchml
|
|
)
|