option(ENABLE_LIB_livoxProto1 "Enable Livox Protocol v1 backend lib" ON)

if(ENABLE_LIB_livoxProto1)
	add_library(livoxProto1 SHARED
		livoxProto1.cpp
		core.cpp
		device.cpp
		protocol.cpp
		broadcastListener.cpp
		udpCommandDemuxer.cpp
	)

	set_target_properties(livoxProto1 PROPERTIES
		VERSION ${PROJECT_VERSION}
		SOVERSION ${PROJECT_VERSION_MAJOR}
	)

	# Set config define for header generation
	add_compile_definitions(CONFIG_LIB_LIVOXPROTO1_ENABLED)
	target_include_directories(livoxProto1 PUBLIC
		${Boost_INCLUDE_DIRS}
		${CMAKE_SOURCE_DIR}/include
		${CMAKE_SOURCE_DIR}/smocore/include
		${CMAKE_SOURCE_DIR}/commonLibs
	)
	target_link_libraries(livoxProto1 PUBLIC
		Boost::system Boost::log
		spinscale
	)

	# Verify Boost dynamic dependencies after build
	add_custom_command(TARGET livoxProto1 POST_BUILD
		COMMAND ${CMAKE_COMMAND} -DVERIFY_FILE="$<TARGET_FILE:livoxProto1>"
			-P ${CMAKE_SOURCE_DIR}/cmake/VerifyBoostDynamic.cmake
		COMMENT "Verifying Boost dynamic dependencies for livoxProto1"
	)

	# Install rules
	install(TARGETS livoxProto1
		LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} NAMELINK_SKIP
	)
endif()
