if(MeasureTest)
	add_definitions(-DETC_PATH="${CMAKE_CURRENT_LIST_DIR}")
endif ()

set(Target_Name
		clamp_safety
		)

include_directories(
	/usr/local/include/snap7
)

find_package(gRPC CONFIG REQUIRED)

aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/lidar LIDAR_SRC)
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/detect DETECT_SRC)
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/plc PLC_SRC)
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/grpc grpc)

set(Target_source
		${grpc}
		${PLC_SRC}
		${LIDAR_SRC}
		${DETECT_SRC}
		${CMAKE_CURRENT_LIST_DIR}/main.cpp
)

set(Target_libary
		zx
		snap7
		protobuf::libprotobuf
		gRPC::grpc++_reflection
		-lpthread
)

message(${Target_Name} ":" ${Target_libary})

add_executable(${Target_Name} ${Target_source})
target_link_libraries(${Target_Name} ${Target_libary})

#add_executable(${Target_Name}_viewer ${Target_source})
#target_link_libraries(${Target_Name}_viewer ${Target_libary})
#target_compile_definitions(${Target_Name}_viewer PRIVATE __VIEW__PCL=1)

# 将库文件，可执行文件，头文件安装到指定目录
install(TARGETS ${Target_Name}
		LIBRARY DESTINATION lib  # 动态库安装路径
		ARCHIVE DESTINATION lib  # 静态库安装路径
		RUNTIME DESTINATION bin  # 可执行文件安装路径
		PUBLIC_HEADER DESTINATION include  # 头文件安装路径
		)

		
install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/etc
		DESTINATION ${CMAKE_INSTALL_PREFIX}
		)
