2025-07-22 02:46:16 -04:00
|
|
|
cmake_minimum_required(VERSION 3.16)
|
2025-10-01 11:30:19 -04:00
|
|
|
project(salmanoff VERSION 0.01.000 LANGUAGES CXX)
|
2025-07-22 02:46:16 -04:00
|
|
|
|
2025-07-22 04:45:23 -04:00
|
|
|
include(CMakeDependentOption)
|
2025-09-16 21:30:50 -04:00
|
|
|
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DAPSS.cmake)
|
2025-09-22 20:45:36 -04:00
|
|
|
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DebugOpts.cmake)
|
2025-11-03 22:18:45 -04:00
|
|
|
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/VerifyBoostDynamic.cmake)
|
2025-07-22 04:45:23 -04:00
|
|
|
|
2025-07-22 02:46:16 -04:00
|
|
|
# Set C++ standard
|
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
|
|
|
|
|
# Build type
|
|
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
2025-07-28 07:20:44 -04:00
|
|
|
set(CMAKE_BUILD_TYPE Debug FORCE)
|
2025-07-22 02:46:16 -04:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# Compiler flags
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic")
|
|
|
|
|
|
|
|
|
|
# Mind oscillator configuration
|
|
|
|
|
set(MIND_VOSCILLATOR_PERIOD_MS 33 CACHE STRING "Mind's virtual osc clock rate (ms)")
|
|
|
|
|
if(NOT MIND_VOSCILLATOR_PERIOD_MS GREATER 0)
|
|
|
|
|
message(FATAL_ERROR "MIND_VOSCILLATOR_PERIOD_MS must be a positive integer > 0")
|
|
|
|
|
endif()
|
|
|
|
|
math(EXPR MIND_VOSCILLATOR_FREQ_MS "1000 / ${MIND_VOSCILLATOR_PERIOD_MS}")
|
|
|
|
|
|
2025-09-28 23:07:39 -04:00
|
|
|
# Device manager reattacher configuration
|
2025-09-30 23:10:10 -04:00
|
|
|
set(MRNTT_DEVMGR_REATTACHER_PERIOD_MS 2000
|
2025-09-28 23:07:39 -04:00
|
|
|
CACHE STRING "Device manager reattacher period (ms)")
|
|
|
|
|
if(NOT MRNTT_DEVMGR_REATTACHER_PERIOD_MS GREATER 0)
|
|
|
|
|
message(FATAL_ERROR
|
|
|
|
|
"MRNTT_DEVMGR_REATTACHER_PERIOD_MS must be a positive integer > 0")
|
|
|
|
|
endif()
|
|
|
|
|
|
2025-10-31 11:31:04 -04:00
|
|
|
# Stimulus buffer frame period configuration
|
|
|
|
|
set(STIMBUFF_FRAME_PERIOD_MS 33
|
|
|
|
|
CACHE STRING "Stimulus buffer frame period (ms)")
|
|
|
|
|
if(NOT STIMBUFF_FRAME_PERIOD_MS GREATER 0)
|
|
|
|
|
message(FATAL_ERROR
|
|
|
|
|
"STIMBUFF_FRAME_PERIOD_MS must be a positive integer > 0")
|
|
|
|
|
endif()
|
|
|
|
|
|
2025-10-31 12:08:40 -04:00
|
|
|
# Stimulus buffer frame retry delay configuration
|
2025-10-31 12:34:34 -04:00
|
|
|
set(STIMBUFF_FRAME_RETRY_DELAY_MS 1
|
2025-10-31 12:08:40 -04:00
|
|
|
CACHE STRING "Stimulus buffer frame retry delay (ms)")
|
|
|
|
|
if(NOT STIMBUFF_FRAME_RETRY_DELAY_MS GREATER 0)
|
|
|
|
|
message(FATAL_ERROR
|
|
|
|
|
"STIMBUFF_FRAME_RETRY_DELAY_MS must be a positive integer > 0")
|
|
|
|
|
endif()
|
|
|
|
|
|
2025-09-14 22:17:19 -04:00
|
|
|
# World thread configuration
|
|
|
|
|
option(WORLD_USE_BODY_THREAD
|
|
|
|
|
"Use body thread for world component instead of separate world thread" OFF)
|
2025-09-21 15:11:28 -04:00
|
|
|
|
2025-09-20 19:41:57 -04:00
|
|
|
# Test configuration
|
|
|
|
|
option(ENABLE_TESTS "Enable building tests" OFF)
|
2025-09-14 22:17:19 -04:00
|
|
|
|
2025-09-22 20:45:36 -04:00
|
|
|
# Set the debug locks variable for config.h
|
|
|
|
|
if(ENABLE_DEBUG_LOCKS)
|
|
|
|
|
set(CONFIG_ENABLE_DEBUG_LOCKS TRUE)
|
|
|
|
|
endif()
|
|
|
|
|
|
2025-11-06 21:40:32 -04:00
|
|
|
# Set the debug trace callables variable for config.h
|
|
|
|
|
if(ENABLE_DEBUG_TRACE_CALLABLES)
|
|
|
|
|
set(CONFIG_DEBUG_TRACE_CALLABLES TRUE)
|
|
|
|
|
# Suppress frame-address warnings when using __builtin_return_address()
|
|
|
|
|
# with values above 0 (See callableTracer.h).
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-frame-address")
|
|
|
|
|
endif()
|
|
|
|
|
|
2025-10-01 11:02:28 -04:00
|
|
|
# Set the world thread variable for config.h
|
|
|
|
|
if(WORLD_USE_BODY_THREAD)
|
|
|
|
|
set(CONFIG_WORLD_USE_BODY_THREAD TRUE)
|
|
|
|
|
endif()
|
|
|
|
|
|
2025-09-22 20:45:36 -04:00
|
|
|
# Set the timeout variable for config.h
|
|
|
|
|
set(CONFIG_DEBUG_QUTEX_DEADLOCK_TIMEOUT_MS ${DEBUG_QUTEX_DEADLOCK_TIMEOUT_MS})
|
2025-10-31 11:31:04 -04:00
|
|
|
# Set the stimulus buffer frame period variable for config.h
|
|
|
|
|
set(CONFIG_STIMBUFF_FRAME_PERIOD_MS ${STIMBUFF_FRAME_PERIOD_MS})
|
2025-10-31 12:08:40 -04:00
|
|
|
# Set the stimulus buffer frame retry delay variable for config.h
|
|
|
|
|
set(CONFIG_STIMBUFF_FRAME_RETRY_DELAY_MS ${STIMBUFF_FRAME_RETRY_DELAY_MS})
|
2025-09-22 20:45:36 -04:00
|
|
|
|
2025-07-22 02:46:16 -04:00
|
|
|
# Configure config.h
|
|
|
|
|
configure_file(
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include/config.h.in
|
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/include/config.h
|
2025-09-14 22:17:19 -04:00
|
|
|
@ONLY
|
2025-07-22 02:46:16 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Include directories
|
|
|
|
|
include_directories(
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
2025-07-22 06:15:12 -04:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/smocore/include
|
2025-07-22 02:46:16 -04:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/include
|
|
|
|
|
)
|
|
|
|
|
|
2025-07-22 04:45:23 -04:00
|
|
|
# Find core dependencies
|
2025-11-03 22:18:45 -04:00
|
|
|
# We cannot use header-only Boost.Asio because we need both our dlopen()'d
|
|
|
|
|
# libraries and the main binary to refer to the same instances of boost::asio's
|
|
|
|
|
# metadata. If we use header-only Boost.Asio, each dlopen()'d library will have
|
|
|
|
|
# its own copy of boost::asio's metadata, which will cause a segfault if
|
|
|
|
|
# boost::asio objects are used inside of a dlopen()'d library.
|
|
|
|
|
#
|
|
|
|
|
# Honestly, I never liked this whole "header-only" idea so I'm happy to be rid
|
|
|
|
|
# of it.
|
|
|
|
|
#
|
|
|
|
|
# Tell CMake we're linking against the shared library (not header-only)
|
|
|
|
|
set(Boost_USE_STATIC_LIBS OFF)
|
|
|
|
|
set(Boost_USE_HEADER_ONLY OFF)
|
|
|
|
|
find_package(Boost REQUIRED COMPONENTS system log)
|
2025-11-06 21:54:57 -04:00
|
|
|
# Define BOOST_ALL_DYN_LINK project-wide to ensure all Boost libraries use dynamic linking
|
|
|
|
|
add_compile_definitions(BOOST_ALL_DYN_LINK)
|
|
|
|
|
|
2025-07-22 02:46:16 -04:00
|
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
|
find_package(FLEX REQUIRED)
|
|
|
|
|
find_package(BISON REQUIRED)
|
|
|
|
|
|
2025-07-22 04:45:23 -04:00
|
|
|
# Need dlopen() and dlsym()
|
|
|
|
|
find_library(DL_LIBRARY NAMES dl ldl)
|
|
|
|
|
if(NOT DL_LIBRARY)
|
|
|
|
|
message(FATAL_ERROR "Dynamic linking library (libdl/libldl) not found")
|
2025-07-22 02:46:16 -04:00
|
|
|
endif()
|
|
|
|
|
|
2025-09-20 19:41:57 -04:00
|
|
|
# Add third-party dependencies
|
|
|
|
|
if(ENABLE_TESTS)
|
|
|
|
|
add_subdirectory(third_party)
|
|
|
|
|
endif()
|
2025-10-25 03:39:42 -04:00
|
|
|
add_subdirectory(compile)
|
2025-07-22 04:45:23 -04:00
|
|
|
# Add core components
|
2025-07-22 06:15:12 -04:00
|
|
|
add_subdirectory(smocore)
|
2025-07-22 02:46:16 -04:00
|
|
|
add_subdirectory(commonLibs)
|
2025-10-01 18:47:42 -04:00
|
|
|
add_subdirectory(stimBuffApis)
|
2025-07-22 04:45:23 -04:00
|
|
|
add_subdirectory(wilzorApis)
|
2025-09-16 21:30:50 -04:00
|
|
|
add_subdirectory(devices)
|
2025-07-22 02:46:16 -04:00
|
|
|
|
|
|
|
|
# Main executable
|
2025-07-22 06:00:00 -04:00
|
|
|
add_executable(salmanoff main.cpp)
|
|
|
|
|
target_link_libraries(salmanoff
|
2025-11-03 22:18:45 -04:00
|
|
|
Boost::system Boost::log
|
2025-07-22 06:15:12 -04:00
|
|
|
smocore
|
2025-07-22 04:45:23 -04:00
|
|
|
${DL_LIBRARY}
|
2025-11-04 00:22:25 -04:00
|
|
|
attachmentSupport
|
2025-07-22 02:46:16 -04:00
|
|
|
)
|
|
|
|
|
|
2025-11-03 22:18:45 -04:00
|
|
|
# Verify Boost dynamic dependencies after build
|
|
|
|
|
add_custom_command(TARGET salmanoff POST_BUILD
|
|
|
|
|
COMMAND ${CMAKE_COMMAND} -DVERIFY_FILE="$<TARGET_FILE:salmanoff>"
|
|
|
|
|
-P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/VerifyBoostDynamic.cmake
|
|
|
|
|
COMMENT "Verifying Boost dynamic dependencies for salmanoff"
|
|
|
|
|
)
|
|
|
|
|
|
2025-09-16 21:30:50 -04:00
|
|
|
# Add all registered DAPSS targets as dependencies
|
|
|
|
|
add_all_daps_dependencies()
|
|
|
|
|
|
2025-09-20 19:41:57 -04:00
|
|
|
# Add tests if enabled
|
|
|
|
|
if(ENABLE_TESTS)
|
|
|
|
|
enable_testing()
|
|
|
|
|
add_subdirectory(tests)
|
|
|
|
|
endif()
|
|
|
|
|
|
2025-07-22 06:00:00 -04:00
|
|
|
install(TARGETS salmanoff DESTINATION bin)
|
2025-09-16 22:19:48 -04:00
|
|
|
|
|
|
|
|
# Install device configuration files (preprocessed .daps files)
|
|
|
|
|
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/devices/
|
|
|
|
|
DESTINATION share/salmanoff/devices
|
|
|
|
|
FILES_MATCHING PATTERN "*.daps"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Install documentation
|
|
|
|
|
install(FILES README.md DESTINATION share/doc/salmanoff)
|
|
|
|
|
install(FILES LICENSE DESTINATION share/doc/salmanoff)
|
|
|
|
|
|
|
|
|
|
# Install example configurations if they exist
|
|
|
|
|
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples")
|
|
|
|
|
install(DIRECTORY examples/ DESTINATION share/salmanoff/examples)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# Include CPack configuration
|
|
|
|
|
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/CPackConfig.cmake)
|
|
|
|
|
include(CPack)
|